# - exteriorFaces (pyTree) -
import KCore.test as test
import Post.PyTree as P
import Generator.PyTree as G

# 1D 
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
# - fillEmptyBC (pyTree) -
# avec des raccords partiels
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

a = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (10, 10, 10))
a = C.addBC2Zone(a, 'wall1', 'BCWall', [1, 1, 5, 7, 1, 10])
a = C.addBC2Zone(a, 'wall2', 'BCWall', [10, 10, 5, 7, 1, 10])
a = C.addBC2Zone(a, 'wall3', 'BCWall', [1, 4, 1, 1, 1, 10])
a = C.addBC2Zone(a, 'wall4', 'BCWall', [1, 4, 10, 10, 1, 10])
a = C.fillEmptyBCWith(a, 'wallv', 'BCWallViscous')
t = C.newPyTree(['Base', a])
test.testT(t)
예제 #3
0
# - cart2Cyl (pyTree) -
import Transform.PyTree as T
import Generator.PyTree as G
import Converter.PyTree as C
import KCore.test as test

a = G.cylinder((0., 0., 0.), 0.5, 1., 0., 359, 1., (360, 20, 10))
C._addBC2Zone(a, 'wall1', 'BCWall', 'imin')
C._initVars(a, 'F', 2.)
C._initVars(a, 'centers:G', 1.)
T._cart2Cyl(a, (0., 0., 0.), (0, 0, 1))
test.testT(a, 1)

a = G.cylinder((0., 0., 0.), 0.5, 1., 0., 359, 1., (360, 20, 10))
T._rotate(a, (0, 0, 0), (1, 0, 0), 90.)
T._cart2Cyl(a, (0., 0., 0.), (0, 1, 0))
test.testT(a, 2)

a = G.cylinder((0., 0., 0.), 0.5, 1., 0., 359, 1., (360, 20, 10))
T._rotate(a, (0, 0, 0), (0, 1, 0), 90.)
T._cart2Cyl(a, (0., 0., 0.), (1, 0, 0))
test.testT(a, 3)
예제 #4
0
# - curve (pyTree) -
import Converter.PyTree as C
import Geom.PyTree as D
import KCore.test as test


# User definition of parametric curve
def f(t):
    x = t
    y = t * t + 1
    z = 0.
    return (x, y, z)


a = D.curve(f)
t = C.newPyTree(['Base', 1])
t[2][1][2].append(a)
test.testT(t, 1)
test.writeCoverage(100)
예제 #5
0
# - silhouette (array) -
import Generator.PyTree as G
import Converter.PyTree as C
import Post.PyTree as P
import Transform.PyTree as T
import Geom.PyTree as D
import KCore.test as test

# 1D structure
a = G.cylinder((0., 0., 0.), 0.5, 1., 360., 0., 10., (50, 1, 1))
a = C.initVars(a, 'P', 1.)
a = C.initVars(a, 'centers:Q', 2.)
vector = [0., 1., 0.]
res = P.silhouette(a, vector)
test.testT(res, 1)

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
예제 #6
0
import Post.PyTree as P
import Generator.PyTree as G
import Transform.PyTree as T
import KCore.test as test

# cylindre
ni = 30
nj = 40
nk = 1
m1 = G.cylinder((0, 0, 0), 1, 5, 0., 360., 10., (50, 50, 1))
m1 = C.initVars(m1, 'cellN', 1.)
m1 = C.initVars(m1, 'centers:ichim', 1.)

# Set cellN = 2 (interpolated points) to boundary
s = T.subzone(m1, (1, nj, 1), (ni, nj, nk))
s = C.initVars(s, 'cellN', 2)
m1 = T.patch(m1, s, (1, nj, 1))

ni1 = m1[1][0][0]
nj1 = m1[1][0][1]
nk1 = nk
s = T.subzone(m1, (1, 1, 1), (ni1, 1, nk1))
s = C.initVars(s, 'cellN', 2)
m1 = T.patch(m1, s, (1, 1, 1))

