예제 #1
0
# - BB (pyTree) -
import Generator.PyTree as G
import Transform.PyTree as T
import Post.PyTree as P
import KCore.test as test

# Rotated box
box = G.cartTetra((0, 0, 0), (1., 1., 1.), (2, 2, 2))
box = P.exteriorFaces(box)
box = T.rotate(box, (0, 0, 0), (1, 0, 0), +50.)  # Rotation X
box = T.rotate(box, (0, 0, 0), (0, 1, 0), -20.)  # Rotation Y
box = T.rotate(box, (0, 0, 0), (0, 0, 1), 30.)  # Rotation Z
OBB = G.BB(box, method='OBB', weighting=1)
test.testT(OBB, 1)

# Aligned box
box = G.cartTetra((0, 0, 0), (1., 1., 1.), (2, 2, 2))
box = P.exteriorFaces(box)
OBB = G.BB(box, method='OBB', weighting=1)
test.testT(OBB, 2)
예제 #2
0
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2, 3])
a = T.contract(a, (0., 0., 0.), (1, 0, 0), (0, 1, 0), 0.1)
test.testT(a, 1)

# Structure 2D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 1))
C._addVars(a, 'Density')
C._initVars(a, 'centers:cellN', 1)
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'overlap', 'BCOverlap', 'jmin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'imax', a, 'imin', [1, 2])
a = T.contract(a, (0., 0., 0.), (1, 0, 0), (0, 1, 0), 0.1)
test.testT(a, 2)

# TETRA
a = G.cartTetra((0, 0, 0), (1, 1, 1), (10, 10, 3))
C._addVars(a, 'Density')
C._initVars(a, 'centers:cellN', 1)
a = T.contract(a, (0., 0., 0.), (1, 0, 0), (0, 1, 0), 0.1)
test.testT(a, 3)

# HEXA
a = G.cartHexa((0, 0, 0), (1, 1, 1), (10, 10, 3))
C._addVars(a, 'Density')
C._initVars(a, 'centers:cellN', 1)
a = T.contract(a, (0., 0., 0.), (1, 0, 0), (0, 1, 0), 0.1)
test.testT(a, 4)

# TRI
a = G.cartTetra((0, 0, 0), (1, 1, 1), (10, 10, 1))
C._addVars(a, 'Density')
# - mergeConnectivity (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.Internal as Internal
import KCore.test as test

a = G.cartHexa((0, 0, 0), (1, 1, 1), (10, 10, 10))
b = G.cartHexa((0, 0, 0), (1, 1, 1), (10, 10, 1))

# merge boundary connectivity
c = C.mergeConnectivity(a, b, boundary=1)
test.testT(c, 1)

# merge element connectivity
b = G.cartTetra((0, 0, 9), (1, 1, 1), (10, 10, 10))
c = C.mergeConnectivity(a, b, boundary=0)
test.testO(c, 2)
예제 #4
0
#!/usr/bin/python
# coding: utf-8
r"""cartTetra (pyTree)

Create an unstructured tetrahedral mesh defined from a Cartesian grid 
of ni x nj x nk points starting from point (xo,yo,zo) and of step (hi,hj,hk).
Type of elements are ‘TRI’ for 2D arrays and ‘TETRA’ for 3D arrays.
Parameters:
    (xo,yo,zo) (3-tuple of floats) – coordinates of the starting point
    (hi,hj,hk) (3-tuple of floats) – values of advancing step in the three directions
    (ni,nj,nk) (3-tuple of integers) – number of points in each direction

Returns:a 1D, 2D or 3D unstructured mesh
Return type:array or pyTree zone

"""
import Generator.PyTree as G
import Converter.PyTree as C
import CPlot.PyTree

a = G.cartTetra((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 3))
C.convertPyTree2File(a, 'out.cgns')
CPlot.PyTree.display(a, displayBB=0, mode='mesh', meshStyle=1)
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.)
vol = G.getVolumeMap(a)
T.testT(vol, 4)

