# - computeNormGrad (pyTree) - import Converter.PyTree as C import Post.PyTree as P import Generator.PyTree as G ni = 30 nj = 40 nk = 10 m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk)) m = C.initVars(m, '{Density}=2*{CoordinateX}+{CoordinateX}*{CoordinateY}') m = P.computeNormGrad(m, 'Density') C.convertPyTree2File(m, 'out.cgns')
# - rotate (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), (10, 10, 2)) # Rotate with an axis and an angle b = T.rotate(a, (0., 0., 0.), (0., 0., 1.), 30.) b[0] = 'cartRot1' # Rotate with two axis c = T.rotate(a, (0., 0., 0.), ((1., 0., 0.), (0, 1, 0), (0, 0, 1)), ((1, 1, 0), (1, -1, 0), (0, 0, 1))) c[0] = 'cartRot2' # Rotate with three angles c = T.rotate(a, (0., 0., 0.), (0, 0, 90)) c[0] = 'cartRot3' C.convertPyTree2File([a, b, c], 'out.cgns')
#!/usr/bin/env python # coding: utf-8 r"""curve (pyTree)""" import Converter.PyTree as C import Geom.PyTree as D # User definition of parametric curve def f(t): r"""Parametric function""" x = t y = t * t + 1 z = 0. return x, y, z a = D.curve(f) C.convertPyTree2File(a, 'out.cgns')
# - selectCells (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Post.PyTree as P import KCore.test as test def F(x, y, z): if (x + 2 * y + z > 20.): return True else: return False # CAS 1D a = G.cart((0, 0, 0), (1, 1, 1), (30, 1, 1)) a = C.addVars(a, 'Density') a = C.addVars(a, 'centers:cellN') a = P.selectCells(a, F, ['CoordinateX', 'CoordinateY', 'CoordinateZ']) test.testT(a, 1) # CAS 2D a = G.cart((0, 0, 0), (1, 1, 1), (11, 11, 1)) a = C.addVars(a, 'Density') a = C.addVars(a, 'centers:cellN') a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin') a = P.selectCells(a, F, ['CoordinateX', 'CoordinateY', 'CoordinateZ']) test.testT(a, 2) # CAS 3D a = G.cart((0, 0, 0), (1, 1, 1), (11, 11, 11)) a = C.addVars(a, 'Density') a = C.addVars(a, 'centers:cellN')
# - surfaceWalk (pyTree) import Converter.PyTree as C import Geom.PyTree as D import Transform.PyTree as T import Generator.PyTree as G # User definition of parametric curve def f(t, u): x = t+u y = t*t+1+u*u z = u return x, y, z # Array definition of geometry a = D.surface(f) c = D.circle((1.2, 1.7, 0.6), 0.1) c = T.rotate(c, (1.2, 1.7, 0.6), (0, 1, 0), 90.) c = T.reorder(c, (-1, 2, 3)) c = T.projectOrtho(c, [a]) h = G.cart((0., 0., 0.), (0.01, 1, 1), (15, 1, 1)) r = G.surfaceWalk([a], c, h, niter=100) C.convertPyTree2File(r, "out.cgns")
# - getState (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import KCore.test as test a = G.cylinder((0,0,0), 1., 1.5, 0., 360., 1., (80,30,2)) t = C.newPyTree(['Base']); t[2][1][2].append(a) # Specifie un etat de reference adimensionne par: # Mach, alpha, Re, MutSMu, TurbRate (adim1) C._addState(t, adim='adim1', MInf=0.5, alphaZ=0., alphaY=0., ReInf=1.e8, MutSMuInf=0.2, TurbRateInf=1.e-8) # Get the ref state state = C.getState(t) test.testO(state, 1)
# - extractBCOfName (pyTree) - import Converter.PyTree as C import Generator.PyTree as G a = G.cylinder((0,0,0), 1., 1.5, 360., 0., 1., (100,30,10)) a = C.addBC2Zone(a, 'wall1', 'BCWall', 'jmin') a = C.addBC2Zone(a, 'walla', 'FamilySpecified:CARTER', 'imin') t = C.newPyTree(['Base',3,'Skin',2]); t[2][1][2] += [a] t[2][1] = C.addFamily2Base(t[2][1], 'CARTER', bndType='BCWall') Z1 = C.extractBCOfName(a, 'wall*') Z2 = C.extractBCOfName(a, 'FamilySpecified:CARTER') C.convertPyTree2File(Z1+Z2, 'out.cgns')