# carre
m2 = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), -1), (ni, nj, 1))
m2 = C.initVars(m2, 'cellN', 1.)
m2 = C.initVars(m2, 'Density', 1.2)
test.testT(m2)
# - getVolumeMap (pyTree) -
import Generator.PyTree as G
import Converter.PyTree as C
import KCore.test as T

# Test 3D structure
a = G.cart((0.,0.,0.), (0.1,0.1,0.2), (10,10,3))
a = C.addBC2Zone(a, 'wall1','BCWall','jmin')
a = C.addBC2Zone(a, 'match1','BCMatch','imin',a,'imax',[1,2,3])
a = C.addBC2Zone(a, 'match2','BCMatch','imax',a,'imin',[1,2,3])
a = C.fillEmptyBCWith(a,'overlap','BCOverlap')
t = C.newPyTree(['Base']); t[2][1][2].append(a)
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
t = C.initVars(t,'Density',2.); t = C.initVars(t,'centers:cellN',1.)
t = G.getVolumeMap(t)
T.testT(t,1)

# Test 2D structure
a = G.cart((0.,0.,0.), (0.1,0.1,0.2), (10,10,1))
t = C.newPyTree(['Base',2]); t[2][1][2].append(a)
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
t = C.initVars(t,'Density',2.); t = C.initVars(t,'centers:cellN',1.)
t = G.getVolumeMap(t)
T.testT(t,2)

# Test 2d non-structure hexa
a = G.cartHexa((0.,0.,0.), (0.1,0.1,0.2), (10,10,1))
t = C.newPyTree(['Base',2]); t[2][1][2].append(a)
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
t = C.initVars(t,'Density',2.); t = C.initVars(t,'centers:cellN',1.)
t = G.getVolumeMap(t)
예제 #8
0
t[2][1][2].append(a)
t[2][2][2].append(b)
t = X.connectMatch(t, dim=3)
C._fillEmptyBCWith(t, 'nref', 'BCFarfield', dim=3)
C._addState(t, 'EquationDimension', 3)
C._addVars(t, 'F')
C._initVars(t, 'centers:G', 1.)
t = X.applyBCOverlaps(t, depth=1)

tDnr = C.node2ExtCenter(t)
t1 = X.setInterpData(t, tDnr, sameName=1, loc='centers', storage='direct')

C._initVars(tDnr, '{F}={CoordinateX}*{CoordinateY}')
C._initVars(t1, '{centers:F}={centers:CoordinateX}*{centers:CoordinateY}')
X._setInterpTransfers(t1, tDnr, cellNVariable='', variables=['F'])
test.testT(t1, 0)
t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='interpolated')
t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='extrapolated')
t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='orphan')
t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='cellRatio')
t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='donorAspect')
test.testT(t1, 1)
import sys
sys.exit()

tDnr = X.setInterpData(t, tDnr, sameName=1, loc='centers', storage='inverse')
t1 = X.getOversetInfo(t, tDnr, loc='centers', type='interpolated')
t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='extrapolated')
t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='orphan')
t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='cellRatio')
t1 = X.getOversetInfo(t1, tDnr, loc='centers', type='donorAspect')
예제 #9
0
# - subzone elements (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))
eltsL = []
for i in xrange(N * N):
    eltsL.append(i)
C._initVars(d, 'F={CoordinateX}')
C._initVars(d, 'centers:G={centers:CoordinateY}')
d = T.subzone(d, eltsL, type='elements')
test.testT(d, 1)
# 3D Tetra
N = 51
d = G.cartTetra((0, 0, 0), (1, 1, 1), (N, N, N))
eltsL = []
for i in xrange(N * N):
    eltsL.append(i)
C._initVars(d, 'F={CoordinateX}')
C._initVars(d, 'centers:G={centers:CoordinateY}')
d = T.subzone(d, eltsL, type='elements')
test.testT(d, 2)
#  3D Hexa
N = 51
d = G.cartHexa((0, 0, 0), (1, 1, 1), (N, N, N))
eltsL = []
for i in xrange(N * N):
    eltsL.append(i)