# Test 2d non-structure tetra
a = G.cartTetra((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, 5)

# Test 3d non-structure tetra
a = G.cartTetra((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.)
vol = G.getVolumeMap(a)
T.testT(vol, 6)
예제 #6
0
# - setInterpData (pyTree) - 
# case without cellN field: the whole receiver zone is interpolated
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

# Tetra donor zone
a = G.cartTetra((0,0,-0.2),(0.01,0.01,0.1),(101,101,5))
pts = D.circle((0.5,0.5,0),0.05,N=20)
C._initVars(pts, 'cellN', 2); C._initVars(pts, 'centers:cellN',2) 
# options to combine
notest = 1
for location in ['nodes', 'centers']:
    for stk in ['direct', 'indirect']:
        for pen in [0,1]:
            for nat in [0,1]:
                for order in [2,3,5]:
                    pts2 = X.setInterpData(pts, a, order=order, penalty=pen,
                                           nature=nat, loc=location, 
                                           storage=stk, hook=None)
                    test.testT(pts2, notest)
                    notest += 1
예제 #7
0
# - setValue (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G

# Structured array
Ni = 40
Nj = 50
Nk = 20
a = G.cart((0, 0, 0), (1. / (Ni - 1), 0.5 / (Nj - 1), 1. / (Nk - 1)),
           (Ni, Nj, Nk))
C.setValue(a, 'CoordinateX', (10, 1, 1), 0.25)
C.setValue(a, 'GridCoordinates', (11, 1, 1), [0.3, 0.2, 0.1])
print a

# Unstructured array
Ni = 40
Nj = 50
Nk = 20
a = G.cartTetra((0, 0, 0), (1. / (Ni - 1), 0.5 / (Nj - 1), 1. / (Nk - 1)),
                (Ni, Nj, Nk))
C.setValue(a, 'CoordinateX', 9, 0.1)
print a
예제 #8
0
import Converter.PyTree as C
import KCore.test as test
import Generator.PyTree as G

# Compute L0 norm on structured mesh for a variable F(at nodes) and G(at centers), with celln
a = G.cart((0, 0, 0), (1, 1, 1), (11, 11, 11))
a = C.initVars(a, "F", 1.)
a = C.initVars(a, "centers:G", 1.)
a = C.initVars(a, "centers:cellN", 1.)
norm = C.normL0(a, "F")
test.testO(norm, 1)
norm = C.normL2(a, "centers:G")
test.testO(norm, 11)

# Compute L0 norm on unstructured mesh for a variable F(at nodes) and G(at centers), with celln
a = G.cartTetra((0, 0, 0), (0.1, 0.1, 0.1), (10, 10, 10))
a = C.initVars(a, "F", 1.)
a = C.initVars(a, "centers:G", 1.)
a = C.initVars(a, "centers:cellN", 1.)
norm = C.normL0(a, "F")
test.testO(norm, 2)
norm = C.normL2(a, "centers:G")
test.testO(norm, 21)

# On lists
a1 = G.cart((0, 0, 0), (1, 1, 1), (11, 11, 11))
a2 = G.cart((0, 0, 0), (1, 1, 1), (11, 11, 11))
l = [a1, a2]
l[0] = C.initVars(l[0], "F", 1.)
l[1] = C.initVars(l[1], "F", 1.2)
norm = C.normL0(l, "F")
예제 #9
0
a = C.initVars(a, 'F', 1.)
res = T.dual(a)
t = C.newPyTree(['Base'])
t[2][1][2] += [res]
test.testT(t, 2)

# NGON 3D
a = G.cartHexa((0, 0, 0), (1, 1, 1), (11, 11, 11))
a = C.convertArray2NGon(a)
a = G.close(a)
res = T.dual(a)
t = C.newPyTree(['Base'])
t[2][1][2] += [res]
test.testT(t, 3)

a = G.cartTetra((0, 0, 0), (1, 1, 1), (11, 11, 11))
a = C.convertArray2NGon(a)
a = G.close(a)
res = T.dual(a)
t = C.newPyTree(['Base'])
t[2][1][2] += [res]
test.testT(t, 4)

a = D.sphere((0, 0, 0), 1., 15)
a = C.convertArray2Tetra(a)
a = G.close(a)
distrib = G.cart((0, 0, 0), (0.1, 0, 0), (11, 1, 1))
a = G.addNormalLayers(a, distrib)
a = C.convertArray2NGon(a)
a = G.close(a)
a = C.initVars(a, 'F', 1.)
예제 #10
0
import Transform.PyTree as T
import KCore.test as test

# test sur une zone
ni = 21
nj = 21
nk = 1
hi = 2. / (ni - 1)
hj = 2. / (nj - 1)
m = G.cart((0., 0., 0.), (hi, hj, 1.), (ni, nj, nk))
m = T.perturbate(m, 0.51)
tri = G.delaunay(m)
tri = C.initVars(tri, 'centers:indic', 1.)
tri = C.initVars(tri, 'G', 2.)
sol = P.refine(tri, 'indic')
test.testT(sol, 1)

# test sur une base
m = G.cartTetra((2, 2, 2), (0.1, 0.1, 0.1), (10, 5, 1))
m = C.initVars(m, 'centers:indic', 1)
m = C.initVars(m, 'G', 0)
t = C.newPyTree(['Base', 2])
t[2][1][2] += [m, tri]
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
sol = P.refine(t[2][1], 'indic')
test.testT(sol, 2)

# test sur un arbre
t2 = P.refine(t, 'indic')
test.testT(t2, 3)
예제 #11
0
# - cartTetra (pyTree) -
import Generator.PyTree as G
import KCore.test as test

# BAR
a = G.cartTetra((0., 0., 0.), (0.1, 0.1, 0.2), (10, 1, 1))
test.testT(a, 1)
# TRI
a = G.cartTetra((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 1))
test.testT(a, 2)
# TETRA
a = G.cartTetra((0., 0., 0.), (1., 1., 1.), (2, 2, 2))
test.testT(a, 3)
test.writeCoverage(100)
예제 #12
0
import Generator.PyTree as G
import KCore.test as test

# STRUCT
z = G.cart((0., 0., 0.), (1., 1., 1.), (10, 10, 10))
res = C.getFields('GridCoordinates', z)
test.testA(res, 1)
z = C.initVars(z, 'F=1')
z = C.initVars(z, 'centers:G=2')
res = C.getFields('FlowSolution', z)
test.testA(res, 2)
res = C.getFields('FlowSolution#Centers', z)
test.testA(res, 3)

# BE
z = G.cartTetra((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, 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)
# - exteriorFaces (pyTree)-
import Converter.PyTree as C
import Post.PyTree as P
import Generator.PyTree as G

a = G.cartTetra((0,0,0), (1,1,1), (4,4,6))
b = P.exteriorFaces(a)
C.convertPyTree2File(b, 'out.cgns')
# - collapse (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Transform.PyTree as T
import KCore.test as test

hi = 0.1
hj = 0.01
hk = 1.
ni = 20
nj = 2
nk = 1
a = G.cartTetra((0., 0., 0.), (hi, hj, hk), (ni, nj, nk))
#a = C.initVars(a, 'F', 2.); #a = C.initVars(a, 'centers:G', 1.)
b = T.collapse(a)
t = C.newPyTree(['BAR', 1])
t[2][1][2].append(b)
test.testT(t, 1)

a = G.cartTetra((0., 0., 0.), (hi, hj, hk), (ni, nj, nk))
T._collapse(a)
test.testT(t, 2)
예제 #15
0
# - exteriorFaces (pyTree) -
import Converter.PyTree as C
import Post.PyTree as P
import Generator.PyTree as G
import KCore.test as test

# test faces exterieures au sens large
# faces ayant 2 voisins
a = G.cartTetra((0, 0, 0), (1, 1., 1), (20, 2, 1))
a = C.addVars(a, 'Density')
a = C.addVars(a, 'centers:cellN')
t = C.newPyTree(['Base', 1])
t[2][1][2].append(a)
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
t = P.exteriorFaces(t)
test.testT(t, 1)

# test faces interieures au sens strict :
# faces n'ayant que des noeuds exterieurs
a = G.cartTetra((0, 0, 0), (1, 1., 1), (20, 2, 1))
a = C.addVars(a, 'Density')
a = C.addVars(a, 'centers:cellN')
t = C.newPyTree(['Base', 1])
t[2][1][2].append(a)
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
t = P.exteriorFaces(t)
test.testT(t, 2)

# cas 3D
a = G.cart((0, 0, 0), (1, 1, 1), (4, 4, 6))
a = C.addVars(a, 'Density')
예제 #16
0
# sur une zone structuree
a = D.sphere((0, 0, 0), 1., 20)
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'jmin', a, 'jmax', [1, 2])
b = G.cart((-0.5, -0.5, -0.5), (0.05, 0.05, 0.1), (20, 20, 1))
b = C.addVars(b, 'F')
b = C.addVars(b, 'centers:G')
c = T.projectOrtho(b, a)
test.testT(c, 1)

# sur une zone non structuree
a = D.sphere((0, 0, 0), 1., 20)
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'jmin', a, 'jmax', [1, 2])
b = G.cartTetra((-0.5, -0.5, -0.5), (0.05, 0.05, 0.1), (20, 20, 1))
b = C.initVars(b, 'F', 2.)
b = C.addVars(b, 'centers:G')
c = T.projectOrtho(b, a)
test.testT(c, 2)

# NS sur une zone non structuree
a = D.sphere((0, 0, 0), 1., 20)
a = C.convertArray2Tetra(a)
b = G.cartTetra((-0.5, -0.5, -0.5), (0.05, 0.05, 0.1), (20, 20, 1))
b = C.initVars(b, 'F', 2.)
b = C.addVars(b, 'centers:G')
c = T.projectOrtho(b, a)
t = C.newPyTree(['Base'])
t[2][1][2] += [a, b, c]
test.testT(c, 3)
예제 #17
0
# - join (pyTree) -
import Transform.PyTree as T
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

# Join 2 NGON avec TETRA : 2 zones
a1 = G.cartTetra((0., 0., 0.), (1., 1., 1), (11, 11, 10))
a1 = C.convertArray2NGon(a1)
a1 = C.initVars(a1, 'F', 2.)
a1 = C.initVars(a1, 'centers:G', 1)
a2 = G.cartTetra((10., 0., 0.), (1., 1., 1), (10, 10, 10))
a2 = C.convertArray2NGon(a2)
a2 = C.initVars(a2, 'F', 3.)
a2 = C.initVars(a2, 'centers:G', 3)
a = T.join(a1, a2)
t = C.newPyTree(['Base'])
t[2][1][2].append(a)
test.testT(t, 1)
#
# Join sur une liste de zones
#
t = C.newPyTree(['Base'])
t[2][1][2].append(a1)
t[2][1][2].append(a2)
t[2][1][2].append(T.join(t[2][1][2]))
test.testT(t, 2)
#
# Join sur un arbre
#
t = C.newPyTree(['Base'])
b = G.cart((1.1, -0.1, -0.1), (0.1, 0.1, 0.1), (1, 5, 5))
b = G.getNormalMap(b)
b = C.center2Node(b, ['centers:sx', 'centers:sy', 'centers:sz'])
c = T.projectAllDirs(b, a, ['sx', 'sy', 'sz'])
c[0] = 'projection'
t = C.newPyTree(['Base', 2])
t[2][1][2].append(c)
test.testT(t, 1)

# Non structure sur structure
a = D.sphere((0, 0, 0), 1., 20)
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'jmin', a, 'jmax', [1, 2])
a = C.addVars(a, 'F')
a = C.addVars(a, 'centers:G')
b = G.cartTetra((1.1, -0.1, -0.1), (0.1, 0.1, 0.1), (1, 5, 5))
b = G.getNormalMap(b)
b = C.center2Node(b, ['centers:sx', 'centers:sy', 'centers:sz'])
c = T.projectAllDirs(b, a, ['sx', 'sy', 'sz'])
c[0] = 'projection'
t = C.newPyTree(['Base', 2])
t[2][1][2].append(c)
test.testT(t, 2)

