import Connector.PyTree as X import KCore.test as test # Cas 3D NGon avec raccord match # =============================== ni = 30 nj = 30 nk = 10 lx = 1. ly = 1. lz = 0.25 dx = lx/float(ni-1) dy = ly/float(nj-1) dz = lz/float(nk-1) a = G.cartNGon((1,1,1), (dx,dy,dz), (ni,nj,nk)); a[0]='cart1' b = G.cartNGon((lx+1,1+(ni/2.)*dy,1), (dx,dy,dz), (ni,nj,nk)); b[0]='cart2' c = G.cartNGon((lx+1,1-(ni/2.-1)*dy,1), (dx,dy,dz), (ni,nj,nk)); c[0]='cart3' t = C.newPyTree(['Base',a,b,c]) t = C.initVars(t, '{centers:F}={centers:CoordinateX}*{centers:CoordinateY}*{centers:CoordinateZ}') t = C.initVars(t, '{G}=2.3') t = C.initVars(t, '{centers:H}={centers:CoordinateY}') t = C.initVars(t, '{centers:M}={centers:CoordinateX}') t = X.connectMatch(t) t = C.fillEmptyBCWith(t,"wall",'BCWall') P._computeGrad2(t, 'centers:F') test.testT(t,1)
# - computeDiv2 (pyTree) - import Converter.PyTree as C import Post.PyTree as P import Generator.PyTree as G m = G.cartNGon((0,0,0), (1,1,1), (4,4,4)) C._initVars(m, '{centers:fldX}= cos({centers:CoordinateX})') C._initVars(m, '{centers:fldY}= 4.*{centers:CoordinateY}') C._initVars(m, '{centers:fldZ}= {centers:CoordinateY}*{centers:CoordinateZ}**2.') m = P.computeDiv2(m, 'centers:fld') C.convertPyTree2File(m, 'out.cgns')
# - setInterpData (pyTree) - # donneur NGON + leastsquare import Converter.PyTree as C import Generator.PyTree as G import Connector.PyTree as X import Geom.PyTree as D import KCore.test as test # NGON donor zone a = G.cartNGon((0, 0, -0.2), (0.01, 0.01, 0.1), (101, 101, 5)) # receiver pts = D.circle((0.5, 0.5, 0), 0.05, N=20) pts = C.initVars(pts, 'centers:cellN=2') pts2 = X.setInterpData(pts, a, order=3, nature=1, loc='centers', storage='direct', hook=None, method='leastsquares') test.testT(pts2, 1)
# - identifyFaces (pyTree) - import Converter.PyTree as C import Generator.PyTree as G a = G.cartNGon((0, 0, 0), (1, 1, 1), (10, 10, 10)) b = G.cartNGon((9, 0, 0), (1, 1, 1), (10, 10, 10)) # Enregistre les centres des faces de a dans le hook hook = C.createHook(a, function='faceCenters') # Indices des faces de a correspondant aux faces de b faces = C.identifyFaces(hook, b) print(faces) #>> [10 -1 -1 ..., -1 -1 -1]
# Create a function def F(x, y, z): deg = 1 if deg == 0: return 10. elif deg == 1: return x + 2. * y + 3. * z elif deg == 2: return x * x + 2. * y * y + 3 * z elif deg == 3: return x * x * y + 2. * y * y * y + 3 * z elif deg == 4: return x * x * x * x + 2. * y * y * y * y + z * z else: return 2 * x * x * x * x * x + 2. * y * y * z + z * z # Donor mesh ni = 11 nj = 11 nk = 11 m = G.cartNGon((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk)) C._initVars(m, '{F}={CoordinateX}+2*{CoordinateY}+3*{CoordinateZ}') C._initVars(m, '{G}=10*{CoordinateX}') C._initVars(m, 'centers:G', 1.) # Receiver mesh a = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk)) a[0] = 'extraction' C._initVars(a, 'F', -1000.) C._initVars(a, 'G', -1000.) # 2nd order, nodes, direct storage t = C.newPyTree(['Rcv', 'Dnr']) t[2][1][2] = [a] t[2][2][2] = [m] C._initVars(t[2][1], 'cellN', 2) t[2][2] = X.setInterpData(t[2][1],
# - getBCs (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import KCore.test as test a = G.cart((0,0,0),(1,1,1),(10,10,2)) a = C.addBC2Zone(a, 'overlap', 'BCOverlap', 'imin') a = C.addBC2Zone(a, 'match1', 'BCMatch', 'jmin', a, 'jmax', [1,2,3]) a = C.fillEmptyBCWith(a, 'wall', 'BCWall', dim=2) (BCs,BCNames,BCTypes) = C.getBCs(a) test.testO(BCNames, 1) a = G.cartHexa((0,0,0),(1,1,1),(10,10,2)) a = C.addBC2Zone(a, 'wall', 'BCWall', faceList=[1,2]) (BCs,BCNames,BCTypes) = C.getBCs(a) test.testO(BCNames, 2) a = G.cartNGon((0,0,0),(1,1,1),(10,10,2)) a = C.addBC2Zone(a, 'wall', 'BCWall', faceList=[1,2]) (BCs,BCNames,BCTypes) = C.getBCs(a) test.testO(BCNames, 3)
import KCore.test as T # Structure a = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (11, 11, 11)) a = G.enforcePlusX(a, 1e-6, (5, 50)) a = C.addBC2Zone(a, 'wall1', 'BCWall', 'jmin') a = C.fillEmptyBCWith(a, 'overlap', 'BCOverlap') a = C.initVars(a, 'F', 1.) a = C.initVars(a, 'centers:G', 1.) a = G.getEdgeRatio(a) T.testT(a, 1) # TEST NON STRUCTURE ELT BASIQUE a = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (11, 11, 11)) a = G.enforcePlusX(a, 1e-6, (5, 50)) a = C.convertArray2Tetra(a) a = C.initVars(a, 'F', 1.) a = C.initVars(a, 'centers:G', 1.) a = G.getEdgeRatio(a) T.testT(a, 2) # TEST NON STRUCTURE NGON a = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (11, 11, 11)) a = G.enforcePlusX(a, 1e-6, (5, 50)) a = C.convertArray2NGon(a) a = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.1), (11, 11, 11)) a = C.initVars(a, 'F', 1.) a = C.initVars(a, 'centers:G', 1.) a = G.getEdgeRatio(a) T.testT(a, 3)
b = G.cart((10,0.,0.), (0.1,0.1,0.2), (10,10,5)) C._initVars(a,'F',1.); C._initVars(a,'centers:G',2.) a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin') A = C.convertArray2Tetra([a,b],split='withBarycenters') t = C.newPyTree(['Base']); t[2][1][2] = t[2][1][2] + A test.testT(t, 3) # Sur un HEXA a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (10,10,5)) C._initVars(a, 'F={CoordinateX}') C._initVars(a, 'centers:G={CoordinateY}') a = C.convertArray2Tetra(a,split='withBarycenters') t = C.newPyTree(['Base',a]) test.testT(t, 4) # Sur un QUAD a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (10,10,1)) a = C.initVars(a, 'F={CoordinateX}') a = C.initVars(a, 'centers:G={CoordinateY}') a = C.convertArray2Tetra(a,split='withBarycenters') t = C.newPyTree(['Base',2,a]) test.testT(t, 5) # Sur un NGON a = G.cartNGon((0.,0.,0.), (0.1,0.1,0.2), (10,10,1)) C._initVars(a, 'F={CoordinateX}') C._initVars(a, 'centers:G={CoordinateY}') a = C.convertArray2Tetra(a,split='withBarycenters') t = C.newPyTree(['Base',2,a]) test.testT(t, 6)
test.testT(a, 2) # reorder a QUAD mesh a = G.cartHexa((0, 0, 0), (1, 1, 1), (8, 9, 1)) C._initVars(a, '{Density}={CoordinateX}**2+2*{CoordinateY}') C._initVars(a, '{centers:F}={centers:CoordinateX}') a = T.reorder(a, (-1, )) test.testT(a, 3) # reorder a NGON mesh: sphere case a = D.sphere6((0, 0, 0), 1., 20) a = C.convertArray2NGon(a) a = T.join(a) a = G.close(a) a = T.reorder(a, (1, )) G._getNormalMap(a) a = C.initVars(a, '{centers:DensityX}=12.*{centers:sx}') C._initVars(a, '{centers:DensityY}=12.*{centers:sy}') C._initVars(a, '{centers:DensityZ}=12.*{centers:sz}') resX = P.integ(a, var='centers:DensityX') resY = P.integ(a, var='centers:DensityX') resZ = P.integ(a, var='centers:DensityX') test.testT(a, 4) # reorder a NGON mesh v2 a = G.cartNGon((0, 0, 0), (1, 1, 1), (8, 9, 1)) C._initVars(a, '{Density}={CoordinateX}**2+2*{CoordinateY}') C._initVars(a, '{centers:F}={centers:CoordinateX}') a = T.reorder(a, (-1, )) #test.testT(a,5)
import numpy ns = 200 a = G.cart((0, 0, 0), (1, 1, 1), (ns, ns, ns)) # Get an array2 from a x1 = Internal.getNodeFromName2(a, 'CoordinateX') x2 = Internal.getNodeFromName2(a, 'CoordinateY') x3 = Internal.getNodeFromName2(a, 'CoordinateZ') b = ['x,y,z', [x1[1], x2[1], x3[1]], ns, ns, ns] #KCore.tester(b) a = G.cartHexa((0, 0, 0), (1, 1, 1), (ns, ns, ns)) # Get an array2 from a x1 = Internal.getNodeFromName2(a, 'CoordinateX') x2 = Internal.getNodeFromName2(a, 'CoordinateY') x3 = Internal.getNodeFromName2(a, 'CoordinateZ') c1 = Internal.getNodeFromName2(a, 'ElementConnectivity') c1 = c1[1].reshape((8, (ns - 1) * (ns - 1) * (ns - 1))) # cool b = ['x,y,z', [x1[1], x2[1], x3[1]], [c1], 'HEXA'] KCore.tester(b) a = G.cartNGon((0, 0, 0), (1, 1, 1), (ns, ns, ns)) C.convertPyTree2File(a, 'out.cgns') # Get an array2 from a x1 = Internal.getNodeFromName2(a, 'CoordinateX') x2 = Internal.getNodeFromName2(a, 'CoordinateY') x3 = Internal.getNodeFromName2(a, 'CoordinateZ') c1 = Internal.getNodesFromName2(a, 'ElementConnectivity') b = ['x,y,z', [x1[1], x2[1], x3[1]], [c1], 'HEXA'] KCore.tester(b)
z = C.initVars(z, 'centers:G=2') res = C.getFields('FlowSolution', z) test.testA(res, 4) res = C.getFields('FlowSolution#Centers', z) test.testA(res, 5) z = G.cartTetra((0., 0., 0.), (1., 1., 1.), (10, 10, 1)) z = C.initVars(z, 'F=1') z = C.initVars(z, 'centers:G=2') res = C.getFields('FlowSolution', z) test.testA(res, 6) res = C.getFields('FlowSolution#Centers', z) test.testA(res, 7) z = G.cartTetra((0., 0., 0.), (1., 1., 1.), (10, 1, 1)) z = C.initVars(z, 'F=1') z = C.initVars(z, 'centers:G=2') res = C.getFields('FlowSolution', z) test.testA(res, 8) res = C.getFields('FlowSolution#Centers', z) test.testA(res, 9) # NGON z = G.cartNGon((0., 0., 0.), (1., 1., 1.), (10, 10, 10)) z = C.initVars(z, 'F=1') z = C.initVars(z, 'centers:G=2') res = C.getFields('FlowSolution', z) test.testA(res, 10) res = C.getFields('FlowSolution#Centers', z) test.testA(res, 11)
# - extractAllBCMatch (pyTree) - import Generator.PyTree as G import Converter.PyTree as CP import Converter.Internal as Internal import Transform.PyTree as T import Connector.PyTree as X import KCore.test as test varL = ['centers:H', 'centers:M'] a = G.cartNGon((1, 1, 1), (1., 1., 1.), (4, 10, 3)) a[0] = 'cart1' b = G.cartNGon((4, 2, 0), (1., 1., 1.), (5, 8, 5)) b[0] = 'cart2' t = CP.newPyTree(['Base', a, b]) t = CP.initVars(t, '{F}=3*{CoordinateX}+2*{CoordinateY}') t = CP.initVars(t, '{centers:G}=2.3') t = CP.initVars(t, '{centers:H}={centers:CoordinateY}') t = CP.initVars(t, '{centers:M}={centers:CoordinateX}') t = X.connectMatch(t, dim=3) t = CP.fillEmptyBCWith(t, "wall", 'BCWall') dico = CP.extractAllBCMatch(t, varL) it = 0 for z in Internal.getZones(t): it = it + 1 indR, fld = CP.computeBCMatchField(z, dico, varL)
# - cartNGon (pyTree) - import Generator.PyTree as G import Converter.PyTree as C a = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.2), (2, 2, 2)) C.convertPyTree2File(a, 'out.cgns')
# - addBC2Zone (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import KCore.test as test # - NGons - # Ajout par une faceList a = G.cartNGon((2,0,0), (0.1,0.1,1), (10,10,2)) a = C.addBC2Zone(a, 'wall', 'BCWall', faceList=[1,2]) test.testT(a, 1) # ajout par une subzone b = G.cartNGon((2,0,0), (0.1,0.1,1), (10,1,2)) a = C.addBC2Zone(a, 'wall', 'BCWall', subzone=b) test.testT(a, 2) # raccords match - ajout par une subzone a = G.cartNGon((0,0,0), (0.1,0.1,1), (11,11,2)) faceMatch = G.cartNGon((1,0,0), (0.1,0.1,1), (1,11,2)) b = G.cartNGon((1,0,0), (0.1,0.1,1), (11,11,2)) a = C.addBC2Zone(a, 'match', 'BCMatch', subzone=faceMatch, zoneDonor=b) b = C.addBC2Zone(b, 'match', 'BCMatch', subzone=faceMatch, zoneDonor=a) t = C.newPyTree(['Base',a,b,faceMatch]) test.testT(t, 3) # raccords match - ajout par une faceList a = G.cartNGon((0,0,0), (0.1,0.1,1), (11,11,2)) b = G.cartNGon((1,0,0), (0.1,0.1,1), (11,11,2)) faceLista = [11,22,33,44,55,66,77,88,99,110] faceListb = [1,12,23,34,45,56,67,78,89,100]
# subzone faces (pyTree) import Converter.PyTree as C import Generator.PyTree as G import Transform.PyTree as T import KCore.test as test N = 51 d = G.cartNGon((0,0,0), (1,1,1),(N,N,N)) facesL=[] for i in xrange(1,N*N): facesL.append(i+1) C._initVars(d,'F={CoordinateX}') C._initVars(d,'centers:G={centers:CoordinateY}') d = T.subzone(d, facesL, type='faces') test.testT(d,1) # 3D Tetra N = 51 d = G.cartTetra((0,0,0), (1,1,1),(N,N,N)) facesL=[] for i in xrange(1,N*N): facesL.append(i+1) C._initVars(d,'F={CoordinateX}') C._initVars(d,'centers:G={centers:CoordinateY}') d = T.subzone(d, facesL, type='faces') test.testT(d,2) # 3D Hexa N = 51 d = G.cartHexa((0,0,0), (1,1,1),(N,N,N)) facesL=[] for i in xrange(1,N*N): facesL.append(i+1) C._initVars(d,'F={CoordinateX}') C._initVars(d,'centers:G={centers:CoordinateY}') d = T.subzone(d, facesL, type='faces')
# BC referencees par des familles a = G.cart((0., 0., 0), (0.01, 0.01, 1.), (20, 20, 2)) a = C.addBC2Zone(a, 'walla', 'FamilySpecified:CARTER', 'imin') a = C.addBC2Zone(a, 'nref', 'FamilySpecified:LOIN', 'imax') t = C.newPyTree(['Base']) t[2][1][2] += [a] t[2][1] = C.addFamily2Base(t[2][1], 'CARTER', bndType='BCWall') t[2][1] = C.addFamily2Base(t[2][1], 'LOIN', bndType='BCFarfield') zones = C.extractBCOfType(t, 'BCWall') t = C.newPyTree(['Base']) t[2][1][2] += zones test.testT(t, 4) # BC sur un NGON a = G.cartNGon((0, 0, 0), (1, 1, 1), (10, 10, 10)) subzone = G.cartNGon((0, 0, 0), (1, 1, 1), (10, 10, 1)) hook = C.createHook(a, function='faceCenters') ids = C.identifyElements(hook, subzone) a = C.addBC2Zone(a, 'wall', 'BCWall', faceList=ids) ext = C.extractBCOfType(a, 'BCWall') test.testT(ext, 5) # BC sur un basic elements a = G.cartHexa((0, 0, 0), (1, 1, 1), (5, 5, 5)) subzone = G.cartHexa((0, 0, 0), (1, 1, 1), (5, 5, 1)) hook = C.createHook(a, function='faceCenters') ids = C.identifyElements(hook, subzone) a = C.addBC2Zone(a, 'wall', 'BCWall', faceList=ids) ext = C.extractBCOfType(a, 'BCWall') test.testT(ext, 6)
# --- Equation state t[2][1] = C.addState(t[2][1], 'EquationDimension', 3) t[2][1][2] = X.connectMatch(t[2][1][2]) test.testT(t, 1) # coincident a3 = G.cart((1.00001, 0., 0.), (0.1, 0.1, 0.1), (11, 21, 2)) a3[0] = 'cart3' t = C.newPyTree(['Base']) t[2][1][2] += [a, a3] C._addState(t[2][1], 'EquationDimension', 3) t[2][1][2] = X.connectMatch(t[2][1][2], tol=2.e-5) test.testT(t, 2) # CAS NGON a1 = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.1), (11, 21, 11)) a1[0] = 'cart1' a2 = G.cartNGon((1., 0., 0.), (0.1, 0.1, 0.1), (11, 21, 11)) a2[0] = 'cart2' t = C.newPyTree(['Base']) t[2][1][2] += [a1, a2] C._addState(t[2][1], 'EquationDimension', 3) C._initVars(t, 'centers:Density', 1.) C._initVars(t, 'F', 0.) t = X.connectMatch(t) test.testT(t, 3) # Cas hybride a1 = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.1), (11, 21, 11)) a1[0] = 'cartNGon' a2 = G.cart((1., 0., 0.), (0.1, 0.1, 0.1), (11, 21, 11))
# - adapt2FastP2 (pyTree) - import Generator.PyTree as G import Transform.PyTree as T import Converter.PyTree as C import Converter.Internal as Internal import Connector.PyTree as X import Converter.GhostCells as GC import KCore.test as test a = G.cartNGon((0, 0, 0), (1, 1, 1), (6, 6, 3)) b = T.splitNParts(a, N=3) t = C.newPyTree(['Base', b]) t = X.connectMatch(t) t = C.fillEmptyBCWith(t, 'wall', 'BCWall', dim=3) Internal._adaptNFace2PE(t, remove=False) # Test avec deux couches t = GC.adapt2FastP2(t, nlayers=2) # creation parentElement du NGon test.testT(t, 1)
a = C.convertArray2NGon(a) a = G.close(a) a = C.initVars(a, 'centers:F={centers:CoordinateX}**2') a = C.initVars(a, 'Density=3*{CoordinateX}+2*{CoordinateY}') t = C.newPyTree(['Base']) t[2][1][2] = [a] t = Internal.addGhostCells(t, t, 1, adaptBCs=0, fillCorner=1) t = Internal.rmGhostCells(t, t, 1) test.testT(t, 2) # 2D sans frontieres exterieures a = D.sphere((0, 0, 0), 1, N=10) a = C.convertArray2NGon(a) a = C.initVars(a, 'centers:F={centers:CoordinateX}**2') a = C.initVars(a, 'Density=3*{CoordinateX}+2*{CoordinateY}') t = C.newPyTree(['Base']) t[2][1][2] = [a] t = Internal.addGhostCells(t, t, 1, adaptBCs=0, fillCorner=1) t = Internal.rmGhostCells(t, t, 1) test.testT(t, 3) # 2D avec frontieres exterieures a = G.cartNGon((0, 0, 0), (1, 1, 1), (21, 21, 1)) a = C.initVars(a, 'centers:F={centers:CoordinateX}**2') a = C.initVars(a, 'Density=3*{CoordinateX}+2*{CoordinateY}') t = C.newPyTree(['Base']) t[2][1][2] = [a] t = Internal.addGhostCells(t, t, 1, adaptBCs=0, fillCorner=1) t = Internal.rmGhostCells(t, t, 1) test.testT(t, 4)
# - conformizeNGon (pyTree) - import Generator.PyTree as G import Converter.PyTree as C import Transform.PyTree as T a = G.cartNGon((0, 0, 0), (0.1, 0.1, 1), (11, 11, 1)) b = G.cartNGon((1., 0, 0), (0.1, 0.2, 1), (11, 6, 1)) res = T.join(a, b) res = C.conformizeNGon(res) t = C.newPyTree(['Base', res]) C.convertPyTree2File(t, 'out.cgns')
# - extractBCMatch (pyTree) - import Generator.PyTree as G import Converter.PyTree as CP import Converter.Internal as Internal import Connector.PyTree as X import KCore.test as test a = G.cartNGon((1, 1, 1), (1., 1., 1.), (4, 10, 1)) a[0] = 'cart1' b = G.cartNGon((4, 2, 1), (1., 1., 1.), (5, 8, 1)) b[0] = 'cart2' c = G.cartNGon((4, 9, 1), (1., 1., 1.), (4, 5, 1)) c[0] = 'cart3' t = CP.newPyTree(['Base', a, b, c]) t = CP.initVars(t, '{F}=3*{CoordinateX}+2*{CoordinateY}') t = CP.initVars(t, '{centers:G}=2.3') t = CP.initVars(t, '{centers:H}={centers:CoordinateY}') t = CP.initVars(t, '{centers:M}={centers:CoordinateX}') t = X.connectMatch(t, dim=2) t = CP.fillEmptyBCWith(t, "wall", 'BCWall') varL = ['H'] zones = Internal.getZones(t) it = 0 for z in zones: dim = Internal.getZoneDim(z) gcs = Internal.getNodesFromType2(z, 'GridConnectivity_t')
# - breakElements (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Transform.PyTree as T a = G.cartTetra((0, 0, 0), (1, 1, 1), (3, 3, 2)) a = C.convertArray2NGon(a) a = G.close(a) b = G.cartNGon((2, 0, 0), (1, 1, 1), (3, 3, 1)) res = T.join(a, b) res = T.breakElements(res) C.convertPyTree2File(res, 'out.cgns')
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmin') a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2, 3]) C._addVars(a, 'Density') C._initVars(a, 'centers:cellN', 1) t = C.newPyTree(['Base', a]) t = T.splitNParts(t, 4, multigrid=0, dirs=[1, 2, 3]) 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]) C._addVars(a, 'Density') C._initVars(a, 'centers:cellN', 1) t = C.newPyTree(['Base', 3, a]) t = T.splitNParts(t, 4, multigrid=0, dirs=[1, 2, 3]) test.testT(t, 2) a = G.cart((0, 0, 0), (1, 1, 1), (81, 81, 81)) b = G.cart((80, 0, 0), (1, 1, 1), (41, 81, 41)) t = C.newPyTree(['Base', a, b]) t = T.splitNParts(t, 10, multigrid=0, dirs=[1, 2, 3]) test.testT(t, 3) a = G.cart((0, 0, 0), (1, 1, 1), (81, 81, 81)) b = G.cartNGon((80, 0, 0), (1, 1, 1), (41, 81, 41)) t = C.newPyTree(['Base', a, b]) t = T.splitNParts(t, 10, multigrid=0, dirs=[1, 2, 3]) test.testT(t, 4)
# - addBC2Zone (pyTree) - import Converter.PyTree as C import Generator.PyTree as G # - NGons - a = G.cartNGon((2, 0, 0), (0.1, 0.1, 1), (10, 10, 2)) a = C.addBC2Zone(a, 'wall', 'BCWall', faceList=[1, 2]) C.convertPyTree2File(a, 'out.cgns')
C._initVars(t, '{centers:fldY}= ({centers:CoordinateY})**2') C._initVars(t, '{centers:fldZ}= ({centers:CoordinateZ})**2') C._initBCDataSet(t, '{fldX}=0.5') C._initBCDataSet(t, '{fldY}=0.5') C._initBCDataSet(t, '{fldZ}=0.5') P._computeDiv2(t, 'centers:fld') test.testT(t, 2) #---------- # 2D NGON #---------- ni = 15 nj = 15 m1 = G.cartNGon((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1.), (ni, nj, 2)) m2 = G.cartNGon((0, 10, 0), (10. / (ni - 1), 10. / (nj - 1), 1.), (ni, nj, 2)) m3 = G.cartNGon((10, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1.), (ni, nj, 2)) t1 = C.newPyTree(['Base', m1, m2, m3]) t1 = X.connectMatch(t1, dim=2) t1 = C.fillEmptyBCWith(t1, "wall", 'BCWall') C._initVars(t1, '{centers:fldX}= ({centers:CoordinateX})**2') C._initVars(t1, '{centers:fldY}= ({centers:CoordinateY})**2') C._initVars(t1, '{centers:fldZ}= ({centers:CoordinateZ})**2') C._initBCDataSet(t1, '{fldX}=0.5') C._initBCDataSet(t1, '{fldY}=0.5') C._initBCDataSet(t1, '{fldZ}=0.5')
# - adapt2FastP (pyTree) - import Generator.PyTree as G import Converter.PyTree as C import Converter.Internal as Internal a = G.cartNGon((0,0,0), (1,1,1), (30,30,20)) Internal._adapt2FastP(a) C.convertPyTree2File(a, 'out.cgns')