# - addReferenceState (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile
import KCore.test as test

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
t = C.newPyTree(['Base'])
t[2][1][2].append(a)
tp = elsAProfile.addReferenceState(t, conservative=[1., 0, 0, 0, 1.7])
test.testT(tp, 1)

tp = elsAProfile.addReferenceState(t,
                                   conservative=[1., 0, 0, 0, 1.7, 1e-7],
                                   turbmod='spalart')
test.testT(tp, 2)
tp = elsAProfile.addReferenceState(t,
                                   conservative=[1., 0., 0., 0., 1.7, 1e-7],
                                   turbmod='spalart',
                                   temp=1.,
                                   name='ReferenceStateSpalart',
                                   comments="Mon etat de reference")
test.testT(tp, 3)
예제 #11
0
# partiellement coincident
# --- CL
a2 = G.cart((1., 0.5, 0.), (0.1, 0.1, 0.1), (11, 21, 2))
a2[0] = 'cart2'
a2 = C.addBC2Zone(a2, 'wall1', 'BCWall', 'jmax')
a2 = C.addBC2Zone(a2, 'overlap1', 'BCOverlap', 'jmin')
# --- champ aux centres
a2 = C.initVars(a2, 'centers:Density', 1.)
# --- champ aux noeuds
a2 = C.initVars(a2, 'cellN', 2.)
t = C.newPyTree(['Base', a, a2])
# --- 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'
# - getZonesPerIterations (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.Internal as Internal
import KCore.test as test

a = G.cart((0, 0, 0), (1, 1, 1), (3, 3, 3))
t = C.newPyTree(['Base', a])
b = Internal.getNodeFromName(t, 'Base')
n = Internal.newBaseIterativeData(name='BaseIterativeData',
                                  nsteps=1,
                                  itype='IterationValues',
                                  parent=b)
Internal.newDataArray('TimeValues', value=[0.], parent=n)
Internal.newDataArray('NumberOfZones', value=[1], parent=n)
Internal.newDataArray('ZonePointers', value=[['cart']], parent=n)

# List of zones of it=0
zones = Internal.getZonesPerIteration(t, iteration=0)
test.testT(C.newPyTree(['Base', zones]), 1)
# List of zones of time 0.
zones = Internal.getZonesPerIteration(t, time=0.)
test.testT(C.newPyTree(['Base', zones]), 2)
# All zones of all iterations
zones = Internal.getZonesPerIteration(t)
test.testT(C.newPyTree(['Base', zones]), 3)
# - addGlobalConvergenceHistory (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile
import KCore.test as test

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
t = C.newPyTree(['Base', a])
tp = elsAProfile.addGlobalConvergenceHistory(t)
test.testT(tp, 1)
#
# Champ en noeuds non structure PENTA
#
a = G.cartPenta((-2., -1., -1.), (0.1, 0.1, 0.1), (21, 21, 21))
b = T.translate(a, (2, 0, 0))
b[0] = 'cart2'
t = C.newPyTree(['Cart'])
t[2][1][2] += [a, b]
t = C.initVars(t, 'Density', 1.)
t = C.initVars(t, 'cellN', sphere,
               ['CoordinateX', 'CoordinateY', 'CoordinateZ'])
nod = 1
for d in [-2, -1, 0, 1, 2, 5]:
    t2 = X.setHoleInterpolatedPoints(t, depth=d)
    test.testT(t2, nod)
    nod += 1

# Champ cellN en centres
a = G.cartPenta((-2., -1., -1.), (0.1, 0.1, 0.1), (21, 21, 21))
b = T.translate(a, (2, 0, 0))
b[0] = 'cart2'
t = C.newPyTree(['Cart'])
t[2][1][2] += [a, b]
t = C.initVars(t, 'Density', 1.)
t = C.initVars(t, 'cellN', sphere,
               ['CoordinateX', 'CoordinateY', 'CoordinateZ'])
