Example #1
0
# - reorderAll (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Transform.PyTree as T

ni = 30
nj = 40
nk = 1
m1 = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
m1[0] = 'cart1'
m2 = T.rotate(m1, (0.2, 0.2, 0.), (0., 0., 1.), 15.)
m2 = T.reorder(m2, (-1, 2, 3))
m2[0] = 'cart2'
t = C.newPyTree(['Base', 2])
t[2][1][2] += [m1, m2]
t = T.reorderAll(t, 1)
C.convertPyTree2File(t, "out.cgns")
Example #2
0
# - 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')
Example #3
0
# - 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')
Example #4
0
# - 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")