# Structure sur NS
a = D.sphere((0, 0, 0), 1., 20)
a = C.convertArray2Tetra(a)
b = G.cart((1.1, -0.1, -0.1), (0.1, 0.1, 0.1), (1, 5, 5))
b = C.initVars(b, 'F', 2.)
b = C.initVars(b, 'centers:G', 1.)
b = G.getNormalMap(b)
예제 #19
0
# - isoLine (pyTree) -
import Post.PyTree as P
import Converter.PyTree as C
import Generator.PyTree as G
import Geom.PyTree as D
import KCore.test as test


def F(x, y):
    return x * x + y * y


# Test sur un champ en noeuds
a = G.cartTetra((0, 0, 0), (1, 1, 1), (10, 10, 1))
a = C.initVars(a, 'field', F, ['CoordinateX', 'CoordinateY'])
iso = P.isoLine(a, 'field', 15.)
test.testT(iso, 1)

# Test sur un champ en centres
b = G.cartTetra((0, 0, 0), (1, 1, 1), (10, 10, 1))
b = C.node2Center(b, ['CoordinateX', 'CoordinateY'])
b = C.initVars(b, 'centers:field', F,
               ['centers:CoordinateX', 'centers:CoordinateY'])
b = C.rmVars(b, ['centers:CoordinateX', 'centers:CoordinateY'])
iso = P.isoLine(b, 'centers:field', 15.)
t = C.newPyTree(['Base'])
t[2][1][2] += [b, iso]
#test.testA(iso, 2)
예제 #20
0
# - 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')
# - breakConnectivity (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