t = C.node2Center(t, 'cellN')
t = C.rmVars(t, 'cellN')
for d in [-2, -1, 0, 1, 2, 5]:
    t2 = X.setHoleInterpolatedPoints(t, depth=d)
예제 #15
0
import Transform.PyTree as T
import Generator.PyTree as G
import Converter.PyTree as C
import KCore.test as test

# Structure 3D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 3))
a = C.addVars(a, 'Density')
a = C.addVars(a, 'centers:cellN')
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, 3])
t = C.newPyTree(['Base', a])
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
t = T.symetrize(t, (0., 0., 0.), (1, 0, 0), (0, 0, 1))
test.testT(t, 1)

# Structure 2D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 1))
a = C.addVars(a, 'Density')
a = C.addVars(a, 'centers:cellN')
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])
t = C.newPyTree(['Base', 2, a])
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t = T.symetrize(t, (0., 0., 0.), (1, 0, 0), (0, 0, 1))
test.testT(t, 2)

# TETRA
a = G.cartTetra((0, 0, 0), (1, 1, 1), (10, 10, 3))
# - setInterpolations (pyTree)-
# Cas double wall avec stockage inverse
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import KCore.test as test

a = G.cylinder((0, 0, 0), 1, 2, 0, 360, 1, (60, 20, 2))
b = G.cylinder((0, 0, 0), 1, 2, 3, 160, 1, (30, 20, 2))
a = C.addBC2Zone(a, 'wall', 'BCWall', 'jmin')
a = C.addBC2Zone(a, 'match', 'BCMatch', 'imin', a, 'imax', trirac=[1, 2, 3])
a = C.addBC2Zone(a, 'match', 'BCMatch', 'imax', a, 'imin', trirac=[1, 2, 3])
a = C.addBC2Zone(a, 'nref', 'BCFarfield', 'jmax')
b = C.addBC2Zone(b, 'wall', 'BCWall', 'jmin')
b = C.fillEmptyBCWith(b, 'overlap', 'BCOverlap', dim=2)
t = C.newPyTree(['Base', 'Base2'])
t[2][1][2] = [a]
t[2][2][2] = [b]
t = C.initVars(t, 'Density', 1.)
t = C.initVars(t, 'centers:G', 10.)
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
# depth = 2
t1 = X.applyBCOverlaps(t, depth=2)
t1 = X.setInterpolations(t1, loc='cell', double_wall=1, storage='inverse')
test.testT(t1, 1)
# depth = 1
t2 = X.applyBCOverlaps(t, depth=1)
t2 = X.setInterpolations(t2, loc='face', double_wall=1, storage='inverse')
t2 = X.setInterpolations(t2, loc='cell', double_wall=1, storage='inverse')
test.testT(t2, 2)
m = C.initVars(m, 'F1', F, ['CoordinateX', 'CoordinateY', 'CoordinateZ'])
m = C.addVars(m, 'F2')
m = C.addVars(m, 'F3')
varname = ['F1', 'F2', 'F3']
m = P.computeCurl(m, varname)
m = C.initVars(m, 'centers:F4', F,
               ['centers:rotx', 'centers:roty', 'centers:rotz'])
m = C.addVars(m, 'centers:F5')
m = C.addVars(m, 'centers:F6')
m = C.addBC2Zone(m, 'ov', 'BCOverlap', 'imin')
t = C.newPyTree(['Base', 2])
t[2][1][2].append(m)
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
varname = ['centers:F4', 'centers:F5', 'centers:F6']
t = P.computeNormCurl(t, varname)
test.testT(t, 2)

#-----
# 3D
#-----
ni = 30
nj = 40
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, 2))
m = C.initVars(m, 'F1', F, ['CoordinateX', 'CoordinateY', 'CoordinateZ'])
m = C.addVars(m, 'F2')
m = C.addVars(m, 'F3')
varname = ['F1', 'F2', 'F3']
m = P.computeCurl(m, varname)
m = C.initVars(m, 'centers:F4', F,
               ['centers:rotx', 'centers:roty', 'centers:rotz'])
