def splitAndDistribute(event=None): global STATS if CTK.t == []: return try: NProc = int(VARS[0].get()) except: CTK.TXT.insert('START', 'distribute: NProc is invalid.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return try: comSpeed = float(VARS[1].get()) except: CTK.TXT.insert('START', 'distribute: ComSpeed is invalid.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return algo = VARS[2].get() useCom = VARS[3].get() level = int(VARS[5].get()) CTK.saveTree() try: #CTK.t = T.splitNParts(CTK.t, NProc, multigrid=level) CTK.t = T.splitSize(CTK.t, N=0, multigrid=level, R=NProc, type=2) # no need to check inconsistant match (they have been deleted) node = Internal.getNodeFromName(CTK.t, 'EquationDimension') if node is not None: ndim = Internal.getValue(node) # Manque le reglage de la tol else: CTK.TXT.insert( 'START', 'EquationDimension not found (tkState). Using 3D.\n') CTK.TXT.insert('START', 'Warning: ', 'Warning') ndim = 3 CTK.t = X.connectMatch(CTK.t, dim=ndim) CTK.display(CTK.t) except Exception as e: Panels.displayErrors([0, str(e)], header='Error: distribute/split') CTK.TXT.insert('START', 'splitSize fails for at least one zone.\n') CTK.TXT.insert('START', 'Warning: ', 'Warning') (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) CTK.t, STATS = D.distribute(CTK.t, NProc, perfo=(1., 0., comSpeed), useCom=useCom, algorithm=algo) CTK.TXT.insert('START', 'Blocks split and distributed.\n') CTK.TKTREE.updateApp() updateStats()
#!/usr/bin/env python # coding: utf-8 r"""<TBC>""" import Generator.PyTree as G import Converter.PyTree as C import Transform.PyTree as T import Geom.PyTree as D a = G.cart((-2, -2, -2), (0.04, 0.04, 0.04), (100, 100, 100)) a = T.splitSize(a, N=100000) b = D.sphere((0, 0, 0), 1., N=100) t = C.newPyTree(['Base']) t[2][1][2] += a C.convertPyTree2File(t, 'in.cgns') t = C.newPyTree(['Base']) t[2][1][2] += [b] C.convertPyTree2File(t, 'walls.cgns')
# - merge (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Transform.PyTree as T import Connector.PyTree as X import Geom.PyTree as D def f(t,u): x = t+u y = t*t+1+u*u z = u return (x,y,z) a = D.surface(f) b = T.splitSize(a, 100) b = X.connectMatch(b, dim=2) t = C.newPyTree(['Surface']); t[2][1][2] += b b = T.merge(t) t[2][1][2] = b C.convertPyTree2File(t, "out.cgns")
import Transform.PyTree as T import Connector.PyTree as X import Geom.PyTree as D import KCore.test as test def f(t, u): x = t + u y = t * t + 1 + u * u z = u return (x, y, z) # surface grid a = D.surface(f, N=50) b = T.splitSize(a, 100) b = X.connectMatch(b, dim=2) t = C.newPyTree(['Surface', 2]) t[2][1][2] += b t = C.initVars(t, 'F', 1.) t = C.initVars(t, 'centers:G', 2.) t[2][1][2][0] = C.addBC2Zone(t[2][1][2][0], 'overlap', 'BCOverlap', 'imin') t = C.fillEmptyBCWith(t, 'wall', 'BCWall', dim=2) b = T.merge(t) t2 = C.newPyTree(['Surface', 2]) t2[2][1][2] += b test.testT(t2, 1) b = T.merge(t, alphaRef=45.) t2 = C.newPyTree(['Surface', 2]) t2[2][1][2] = b test.testT(t2, 2)
import Generator.PyTree as G import Transform.PyTree as T import Converter.PyTree as C import Connector.PyTree as X import KCore.test as test # Structure + Champs + CL a = G.cart((0, 0, 0), (1, 1, 1), (50, 20, 10)) a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin') a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmin') a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2, 3]) a = C.addVars(a, 'Density') a = C.initVars(a, 'centers:cellN', 1) t = C.newPyTree(['Base']) t[2][1][2].append(a) t = T.splitSize(t, 1000) t = X.connectMatch(t) test.testT(t, 1) # 2D Structure + Champs + CL a = G.cart((0, 0, 0), (1, 1, 1), (50, 20, 2)) a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin') a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmin') a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2]) a = C.addVars(a, 'Density') a = C.initVars(a, 'centers:cellN', 1) t = C.newPyTree(['Base', 3]) t[2][1][2].append(a) t = T.splitSize(t, 100) t = X.connectMatch(t) test.testT(t, 2)
# - splitSize (pyTree) - import Generator.PyTree as G import Transform.PyTree as T import Converter.PyTree as C a = G.cart((0,0,0),(1,1,1),(50,20,10)) t = C.newPyTree(['Base',a]) t = T.splitSize(t, 300, type=0) C.convertPyTree2File(t, 'out.cgns')
# - splitSize (pyTree) - import Generator.PyTree as G import Transform.PyTree as T import Converter.PyTree as C import Connector.PyTree as X import KCore.test as test t = C.newPyTree(['Base']) a = G.cart((0, 0, 0), (1, 1, 1), (51, 21, 11)) a[0] = 'cart1' a2 = T.translate(a, (46, 0, 0)) a2[0] = 'cart2' a3 = T.translate(a, (-50, 0, 0)) a3[0] = 'cart3' a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'imax') a2 = C.addBC2Zone(a2, 'overlap2', 'BCOverlap', 'imin') t[2][1][2] += [a, a2, a3] t = C.fillEmptyBCWith(t, 'wall', 'BCWall') t[2][1] = C.addState(t[2][1], 'EquationDimension', 3) t = T.splitSize(t, 700) t = X.connectMatch(t) test.testT(t)
#!/usr/bin/env python # coding: utf-8 r"""<TBC>""" # Case import Converter.PyTree as C import Generator.PyTree as G import Transform.PyTree as T a = G.cart((0, 0, 0), (1, 1, 1), (100, 100, 50)) a = C.initVars( a, 'F = sin({CoordinateX}*0.1)*cos({CoordinateY}*0.1)*sin({CoordinateZ}*0.1)') a = T.splitSize(a, N=3000) C.convertPyTree2File(a, 'cart.cgns')