a = G.cartHexa((0, 0, 0), (1, 1, 1), (10, 10, 10))
b = G.cartTetra((9, 0, 0), (1, 1, 1), (10, 10, 10))
c = C.mergeConnectivity(a, b, boundary=0)

t = C.newPyTree(['Base', c])
t = C.breakConnectivity(t)
test.testT(t, 1)
a = G.cart((0,0,0), (1,1,1), (10,1,1))
b = P.exteriorFaces(a)
test.testT(b,1)

# 2D array
a = G.cart((0,0,0), (1,1,1), (10,6,1))
b = P.exteriorFaces(a)
test.testT(b,2)

# 3D array
a = G.cart((0,0,0), (1,1,1), (4,4,6))
b = P.exteriorFaces(a)
test.testT(b,3)

# TRI
a = G.cartTetra((0,0,0), (1,1,1), (20,3,1))
b = P.exteriorFaces(a)
test.testT(b,4)

# QUAD
a = G.cartHexa((0,0,0), (1,1,1), (20,3,1))
b = P.exteriorFaces(a)
test.testT(b,5)

# TETRA
a = G.cartTetra((0,0,0), (1,1,1), (3,3,3))
b = P.exteriorFaces(a)
test.testT(b,6)

# HEXA
a = G.cartHexa((0,0,0), (1,1,1), (3,3,3))
예제 #23
0
m = C.initVars(m, 'centers:vy', 1.)
m = C.initVars(m, 'ratio', 1.)
m = C.addBC2Zone(m, 'overlap', 'BCOverlap', 'imin')
m = C.initVars(m, 'vx', 1.)
m = C.initVars(m, 'centers:vy', 1.)
m = C.initVars(m, 'ratio', 1.)
t = C.newPyTree(['Base', 1])
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
t[2][1][2].append(m)
res = P.integ(t, 'vx') + P.integ(t, 'centers:vy')
test.testO(res, 2)