m = C.addVars(m, 'centers:F5')
예제 #18
0
# - 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)
예제 #19
0
import KCore.test as test

surf = D.circle((0, 0, 0), 0.5, 20)

a = G.cart((-1., -1., 0.), (0.1, 0.1, 1), (20, 20, 1))
a = C.addBC2Zone(a, 'ov', 'BCOverlap', 'jmin')
t = C.newPyTree(['Cart', 2])
t[2][1][2].append(a)
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t = C.fillEmptyBCWith(t, 'wall', 'BCWall')
t = C.addVars(t, 'Density')
t = C.initVars(t, 'centers:cellN', 1.)
bodies = [[surf]]
criterions = ['cell_intersect', 'cell_intersect_opt', 'center_in']
# Matrice de masquage (arbre d'assemblage)
import numpy
BM = numpy.array([[1]])
c = 1
for delta in [0., 0.1]:
    for type in criterions:
        if (type == 'cell_intersect_opt' and delta > 0): c += 1
        else:
            t2 = X.blankCells(t,
                              bodies,
                              BM,
                              blankingType=type,
                              delta=delta,
                              dim=2)
            test.testT(t2, c)
            c += 1
# - enforceMoinsY (pyTree)-
import Generator.PyTree as G
import KCore.test as test
import Converter.PyTree as C

# Distribution 2D
Ni = 50; Nj = 50
a = G.cart((0,0,0), (1./(Ni-1), 0.5/(Nj-1),1), (Ni,Nj,1))
a = C.addBC2Zone(a, 'wall1','BCWall','jmin')
a = C.addBC2Zone(a, 'match1','BCMatch','imin',a,'imax',[1,2])
a = C.addBC2Zone(a, 'match2','BCMatch','imax',a,'imin',[1,2])
a = C.addBC2Zone(a, 'wall2','BCWall','jmax')
a = C.addVars(a,'Density'); a = C.addVars(a,'centers:cellN')

# monotonic
b = G.enforceMoinsY(a, 1.e-3, (10,15))
test.testT(b,1)
# exact nb of added pts
b = G.enforceMoinsY(a, 1.e-3,10,15)
test.testT(b,2)
import Geom.PyTree as D
import Dist2Walls.PyTree as DTW
import KCore.test as test

N = 21
a = G.cart((0, 0, 0), (1. / (N - 1), 1. / (N - 1), 1. / (N - 1)), (N, N, N))
body = D.sphere((0.5, 0, 0), 0.1, N=20)
tb = C.newPyTree(['Base', body])
C._addState(tb, 'EquationDimension', 3)
C._addState(tb, 'GoverningEquations', 'NSTurbulent')
t = C.newPyTree(['Base', a])
DTW._distance2Walls(t, bodies=tb, loc='centers', type='ortho')
C._initVars(t, 'centers:cellN', 1.)
t, tc = IBM.prepareIBMData(t, tb, DEPTH=2, frontType=0, interpDataType=1)
res = IBM.extractIBMInfo(tc)
test.testT(tc, 1)

# front 1
tb = C.newPyTree(['Base', body])
C._addState(tb, 'EquationDimension', 3)
C._addState(tb, 'GoverningEquations', 'NSTurbulent')
DTW._distance2Walls(t, bodies=tb, loc='centers', type='ortho')
C._initVars(t, 'centers:cellN', 1.)
t, tc = IBM.prepareIBMData(t, tb, DEPTH=2, frontType=1, interpDataType=1)
test.testT(tc, 12)

# front2
t = C.newPyTree(['Base', a])
tb = C.newPyTree(['Base', body])
C._addState(tb, 'EquationDimension', 3)
C._addState(tb, 'GoverningEquations', 'NSTurbulent')
a = G.cart((0.2,0,0),(1./(ni-1), 1./(nj-1),dk),(ni,nj,nk))
C._initVars(a,'{VelocityX}={CoordinateX}')
C._initVars(a,'{VelocityY}={CoordinateY}')
C._initVars(a,'VelocityZ', 1.)
C._addBC2Zone(a,'per1','BCMatch',[1,1,1,nj,1,nk], zoneDonor=a,
              rangeDonor=[ni,ni,1,nj,1,nk], trirac=[1,2,3],
              rotationCenter=(0,0,0), rotationAngle=(0.,0.,0.),
              translation=(+1.,0.,0.))
