def drawLine(npts): CTK.t = C.addBase2PyTree(CTK.t, 'CONTOURS', 1) nodes = Internal.getNodesFromName1(CTK.t, 'CONTOURS') nob = C.getNobOfBase(nodes[0], CTK.t) CTK.TXT.insert('START', 'Click first point...\n') prev = [] if CTK.__BUSY__ == False: CTK.__BUSY__ = True TTK.sunkButton(WIDGETS['draw']) CPlot.setState(cursor=1) while CTK.__BUSY__: CPlot.unselectAllZones() CTK.saveTree() surfaces = getSurfaces() l = [] while l == []: l = CPlot.getActivePoint() time.sleep(CPlot.__timeStep__) WIDGETS['draw'].update() if CTK.__BUSY__ == False: break if CTK.__BUSY__: if prev == []: prev = l CTK.TXT.insert('START', 'Click second point...\n') elif (prev != l): line = D.line(prev, l, npts) if surfaces != []: line = T.projectOrthoSmooth(line, surfaces) CTK.add(CTK.t, nob, -1, line) CTK.TXT.insert('START', 'Line created.\n') CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['draw']) #C._fillMissingVariables(CTK.t) (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) CTK.TKTREE.updateApp() CPlot.render() CPlot.setState(cursor=0) prev = [] return CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['draw']) CPlot.setState(cursor=0) else: CTK.__BUSY__ = False TTK.raiseButton(WIDGETS['draw']) CPlot.setState(cursor=0) return
# - connectMatch sur meme bloc (pyTree)- import Generator.PyTree as G import Converter.PyTree as C import Connector.PyTree as X import Geom.PyTree as D import Transform.PyTree as T import KCore.test as test a = G.cylinder((0.,0.,0.), 0.5, 1., 360., 0., 10., (50,50,30)) t = C.newPyTree(['Base', a]) t = X.connectMatch(t) test.testT(t,1) # 3D raccord i = 1 partiel profil NACA a = D.naca(12., 5001) a2 = D.line((1.,0.,0.),(2.,0.,0.),5001); a = T.join(a, a2) a2 = D.line((2.,0.,0.),(1.,0.,0.),5001); a = T.join(a2, a) Ni = 300; Nj = 50 distrib = G.cart((0,0,0), (1./(Ni-1), 0.5/(Nj-1),1), (Ni,Nj,1)) naca = G.hyper2D(a, distrib, "C") a = T.addkplane(naca) # --- champ aux centres C._initVars(a, 'centers:Density', 1.) # --- champ aux noeuds C._initVars(a, 'cellN', 2.) t = C.newPyTree(['Base', a]) # --- Equation state t[2][1] = C.addState(t[2][1], 'EquationDimension', 3) t = X.connectMatch(t) test.testT(t,2)
T.testT(vol, 1) # Test 2D structure a = G.cart((0.,0.,0.), (0.1,0.1,0.2), (10,10,1)) a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.) vol = G.getVolumeMap(a) T.testT(vol, 2) # Test 1D structure a = G.cart((0.,0.,0.), (0.1,0.1,0.2), (1,1,10)) a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.) vol = G.getVolumeMap(a) T.testT(vol, 7) # Test 1d non-structure bar a = D.line((0,0,0), (1,0,0),11) a2 = C.convertArray2Tetra(a) a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.) vol = G.getVolumeMap(a) T.testT(vol, 8) # Test 2d non-structure hexa a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (10,10,1)) a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.) vol = G.getVolumeMap(a) T.testT(vol, 3) # Test 3d non-structure hexa a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (10,10,10)) a = C.initVars(a,'Density',1.); a = C.initVars(a,'centers:cellN',1.)
def meshCircle(center, R, N): coeff = R * math.sqrt(2.) * 0.25 x = center[0] y = center[1] z = center[2] c = D.circle(center, R, tetas=-45., tetae=45., N=N) l1 = D.line((x + coeff, y - coeff, z), (x + coeff, y + coeff, z), N=N) l2 = D.line((x + coeff, y - coeff, z), (x + 2 * coeff, y - 2 * coeff, z), N=N) l3 = D.line((x + coeff, y + coeff, z), (x + 2 * coeff, y + 2 * coeff, z), N=N) m1 = G.TFI([c, l1, l2, l3]) c = D.circle(center, R, tetas=45., tetae=45. + 90., N=N) l1 = D.line((x + coeff, y + coeff, z), (x - coeff, y + coeff, z), N=N) l2 = D.line((x + coeff, y + coeff, z), (x + 2 * coeff, y + 2 * coeff, z), N=N) l3 = D.line((x - coeff, y + coeff, z), (x - 2 * coeff, y + 2 * coeff, z), N=N) m2 = G.TFI([c, l1, l2, l3]) c = D.circle(center, R, tetas=45. + 90, tetae=45. + 180., N=N) l1 = D.line((x - coeff, y + coeff, z), (x - coeff, y - coeff, z), N=N) l2 = D.line((x - coeff, y + coeff, z), (x - 2 * coeff, y + 2 * coeff, z), N=N) l3 = D.line((x - coeff, y - coeff, z), (x - 2 * coeff, y - 2 * coeff, z), N=N) m3 = G.TFI([c, l1, l2, l3]) c = D.circle(center, R, tetas=45. + 180, tetae=45. + 270., N=N) l1 = D.line((x - coeff, y - coeff, z), (x + coeff, y - coeff, z), N=N) l2 = D.line((x - coeff, y - coeff, z), (x - 2 * coeff, y - 2 * coeff, z), N=N) l3 = D.line((x + coeff, y - coeff, z), (x + 2 * coeff, y - 2 * coeff, z), N=N) m4 = G.TFI([c, l1, l2, l3]) h = 2 * coeff / (N - 1) m5 = G.cart((x - coeff, y - coeff, z), (h, h, h), (N, N, 1)) m5 = T.reorder(m5, (-1, 2, 3)) return [m1, m2, m3, m4, m5]
def generate(event=None): CTK.saveTree() N = CTK.varsFromWidget(VARS[0].get(), type=2) if len(N) != 1: CTK.TXT.insert('START', 'NPts is incorrect.\n') return N = N[0] eltType = VARS[1].get() surfType = VARS[2].get() if surfType == 'Sphere': s = D.sphere6((0, 0, 0), 0.5, N=N) xc = 0 yc = 0 zc = 0 elif surfType == 'Plane': h = 1. / (N - 1) s1 = G.cart((-0.5, -0.5, -0.5), (h, h, h), (N, 1, N)) s = [s1] xc = 0 yc = 0 zc = 0 elif surfType == 'Cube': h = 1. / (N - 1) s1 = G.cart((-0.5, -0.5, -0.5), (h, h, h), (N, N, 1)) s1 = T.reorder(s1, (-1, 2, 3)) s2 = G.cart((-0.5, -0.5, 0.5), (h, h, h), (N, N, 1)) s3 = G.cart((-0.5, -0.5, -0.5), (h, h, h), (N, 1, N)) s4 = G.cart((-0.5, 0.5, -0.5), (h, h, h), (N, 1, N)) s4 = T.reorder(s4, (-1, 2, 3)) s5 = G.cart((-0.5, -0.5, -0.5), (h, h, h), (1, N, N)) s5 = T.reorder(s5, (1, -2, 3)) s6 = G.cart((0.5, -0.5, -0.5), (h, h, h), (1, N, N)) s = [s1, s2, s3, s4, s5, s6] xc = 0 yc = 0 zc = 0 elif surfType == 'Tetra': m1 = meshTri([0, 0, 0], [1, 0, 0], [0, 1, 0], N=N) m1 = T.reorder(m1, (-1, 2, 3)) m2 = meshTri([0, 0, 0], [1, 0, 0], [0, 0, 1], N=N) m3 = meshTri([0, 0, 0], [0, 1, 0], [0, 0, 1], N=N) m3 = T.reorder(m3, (-1, 2, 3)) m4 = meshTri([1, 0, 0], [0, 1, 0], [0, 0, 1], N=N) s = m1 + m2 + m3 + m4 xc = 0.5 yc = 0.5 zc = 0.5 elif surfType == 'Pyramid': h = 1. / (2 * N - 2) m0 = G.cart((-0.5, -0.5, -0.5), (h, h, h), (2 * N - 1, 2 * N - 1, 1)) m0 = T.reorder(m0, (-1, 2, 3)) m1 = meshTri([-0.5, -0.5, -0.5], [0.5, -0.5, -0.5], [0, 0, 0.5], N=N) m2 = meshTri([-0.5, -0.5, -0.5], [-0.5, 0.5, -0.5], [0, 0, 0.5], N=N) m2 = T.reorder(m2, (-1, 2, 3)) m3 = meshTri([-0.5, 0.5, -0.5], [0.5, 0.5, -0.5], [0, 0, 0.5], N=N) m3 = T.reorder(m3, (-1, 2, 3)) m4 = meshTri([0.5, -0.5, -0.5], [0.5, 0.5, -0.5], [0, 0, 0.5], N=N) s = [m0] + m1 + m2 + m3 + m4 xc = 0. yc = 0. zc = 0. elif surfType == 'Cylinder': m0 = meshCircle((0, 0, -0.5), 0.5, N) m1 = meshCircle((0, 0, 0.5), 0.5, N) m1 = T.reorder(m1, (-1, 2, 3)) m2 = D.circle((0, 0, -0.5), 0.5, tetas=-45, tetae=-45 + 360, N=4 * N - 3) l = D.line((0, 0, -0.5), (0, 0, 0.5), N=N) m2 = D.lineDrive(m2, l) s = m0 + m1 + [m2] xc = 0. yc = 0. zc = 0. elif surfType == 'Cone': s = [D.cone((0., 0, 0), 1, 0.1, 1, N=N)] (xc, yc, zc) = G.barycenter(s) else: # Geom parametrics surfaces formula = base[surfType] if formula.replace('{u}', '') == formula: # curve s = D.curve(base[surfType], N) else: s = D.surface(base[surfType], N) (xc, yc, zc) = G.barycenter(s) s = [s] if eltType == 'TRI': s = C.convertArray2Tetra(s) s = T.join(s) s = G.close(s) elif eltType == 'QUAD': s = C.convertArray2Hexa(s) s = T.join(s) s = G.close(s) posCam = CPlot.getState('posCam') posEye = CPlot.getState('posEye') dirCam = CPlot.getState('dirCam') s = T.translate(s, (posEye[0] - xc, posEye[1] - yc, posEye[2] - zc)) lx = posEye[0] - posCam[0] ly = posEye[1] - posCam[1] lz = posEye[2] - posCam[2] if lx * lx + ly * ly + lz * lz < 1.e-10: lx = -1 if (dirCam[0] * dirCam[0] + dirCam[1] * dirCam[1] + dirCam[2] * dirCam[2] == 0.): dirCam = (0, 0, 1) ll = math.sqrt(lx * lx + ly * ly + lz * lz) s = T.homothety(s, (posEye[0], posEye[1], posEye[2]), 0.5 * ll) ux = dirCam[1] * lz - dirCam[2] * ly uy = dirCam[2] * lx - dirCam[0] * lz uz = dirCam[0] * ly - dirCam[1] * lx s = T.rotate(s, (posEye[0], posEye[1], posEye[2]), ((1, 0, 0), (0, 1, 0), (0, 0, 1)), ((-ux, -uy, -uz), (lx, ly, lz), dirCam)) CTK.t = C.addBase2PyTree(CTK.t, 'SURFACES', 2) b = Internal.getNodeFromName1(CTK.t, 'SURFACES') if eltType == 'TRI' or eltType == 'QUAD': nob = C.getNobOfBase(b, CTK.t) CTK.add(CTK.t, nob, -1, s) else: nob = C.getNobOfBase(b, CTK.t) if CP.__slot__ is None: CTK.t[2][nob][2] += s CTK.display(CTK.t) else: for i in s: CTK.add(CTK.t, nob, -1, i) #C._fillMissingVariables(CTK.t) CTK.TXT.insert('START', 'Surface created.\n') (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) CTK.TKTREE.updateApp() CPlot.render()
# - axisym (pyTree) - import Generator.PyTree as G import Converter.PyTree as C import Geom.PyTree as D # Axisym a curve a0 = D.line((0.5,0,0), (0.6,0,1)) a = D.axisym(a0,(0.,0.,0.),(0.,0.,1.),360.,360) C.convertPyTree2File(a, "out.cgns") # Axisym a curve with varying r a0 = D.line((1.0,0,0), (0.,0,1)) a1 = D.circle((0,0,0), 2.) a = D.axisym(a0, (0.,0.,0.), (0.,0.,1.), rmod=a1) C.convertPyTree2File([a,a0,a1], "out1.cgns") # Axisym a 2D cart grid a = G.cart((0.,0.,0.), (0.1,0.1,0.2),(10,10,1)) a = D.axisym(a,(1.,0.,0.),(0.,1.,0.),30.,4) C.convertPyTree2File(a, 'out2.cgns')
# - addNormalLayers (pyTree) - import Generator.PyTree as G import Converter.PyTree as C import Transform.PyTree as T import Geom.PyTree as D d = G.cart((0.1, 0., 0.), (0.1, 1, 1), (2, 1, 1)) a = D.sphere((0, 0, 0), 1, 50) a = D.line((0, 0, 0), (1, 1, 0), 3) b = G.addNormalLayers(a, d) d = G.cart((0.1, 0., 0.), (-0.1, 1, 1), (2, 1, 1)) c = G.addNormalLayers(a, d) a = T.join(b, c) C.convertPyTree2File(a, 'out.cgns')
# - streamSurf (pyTree) - import Converter.PyTree as C import Post.PyTree as P import Generator.PyTree as G import Geom.PyTree as D import math as M import KCore.test as test ni = 30 nj = 40 nk = 5 m1 = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk)) m1[0] = 'cart1' m2 = G.cart((5.5, 0, 0), (9. / (ni - 1), 9. / (nj - 1), 1), (ni, nj, nk)) m2[0] = 'cart2' b = D.line((0.1, 5., 0.1), (0.1, 5., 3.9), N=5) b = C.convertArray2Tetra(b) def F(x): return M.cos(x) m = [m1, m2] m = C.initVars(m, 'u', 1.) m = C.initVars(m, 'v', F, ['CoordinateX']) m = C.initVars(m, 'w', 0.) m = C.initVars(m, 'centers:G', 1.) m = C.addBC2Zone(m, 'wall', 'BCWall', 'imin') m = C.addBC2Zone(m, 'BCOverlap', 'BCOverlap', 'imax') # 3D struct
# - connect1D (pyTree) - import Geom.PyTree as D import KCore.test as test P1 = [-0.5,0,0]; P1b = [0.5,0,0] P2 = [1,-1.5,0]; P2b = [1,-0.5,0] l1 = D.line(P1,P1b) l2 = D.line(P2,P2b) out = D.connect1D([l1,l2], sharpness=0) test.testT(out)
# - TFI (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Geom.PyTree as D # Geometry P0 = (0, 0, 0) P1 = (5, 0, 0) P2 = (0, 7, 0) P3 = (5, 7, 0) Ni = 20 Nj = 10 d1 = D.line(P0, P1, Ni) d2 = D.line(P2, P3, Ni) d3 = D.line(P0, P2, Nj) d4 = D.line(P1, P3, Nj) m = G.TFI([d1, d2, d3, d4]) C.convertPyTree2File(m, 'out.cgns')
# - lineDrive (pyTree) - import Geom.PyTree as D import Generator.PyTree as G import KCore.test as test import Converter.PyTree as C # 1D structure a = D.naca(12.) b = D.line((0, 0, 0), (0, 0., 1.)) c = D.lineDrive(a, b) t = C.newPyTree(['Base', 2, c]) test.testT(t, 1) # 1D structure + champ noeud a = D.circle((0, 0, 0), 1) a = C.addVars(a, 'var') b = D.line((0, 0, 0), (0, 0, 1)) c = D.lineDrive(a, b) t = C.newPyTree(['Base', 2, c]) test.testT(t, 2) # 2D structure + champ en noeuds + champ en centres a = G.cylinder((0, 0, 0), 1, 2, 360, 0, 1, (50, 21, 1)) a = C.addVars(a, 'var') a = C.addVars(a, 'centers:var2') b = D.line((0, 0, 0), (0, 0., 1.)) c = D.lineDrive(a, b) import Converter.Internal as Internal t = C.newPyTree(['Base', 3, c]) test.testT(t, 3)
# - map (pyTree) - import Geom.PyTree as D import Generator.PyTree as G import Converter.PyTree as C import KCore.test as test l = D.line((0, 0, 0), (1, 1, 0)) l = C.initVars(l, 'Density', 1.) l = C.initVars(l, 'centers:cellN', 1.) Ni = 11 dist = G.cart((0, 0, 0), (1. / (Ni - 1), 1., 1.), (Ni, 1, 1)) l2 = G.map(l, dist) test.testT(l2) # Map on a curve l = D.circle((0, 0, 0), 1., 0., 360., 10) Ni = 100 d = G.cart((0, 0, 0), (1. / (Ni - 1), 1., 1.), (Ni, 1, 1)) l = C.convertArray2Tetra(l) l = C.initVars(l, 'Density', 1.) l = C.initVars(l, 'centers:cellN', 1.) m = G.map(l, d) test.testT(m, 2) # 2D a = G.cart((0, 0, 0), (1, 1, 1), (11, 11, 1)) a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin') a = C.addBC2Zone(a, 'overlap', 'BCOverlap', [11, 11, 1, 5, 1, 1]) a = C.fillEmptyBCWith(a, 'nref', 'BCFarfield', dim=2) Ni = 15 dist = G.cart((0, 0, 0), (1. / (Ni - 1), 1., 1.), (Ni, 1, 1))
# - lineGenerate (pyTree)- import Geom.PyTree as D import Converter.PyTree as C # With one driving curve a = D.naca(12.) l = D.line((0, 0, 0), (0, 0., 1.)) a = D.lineGenerate(a, l) C.convertPyTree2File(a, 'out.cgns') # With a set of driving curves a = D.naca(12.) d1 = D.line((0, 0, 0), (0., 0., 1.)) d2 = D.line((1, 0, 0), (2, 0, 1)) a = D.lineGenerate(a, [d1, d2]) C.convertPyTree2File(a, 'out.cgns')
# - addSeparationLine (pyTree)- import Geom.PyTree as D import Converter.PyTree as C a1 = D.circle((0, 0, 0), 1, 0., 360, 1000) a2 = D.line((0., 1., 0.), (0., 2., 0), 100) zones = D.addSeparationLine(a1, a2) C.convertPyTree2File(zones, 'out.cgns')
# - getLength (pyTree)- import Geom.PyTree as D import Converter.PyTree as C import KCore.test as test # test getLength structure a = D.line((0, 0, 0), (1, 0, 0)) l = D.getLength(a) test.testO(l, l) # test getLength BAR a2 = C.convertArray2Tetra(a) l = D.getLength(a2) test.testO(l, 2) # test getLength par lots structure b = D.line((10, 0, 0), (1, 0, 0)) l = D.getLength([a, b]) test.testO(l, 3) # test getLength par lots non structure b2 = C.convertArray2Tetra(b) l = D.getLength([a2, b2]) test.testO(l, 4) # test getLength par lots mixte l = D.getLength([a, b2]) test.testO(l, 5)
def drawRectangle(npts): CTK.t = C.addBase2PyTree(CTK.t, 'CONTOURS', 1) nodes = Internal.getNodesFromName1(CTK.t, 'CONTOURS') nob = C.getNobOfBase(nodes[0], CTK.t) CTK.TXT.insert('START', 'Click left/lower corner...\n') w = WIDGETS['draw'] prev = []; second = [] if (CTK.__BUSY__ == False): CTK.__BUSY__ = True TTK.sunkButton(w) CPlot.setState(cursor=1) while (CTK.__BUSY__ == True): CPlot.unselectAllZones() CTK.saveTree() surfaces = getSurfaces() l = [] while (l == []): l = CPlot.getActivePoint() time.sleep(CPlot.__timeStep__) w.update() if (CTK.__BUSY__ == False): break if (CTK.__BUSY__ == True): if (prev == []): prev = l CTK.TXT.insert('START', 'Click right/up corner...\n') elif (prev != l): e1,e2 = getVectorsFromCanvas() e1n = Vector.norm(e1) e2n = Vector.norm(e2) if (e2n > e1n): e1 = e2 P1 = l; P2 = prev P1P2 = Vector.sub(P2, P1) P1P2n = Vector.norm(P1P2) Q = Vector.norm(Vector.cross(e1, P1P2)) L = math.sqrt( P1P2n*P1P2n - Q*Q ) sign = Vector.dot(e1, P1P2) if (sign > 0): e1 = Vector.mul(L, e1) else: e1 = Vector.mul(-L, e1) P3 = Vector.add(P1, e1) P4 = Vector.sub(P2, e1) l1 = D.line(P1, P3, npts) l2 = D.line(P3, P2, npts) l3 = D.line(P2, P4, npts) l4 = D.line(P4, P1, npts) rect = T.join([l1,l2,l3,l4]) if (surfaces != []): rect = T.projectOrthoSmooth(rect, surfaces) CTK.add(CTK.t, nob, -1, rect) CTK.TXT.insert('START', 'Rectangle created.\n') CTK.__BUSY__ = False TTK.raiseButton(w) CPlot.setState(cursor=0) #C._fillMissingVariables(CTK.t) (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) CTK.TKTREE.updateApp() CPlot.render() CPlot.setState(cursor=0) prev = [] return CTK.__BUSY__ = False TTK.raiseButton(w) CPlot.setState(cursor=0) else: CTK.__BUSY__ = False TTK.raiseButton(w) CPlot.setState(cursor=0)
# - join (pyTree) - import Geom.PyTree as D import Transform.PyTree as T import Converter.PyTree as C a1 = D.naca(12., 5001) a2 = D.line((1., 0., 0.), (20., 0., 0.), 5001) a = T.join(a1, a2) C.convertPyTree2File(a, "out.cgns")
# - convertHO2LO (pyTree) - import Converter.PyTree as C import Geom.PyTree as D import Generator.PyTree as G import Transform.PyTree as T import KCore.test as test # BAR -> BAR_3 a = D.line((0,0,0), (1,0,0), N=3) a = C.convertArray2Hexa(a) a = C.convertLO2HO(a, 0) a = C.convertHO2LO(a, 0) test.testT(a, 1) # TRI -> TRI_6 a = D.triangle((0,0,0), (1,0,0), (1,1,0)) a = C.convertLO2HO(a, 0) a = C.convertHO2LO(a, 0) test.testT(a, 2) # QUAD -> QUAD_8 a = D.quadrangle((0,0,0), (1,0,0), (1,1,0), (0,1,0)) a = C.convertLO2HO(a, 0) a = C.convertHO2LO(a, 0) test.testT(a, 3) # QUAD -> QUAD_9 a = D.quadrangle((0,0,0), (1,0,0), (1,1,0), (0,1,0)) a = C.convertLO2HO(a, 1) a = C.convertHO2LO(a, 0) test.testT(a, 4)
# - TTM (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Geom.PyTree as D P0 = (0, 0, 0) P1 = (5, 0, 0) P2 = (0, 7, 0) P3 = (5, 7, 0) # Geometry d1 = D.line(P0, P1) d2 = D.line(P2, P3) d3 = D.line(P0, P2) d4 = D.line(P1, P3) # Regular discretisation of each line Ni = 20 Nj = 10 r = G.cart((0, 0, 0), (1. / (Ni - 1), 1, 1), (Ni, 1, 1)) q = G.cart((0, 0, 0), (1. / (Nj - 1), 1, 1), (Nj, 1, 1)) r1 = G.map(d1, r) r2 = G.map(d2, r) r3 = G.map(d3, q) r4 = G.map(d4, q) # TTM m = G.TFI([r1, r2, r3, r4]) m = G.TTM(m) t = C.newPyTree(['Base', 2]) t[2][1][2].append(m)
import Geom.PyTree as D import Transform.PyTree as T import KCore.test as test a = G.cylinder((0., 0., 0.), 0.5, 1., 360., 0., 10., (50, 51, 30)) a1 = T.subzone(a, (1, 1, 1), (25, 51, 30)) a2 = T.subzone(a, (25, 1, 1), (50, 51, 30)) a2 = T.oneovern(a2, (1, 2, 1)) t = C.newPyTree(['Base']) t[2][1][2] += [a1, a2] t = X.connectNearMatch(t) test.testT(t, 1) # 3D raccord i = 1 partiel profil NACA a = D.naca(12., 5001) a2 = D.line((1., 0., 0.), (2., 0., 0.), 5001) a = T.join(a, a2) a2 = D.line((2., 0., 0.), (1., 0., 0.), 5001) a = T.join(a2, a) Ni = 301 Nj = 51 distrib = G.cart((0, 0, 0), (1. / (Ni - 1), 0.5 / (Nj - 1), 1), (Ni, Nj, 1)) naca = G.hyper2D(a, distrib, "C") a = T.addkplane(naca) a1 = T.subzone(a, (1, 1, 1), (151, Nj, 2)) a2 = T.subzone(a, (151, 1, 1), (Ni, Nj, 2)) a2 = T.oneovern(a2, (2, 2, 1)) t = C.newPyTree(['Base']) t[2][1][2] += [a1, a2] # --- Equation state t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
# - TFIMono (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Geom.PyTree as D a1 = D.circle((0,0,0), 1., tetas=0, tetae=180., N=41) a2 = D.line((-1,0,0),(1,0,0), N=21) r = G.TFIMono(a1, a2) C.convertPyTree2File(r, 'out.cgns')
vector = [1., 0., 0.] # 2D a1 = G.cylinder((0., 0., 0.), 0.5, 1., 360., 0., 10., (50, 1, 30)) a1 = C.addBC2Zone(a1, 'wall', 'BCWall', 'jmin') a1 = C.addBC2Zone(a1, 'overlap', 'BCOverlap', 'jmax') a2 = T.rotate(a1, (0., 0., 0.), (0., 1., 0.), 120.) a2[0] = 'cart2' A = [a1, a2] A = C.initVars(A, 'P', 1.) A = C.initVars(A, 'centers:Q', 2.) res = P.silhouette(A, vector) test.testT(res, 2) # BAR l1 = D.line((0., 0., 0.), (1., 0., 0.)) l2 = D.line((0., 0., 0.), (0., 1., 0.)) A = C.convertArray2Tetra([l1, l2]) A = C.initVars(A, 'P', 1.) A = C.initVars(A, 'centers:Q', 2.) res = P.silhouette(A, vector) test.testT(res, 3) # TRI A = C.convertArray2Tetra([a1]) A = C.initVars(A, 'P', 1.) A = C.initVars(A, 'centers:Q', 2.) res = P.silhouette(A, vector) test.testT(res, 4) # QUAD
# - TTM (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Geom.PyTree as D import KCore.test as test P0 = (0, 0, 1) P1 = (5, 0, 1) P2 = (0, 7, 1) P3 = (5, 7, 1) # Geometrie d1 = D.line(P0, P1) d2 = D.line(P2, P3) P0 = (0, 0, 1) P1 = (-2, 2, 1) P2 = (-3, 3, 1) P3 = (2, 5, 1) P4 = (0, 7, 1) pts = D.polyline([P0, P1, P2, P3, P4]) b1 = D.bezier(pts) P0 = (5, 0, 1) P1 = (3, 2, 1) P2 = (2, 3, 1) P3 = (6, 5, 1) P4 = (5, 7, 1) pts = D.polyline([P0, P1, P2, P3, P4]) b2 = D.bezier(pts)
a1 = G.cart((13., 0., 0.), (1., 1., 1), (11, 11, 1)) a1 = C.addBC2Zone(a1, 'wall', 'BCWall', 'imin') a1 = C.addBC2Zone(a1, 'ov', 'BCOverlap', 'imax') a1 = C.addBC2Zone(a1, 'match1', 'BCMatch', 'jmin', a1, 'jmax') a2 = G.cartHexa((9., 0., 0.), (1., 1., 1), (10, 10, 1)) a1 = C.initVars(a1, 'F', 2) a1 = C.initVars(a1, 'centers:G', 1) a2 = C.initVars(a2, 'F', 3) a2 = C.initVars(a2, 'centers:G', 3) t = C.newPyTree(['Base', 2]) a = T.join(a1, a2) t[2][1][2].append(a) test.testT(t, 4) # Join 2 STRUCT-1D a1 = D.line((0., 0., 0.), (1., 0., 0), 100) a2 = D.line((1., 0., 0.), (1., 1, 0), 100) a1 = C.addBC2Zone(a1, 'wall', 'BCWall', 'imin') a1 = C.addBC2Zone(a1, 'ov', 'BCOverlap', 'imax') a1 = C.initVars(a1, 'F', 2) a1 = C.initVars(a1, 'centers:G', 1) a2 = C.initVars(a2, 'F', 3) a2 = C.initVars(a2, 'centers:G', 3) t = C.newPyTree(['Base', 2]) a = T.join(a1, a2) t[2][1][2].append(a) test.testT(t, 5) # Join 2 BARS a1 = D.line((0., 0., 0.), (1., 0., 0), 100) a2 = D.line((1., 0., 0.), (1., 1, 0), 100)
def meshTri(P0, P1, P2, N): C01 = (0.5 * (P0[0] + P1[0]), 0.5 * (P0[1] + P1[1]), 0.5 * (P0[2] + P1[2])) C12 = (0.5 * (P1[0] + P2[0]), 0.5 * (P1[1] + P2[1]), 0.5 * (P1[2] + P2[2])) C02 = (0.5 * (P0[0] + P2[0]), 0.5 * (P0[1] + P2[1]), 0.5 * (P0[2] + P2[2])) C = (1. / 3. * (P0[0] + P1[0] + P2[0]), 1. / 3. * (P0[1] + P1[1] + P2[1]), 1. / 3. * (P0[2] + P1[2] + P2[2])) l1 = D.line(P0, C01, N) l2 = D.line(C01, C, N) l3 = D.line(C, C02, N) l4 = D.line(C02, P0, N) m1 = G.TFI([l1, l2, l3, l4]) m1 = T.reorder(m1, (-1, 2, 3)) l1 = D.line(C01, P1, N) l2 = D.line(P1, C12, N) l3 = D.line(C12, C, N) l4 = D.line(C, C01, N) m2 = G.TFI([l1, l2, l3, l4]) m2 = T.reorder(m2, (-1, 2, 3)) l1 = D.line(C, C12, N) l2 = D.line(C12, P2, N) l3 = D.line(P2, C02, N) l4 = D.line(C02, C, N) m3 = G.TFI([l1, l2, l3, l4]) m3 = T.reorder(m3, (-1, 2, 3)) return [m1, m2, m3]
# - refine (pyTree) - import Geom.PyTree as D import Transform.PyTree as T import Converter.PyTree as C a = D.line((0,0,0), (1,0,0), N=10) b = D.line((1,0,0), (2,1,0), N=30) a = T.join([a,b]) a = D.refine(a, N=30) C.convertPyTree2File(a, 'out.cgns')
# - getDistantIndex (pyTree)- import Geom.PyTree as D a = D.line((0., 0., 0.), (1., 0., 0), 100) print 'distant Index:', D.getDistantIndex(a, 25, 0.2)
# - enforceLine (pyTree)- import Generator.PyTree as G import Converter.PyTree as C import Geom.PyTree as D Ni = 50; Nj = 50 a = G.cart((0,0,0), (1./(Ni-1), 0.5/(Nj-1),1), (Ni,Nj,1)) b = D.line((0.,0.2,0.), (1.,0.2,0.), 20) a = G.enforceLine(a, b, 0.01, (5,3)) C.convertPyTree2File(a, 'out.cgns')
# - TFITri (pyTree) import Converter.PyTree as C import Generator.PyTree as G import Geom.PyTree as D P0 = (0,0,0); P1 = (5,0,0); P2 = (1,7,0) # 3 curves (dont need to be lines) d1 = D.line(P0, P1, N=11) d2 = D.line(P1, P2, N=11) d3 = D.line(P0, P2, N=11) r = G.TFITri(d1, d2, d3) C.convertPyTree2File(r, 'out.cgns')
# - splitCurvatureAngle (pyTree) - import Converter.PyTree as C import Geom.PyTree as D import Transform.PyTree as T a = D.naca(12,101) a2 = D.line((1,0,0), (2,0,0), 50) a = T.join(a, a2) a2 = D.line((2,0,0), (1,0,0), 50) a = T.join(a, a2) zones = T.splitCurvatureAngle(a, 20.) C.convertPyTree2File(zones+[a], 'out.cgns')