# TRI
ni = 30
nj = 40
m = G.cartTetra((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, 1))
m = C.initVars(m, 'vx', 1.)
m = C.initVars(m, 'centers:vy', 1.)
m = C.initVars(m, 'ratio', 1.)
t = C.newPyTree(['Base', 2])
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
t[2][1][2].append(m)
res = P.integ(t, 'vx') + P.integ(t, 'centers:vy')
test.testO(res, 3)

# BAR
ni = 30
m = G.cart((0, 0, 0), (10. / (ni - 1), 1, 1), (ni, 1, 1))
m = C.convertArray2Tetra(m)
m = C.initVars(m, 'vx', 1.)
m = C.initVars(m, 'centers:vy', 1.)
예제 #24
0
# reorder a Cartesian structured mesh
a = G.cart((0, 0, 0), (1, 1, 1), (8, 9, 20))
C._initVars(a, '{Density}={CoordinateX}**2+2*{CoordinateY}')
C._initVars(a, 'centers:cellN', 1.)
C._initVars(a, '{Density}={CoordinateX}**2+2*{CoordinateY}')
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imax')
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmax')
t = C.newPyTree(['Base'])
t[2][1][2].append(a)
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
t = T.reorder(t, (2, 1, -3))
test.testT(t, 1)

# reorder a TRI mesh
a = G.cartTetra((0, 0, 0), (1, 1, 1), (8, 9, 1))
C._initVars(a, '{Density}={CoordinateX}**2+2*{CoordinateY}')
#C._initVars(a,'centers:cellN',1.)
t = C.newPyTree(['Base', 2, a])
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t = T.reorder(t, (-1, ))
test.testT(t, 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:cellN', 1.)
t = C.newPyTree(['Base', 2, a])
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t = T.reorder(t, (-1, ))
test.testT(t, 3)
예제 #25
0
# - isoSurf (pyTree) -
import Post.PyTree as P
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

a = G.cartTetra((-20, -20, -20), (0.5, 0.5, 0.5), (50, 50, 50))
a = C.initVars(
    a,
    '{field}={CoordinateX}*{CoordinateX}+{CoordinateY}*{CoordinateY}+{CoordinateZ}'
)

iso = P.isoSurf(a, 'field', value=5.)
t = C.newPyTree(['Base', 2])
t[2][1][2] += iso
test.testT(t, 1)
예제 #26
0
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')
test.testT(d,3)
예제 #27
0
# - collapse (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Transform.PyTree as T

a = G.cartTetra((0., 0., 0.), (0.1, 0.01, 1.), (20, 2, 1))
b = T.collapse(a)
C.convertPyTree2File(b, "out.cgns")
# - bboxIntersection (pyTree) -
import Generator.PyTree as G
import Transform.PyTree as T
import KCore.test as test

boxA = G.cartTetra((2,-1,0.5), (1,2,0.5), (2,2,2)) 

boxB = G.cartTetra((2,-1,0.5), (2,2,1), (2,2,2)) 
boxB  = T.rotate(boxB,(0,0,0),(10,5,-20))
AABB = G.BB(boxA)
OBB = G.BB(boxB, method='OBB')

intersect = G.bboxIntersection(AABB, AABB, tol=1e-10,isBB=True, method='AABB')
test.testO(intersect,1)

intersect = G.bboxIntersection(AABB, OBB, tol=1e-10, isBB=True, method='AABBOBB')
test.testO(intersect,2)

intersect = G.bboxIntersection(AABB, OBB, tol=1e-10, isBB=True, method='OBB')
test.testO(intersect,3)

예제 #29
0
# Zone structuree
a = G.cart((0., 0., 0.), (1., 1., 1.), (10, 10, 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, 3])
C._addVars(a, 'F')
C._addVars(a, 'centers:G')
vect = ['hx', 'hy', 'hz']
C._addVars(a, vect)
C._initVars(a, 'hx', 10.)
a = T.deform(a, vect)
test.testT(a, 1)

# Zone non structuree
a = G.cartTetra((0., 0., 0.), (1., 1., 1.), (10, 10, 2))
C._addVars(a, 'F')
C._addVars(a, 'centers:G')
vect = ['hx', 'hy', 'hz']
C._addVars(a, vect)
C._initVars(a, 'hx', 10.)
a = T.deform(a, vect)
test.testT(a, 2)

# Arbre
a = G.cart((0., 0., 0.), (1., 1., 1.), (10, 10, 1))
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin')
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmin')
b = G.cartTetra((1.5, 1.5, 0.), (1., 1., 1.), (10, 10, 1))
b[0] = 'cart2'
t = C.newPyTree(['Base', 2, a, b])
# - convertArray2NGon(pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G

a = G.cartTetra((0.,0.,0.), (0.1,0.1,0.2), (2,2,1))
b = C.convertArray2NGon(a)
C.convertPyTree2File(b, 'out.cgns')