C._addBC2Zone(a,'per2','BCMatch',[ni,ni,1,nj,1,nk], zoneDonor=a,
              rangeDonor=[1,1,1,nj,1,nk], trirac=[1,2,3],
              rotationCenter=(0,0,0), rotationAngle=(0.,0.,0.),
              translation=(-1.,0.,0.))

t = C.newPyTree(['Base',a])
t = Internal.addGhostCells(t,t,2,adaptBCs=1,fillCorner=1)
test.testT(t,1)

# cas periodicite par rotation
ni = 91; nj = 21; nk = 1
alpha = 90.
a = G.cylinder((0,0,0),0.5,1.,0.,alpha,1.,(ni,nj,nk))
C._initVars(a,'VelocityX', 0.)
C._initVars(a,'VelocityY', 0.)
C._initVars(a,'VelocityZ', 1.)
vx = C.getField('VelocityX',a)[0]
vy = C.getField('VelocityY',a)[0]
nic = vx[2]; njc = vx[3]
for j in range(njc):
    for i in range(nic):
        i0 = i * math.pi/2./90.
        vx[1][0,i+j*nic] = math.cos(i0)
예제 #23
0
# 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')
# - convexify any concave polygon in the mesh (array) -
import Intersector.PyTree as XOR
import Converter.PyTree as C
import KCore.test as test

M1 = C.convertFile2PyTree('boolNG_M1.tp')
M1 = C.convertArray2NGon(M1)

M2 = C.convertFile2PyTree('boolNG_M2.tp')
M2 = C.convertArray2NGon(M2)

tol = -0.5e-3

m = XOR.booleanMinus(M1, M2, tol, preserve_right=1, solid_right=1, agg_mode=1)
#C.convertArrays2File([m], 'i.plt')

m = XOR.simplifyCells(m, 1)

test.testT(m, 1)
예제 #25
0
import Geom.PyTree as D
import Transform.PyTree as T
import Converter.PyTree as C
import KCore.test as test

# Join 2 NON-STRUCT TETRA
a1 = G.cartTetra((0., 0., 0.), (1., 1., 1), (11, 11, 10))
a2 = G.cartTetra((10., 0., 0.), (1., 1., 1), (10, 10, 10))
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', 3])
a = T.join(a1, a2)
t[2][1][2].append(a)
test.testT(t, 1)

# mix struct 3D + HEXA
a1 = G.cart((0., 0., 0.), (1., 1., 1), (11, 11, 10))
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((10., 0., 0.), (1., 1., 1), (11, 11, 10))
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', 3])
a = T.join(a1, a2)
t[2][1][2].append(a)
test.testT(t, 2)
예제 #26
0
import Post.PyTree as P
import Generator.PyTree as G
import KCore.test as test

#-----
# 3D
#-----
ni = 30
nj = 40
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, 2))
C._initVars(
    m,
    '{centers:Density}=2*{centers:CoordinateX}+{centers:CoordinateX}*{centers:CoordinateY}'
)
P._computeGrad2(m, 'centers:Density')
test.testT(m, 1)

ni = 30
nj = 40
nk = 10
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
C._initVars(
    m,
    '{centers:Density}=2*{centers:CoordinateX}+{centers:CoordinateX}*{centers:CoordinateY}'
)
P._computeGrad2(m, 'centers:Density')
test.testT(m, 2)

#-----
# NGON
#-----
# - bboxOfCells (pyTree) -
import Generator.PyTree as G
import Converter.PyTree as C
import KCore.test as test

# test 1D structure
a = G.cart((0.,0.,0.),(0.1,0.1,1.),(20,1,1))
a = C.initVars(a,'Density',2.); a = C.initVars(a,'centers:cellN',1.)
a = G.bboxOfCells(a)
test.testT(a,1)

# test 2D structure
a = G.cart((0.,0.,0.),(0.1,0.1,1.),(20,20,1))
a = C.addBC2Zone(a, 'wall1','BCWall','jmin')
a = C.initVars(a,'Density',2.); a = C.initVars(a,'centers:cellN',1.)
a = G.bboxOfCells(a)
test.testT(a,2)

# test 3d structure
a = G.cart((0.,0.,0.),(0.1,0.1,1.),(20,20,20))
a = C.addBC2Zone(a, 'wall1','BCWall','jmin')
a = C.addBC2Zone(a, 'match1','BCMatch','imin',a,'imax',[1,2,3])
a = C.addBC2Zone(a, 'match2','BCMatch','imax',a,'imin',[1,2,3])
a = C.fillEmptyBCWith(a,'overlap','BCOverlap')
a = C.initVars(a,'Density',2.); a = C.initVars(a,'centers:cellN',1.)
a = G.bboxOfCells(a)
test.testT(a,3)

# test TRI
a = G.cart((0.,0.,0.),(0.1,0.1,1.),(20,20,1))
a = C.convertArray2Tetra(a); a = G.bboxOfCells(a)
예제 #28
0
import Generator.PyTree as G
import Transform.PyTree as T
import KCore.test as test

a1 = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 1))
a1[0] = 'cart1'
a2 = G.cart((9 + 1.e-2, 0, 0), (1, 1, 1), (10, 10, 1))
a2[0] = 'cart2'
a3 = G.cart((0, -5.01, 0), (1, 1, 1), (19, 6, 1))
a3[0] = 'cart3'
a4 = G.cart((0, 9.0001, 0), (1, 1, 1), (10, 6, 1))
a4[0] = 'cart4'
a5 = G.cart((9.01, 9.0002, 0), (1, 1, 1), (10, 6, 1))
a5[0] = 'cart5'

zones = [a1, a2, a3, a4, a5]
for i in xrange(len(zones)):
    zones[i] = C.addBC2Zone(zones[i], 'match1','BCMatch','imin',\
                            zones[i],'imax',[1,2])
    zones[i] = C.addBC2Zone(zones[i], 'match2','BCMatch','imax',\
                            zones[i],'imin',[1,2])
    zones[i] = C.addBC2Zone(zones[i], 'wall1', 'BCWall', 'jmin')
    zones[i] = C.addBC2Zone(zones[i], 'wall2', 'BCWall', 'jmax')

zones = C.addVars(zones, 'Density')
zones = C.addVars(zones, 'centers:cellN')

# Close une liste de maillages structures
zones = G.close(zones, 1e-1)
test.testT(zones, 1)
예제 #29
0
# - exteriorFacesStructured (pyTree) -
import Converter.PyTree as C
import Post.PyTree as P
import Generator.PyTree as G
import KCore.test as test

# 1D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 1, 1))
C._addVars(a, 'Density')
C._addVars(a, 'centers:cellN')
t = C.newPyTree(['Base', 1, a])
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
zones = P.exteriorFacesStructured(t)
test.testT(zones, 1)

# 2D
a = G.cart((0, 0, 0), (1, 1, 1), (1, 6, 10))
C._addVars(a, 'Density')
C._addVars(a, 'centers:cellN')
t = C.newPyTree(['Base', 2, a])
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
zones = P.exteriorFacesStructured(t)
test.testT(zones, 2)

# 3D
a = G.cart((0, 0, 0), (1, 1, 1), (4, 4, 6))
C._addVars(a, 'Density')
C._addVars(a, 'centers:cellN')
t = C.newPyTree(['Base', 3, a])
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
zones = P.exteriorFacesStructured(t)
# - cylinder (pyTree) -
import Generator.PyTree as G
import KCore.test as test

a = G.cylinder((0., 0., 0.), 0.5, 1., 360., 0., 10., (50, 50, 30))
test.testT(a, 1)
test.writeCoverage(100)