示例#1
0
# - setProc (pyTree) -
import Converter.PyTree as C
import Converter.Internal as Internal
import Converter.Mpi as Cmpi
import Generator.PyTree as G

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
b = G.cart((12, 0, 0), (1, 1, 1), (10, 10, 10))
t = C.newPyTree(['Base', a, b])
t = Cmpi.setProc(t, 1)

zones = Internal.getZones(t)
for z in zones:
    print z[0] + ' -> ' + str(Cmpi.getProc(z))
    #>> cart -> 1
    #>> cart.0 -> 1
示例#2
0
# - applyBCOverlaps (pyTree) -
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import Transform.PyTree as T
import KCore.test as test

# NGON
a = G.cylinder((0,0,0), 1., 1.5, 360., 0., 1., (30,30,10))
s = T.subzone(a,(1,30,1),(-1,-1,-1))
s = C.convertArray2NGon(s)
a = C.convertArray2NGon(a)
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', subzone=s)
C._initVars(a, 'Density', 1.)
t = C.newPyTree(['Base',a])
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
t1 = X.applyBCOverlaps(t, depth=1, loc='nodes')
test.testT(t1, 1)

t1 = X.applyBCOverlaps(t, depth=1, loc='centers')
test.testT(t1, 2)

t1 = X.applyBCOverlaps(t, depth=2, loc='nodes')
test.testT(t1, 3)

t1 = X.applyBCOverlaps(t, depth=2, loc='centers')
test.testT(t1, 4)
示例#3
0
# - projectOrthoSmooth (pyTree) -
import Geom.PyTree as D
import Converter.PyTree as C
import Generator.PyTree as G
import Transform.PyTree as T

a = D.sphere((0,0,0), 1., 30)
b = G.cart((-0.5,-0.5,-1.5),(0.05,0.05,0.1), (20,20,1))
c = T.projectOrthoSmooth(b, [a], niter=2)
C.convertPyTree2File([a,b,c], 'out.cgns')
# - initVisbal (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Initiator.PyTree as I

NI = 100
NJ = 100
HI = 50. / (NI - 1)
HJ = 50. / (NJ - 1)
MachInf = 0.8

a = G.cart((0., 0., 0.), (HI, HJ, 1.), (NI, NJ, 2))
z = I.initVisbal(a, (3., 3.), 2., MachInf, loc='centers')
C.convertPyTree2File(z, 'out.cgns')
# - bboxIntersection (pyTree) -
import Generator.PyTree as G
ni = 11
nj = 3
nk = 11
a1 = G.cart((0., 0., 0.), (0.1, 0.1, 0.2), (ni, nj, nk))
a2 = G.cart((0.5, 0.05, 0.01), (0.1, 0.1, 0.2), (ni, nj, nk))
intersect = G.bboxIntersection(a1, a2)
print(intersect)
# - adaptPeriodicMatch (pyTree) -
import Generator.PyTree as G
import Connector.PyTree as X
import Converter.PyTree as C
import Converter.elsAProfile as elsAProfile
import KCore.test as test

a = G.cylinder((0., 0., 0.), 0.1, 1., 0., 90., 5., (11, 11, 11))
t = C.newPyTree(['Base', a])
t = X.connectMatchPeriodic(t,
                           rotationCenter=[0., 0., 0.],
                           rotationAngle=[0., 0., 90.])
tp = elsAProfile.adaptPeriodicMatch(t)
test.testT(tp, 1)

a = G.cylinder((0., 0., 0.), 0.1, 1., 0., 90., 5., (11, 11, 11))
t = C.newPyTree(['Base', a])
t = X.connectMatchPeriodic(t, translation=[0., 0., 5.])
tp = elsAProfile.adaptPeriodicMatch(t)
test.testT(tp, 2)

tp = elsAProfile.adaptPeriodicMatch(t, clean=True)
test.testT(tp, 3)
# - optimizeOverlap (pyTree)-
# Cas double wall
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:cellN', 1)
t[2][1] = C.addState(t[2][1], 'EquationDimension', 2)
t2 = X.optimizeOverlap(t, double_wall=1, priorities=['Base2', 0, 'Base', 1])
test.testT(t2)

# Same as first test, but now using an intersection dictionnary
interDict = X.getIntersectingDomains(t, method='hybrid')
t2 = X.optimizeOverlap(t,
                       double_wall=1,
                       priorities=['Base2', 0, 'Base', 1],
                       intersectionsDict=interDict)
test.testT(t2, 2)
示例#8
0
# - getMinValue (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

a = G.cart((0, 0, 0), (1., 1., 1.), (11, 1, 1))
b = G.cart((-1, 0, 0), (1, 1, 1), (2, 2, 1))
b[0] = 'cart2'
# test sur une zone
minval = C.getMinValue(a, 'CoordinateX')
test.testO(minval, 1)
# test sur une liste de zones
minval = C.getMinValue([a, b], 'CoordinateX')
test.testO(minval, 2)
# test sur un arbre
t = C.newPyTree(['Base', 2])
t[2][1][2] += [a, b]
t = C.addBC2Zone(t, 'wall1', 'BCWall', 'imax')
t = C.initVars(t, 'F', 1.)
t = C.initVars(t, 'centers:G', 2.)
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
minval = C.getMinValue(t, 'CoordinateX')
test.testO(minval, 3)
示例#9
0
# - fillMissingVariables (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 11))
a[0] = 'cart1'
a = C.initVars(a, 'F', 1.)
a = C.initVars(a, 'centers:G', 2.)
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'jmin')
b = G.cart((1, 0, 0), (2, 1, 1), (10, 10, 11))
b[0] = 'cart2'
t = C.newPyTree(['Base'])
t[2][1][2] += [a, b]
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
t = C.fillMissingVariables(t)
test.testT(t, 1)
示例#10
0
# - F (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

def F(x): return x

# Une zone
a = G.cart( (0,0,0), (1,1,1), (10,10,10) )
a = C.initVars(a, '{F}={CoordinateX}+{CoordinateY}')
a = C.initVars(a, '{centers:G}={centers:CoordinateX}+{centers:CoordinateY}')
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
b = F(a)
test.testT(b, 1)

# Une liste de zones
a = G.cart( (0,0,0), (1,1,1), (10,10,10) )
b = G.cartTetra( (0,0,0), (1,1,1), (10,10,10) )
B = F([a,b])
test.testT(B, 2)

# Un arbre
a = G.cart( (0,0,0), (1,1,1), (10,10,10) )
t = C.newPyTree(['Base'])
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
t[2][1][2] += [a]
t = F(t)
test.testT(t, 3)
示例#11
0
# - getCellPlanarity (pyTree) -
import KCore.test as test
import Generator.PyTree as G
import Geom.PyTree as D
import Converter.PyTree as C

a = D.sphere((0, 0, 0), 1., 10)
C._initVars(a, 'Density', 2.)
C._initVars(a, 'centers:cellN', 1.)
a = G.getCellPlanarity(a)
test.testT(a, 1)
# - boolean reorientExternalFaces (array) -
import Generator.PyTree as G
import Converter.PyTree as C
import Intersector.PyTree as XOR
import KCore.test as test

a = G.cartHexa((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 10))
a = C.convertArray2NGon(a)
a = XOR.reorientExternalFaces(a)

t = C.newPyTree(['Base', 2])
t[2][1][2].append(a)
test.testT(t, 1)
示例#13
0
# - getState (pyTree) -
import Generator.PyTree as G
import CPlot.PyTree as CPlot

a = G.cart((0, 0, 0), (1, 1, 1), (5, 5, 5))
CPlot.display(a)

print('dim=', CPlot.getState('dim'))
print('mode=', CPlot.getState('mode'))
print('displayInfo=', CPlot.getState('displayInfo'))
print('meshStyle=', CPlot.getState('meshStyle'))
print('solidStyle=', CPlot.getState('solidStyle'))
print('isoEdges=', CPlot.getState('isoEdges'))
print('win=', CPlot.getState('win'))
print('posCam=', CPlot.getState('posCam'))
print('posEye=', CPlot.getState('posEye'))
print('dirCam=', CPlot.getState('dirCam'))
import Generator.PyTree as G
import Transform.PyTree as T
import Converter.PyTree as C
import Converter.Internal as Internal
import Connector.PyTree as X
import Converter.GhostCells as GC
import KCore.test as test

a = G.cartNGon((0, 0, 0), (1, 1, 1), (6, 6, 3))
b = T.splitNParts(a, N=3)
t = C.newPyTree(['Base', b])
t = X.connectMatch(t)
t = C.fillEmptyBCWith(t, 'wall', 'BCWall', dim=3)
Internal._adaptNFace2PE(t, remove=False)
# Test avec deux couches
t = GC.adapt2FastP(t, nlayers=2)  # creation parentElement du NGon
test.testT(t, 1)
示例#15
0
# - cylinder3 (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
teta = G.cart((0., 0., 0.), (0.1, 1., 1.), (11, 1, 1))
xz = G.cart((0.1, 0., 0.), (0.1, 1., 0.2), (20, 1, 30))
cyl = G.cylinder3(xz, 0., 90., teta)
C.convertPyTree2File(cyl, 'out.cgns')
# - constrainedDelaunay (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Geom.PyTree as D
import Transform.PyTree as T

A = D.text1D('STEPHANIE')
A = C.convertArray2Tetra(A)
a = T.join(A)
# Triangulation respecting given contour
tri = G.constrainedDelaunay(a)
C.convertPyTree2File(tri, 'out.cgns')
# - boolean diffSurf (PyTree) -
import Generator.PyTree as G
import Geom.PyTree as D
import Converter.PyTree as C
import Intersector.PyTree as XOR
import KCore.test as test

# octree
s = D.sphere((0, 0, 0), 1., 100)
snear = 0.1
t = G.octree([s], [snear], dfar=5., balancing=1, ratio=2)

print("ngon conversion...")
t = C.convertArray2NGon(t)
print("ngon conformization...")
t = C.conformizeNGon(t)
t = G.close(t)
print("ngon close cells...")
t = XOR.closeOctalCells(t)
#t = XOR.reorientExternalFaces(t)

s = C.convertArray2NGon(s)
s = XOR.convertNGON2DToNGON3D(s)
#s = XOR.reorientExternalFaces(s)

x = XOR.diffSurf(t, s, tol=0., preserve_right=1,
                 agg_mode=2)  # agg_mode=2 : full mode aggregation

#C.convertPyTree2File(s, 's.cgns')
#C.convertPyTree2File(t, 'o.cgns')
# - getAllIBMPoints (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Connector.ToolboxIBM as IBM
import Post.PyTree as P
import Converter
import KCore.test as test
N = 21
a = G.cart((0, 0, 0), (1, 1, 1), (N, N, N))
C._initVars(a, 'centers:TurbulentDistance={centers:CoordinateZ}')
C._initVars(
    a,
    'centers:cellN=({centers:CoordinateZ}>0.8)*1.+({centers:CoordinateZ}<0.8)*2.'
)
a = P.computeGrad(a, 'centers:TurbulentDistance')
res = IBM.getAllIBMPoints(a, loc='centers', hi=0., he=2., tb=None)
test.testA(res[0] + res[1])
test.testA(res[2], 12)
N = 21
a = G.cart((0, 0, 0), (1, 1, 1), (N, N, N))
C._initVars(a, 'TurbulentDistance={CoordinateZ}')
C._initVars(a, 'cellN=({CoordinateZ}>0.8)*1.+({CoordinateZ}<0.8)*2.')
a = P.computeGrad(a, 'TurbulentDistance')
a = C.center2Node(a, 'FlowSolution#Centers')
res = IBM.getAllIBMPoints(a, loc='nodes', hi=0., he=2., tb=None)
test.testA(res[0] + res[1], 2)
test.testA(res[2], 22)
示例#19
0
# - rmGhostCells (pyTree) -
import Generator.PyTree as G
import Converter.PyTree as C
import Geom.PyTree as D
import Converter.Internal as Internal
import Transform.PyTree as T
import Connector.PyTree as X
import KCore.test as test

# 3D sur une zone
a = D.sphere((0, 0, 0), 1, N=10)
dhk = G.cart((0, 0, 0), (0.1, 1, 1), (2, 1, 1))
a = G.addNormalLayers(a, dhk)
a = C.convertArray2NGon(a)
a = G.close(a)
a = C.initVars(a, 'centers:F={centers:CoordinateX}')
a = C.initVars(a, 'Density={CoordinateX}')
t = C.newPyTree(['Base'])
t[2][1][2] = [a]
t = Internal.addGhostCells(t, t, 2)
t = Internal.rmGhostCells(t, t, 2)
test.testT(t, 1)

# 3D sur un arbre
a = D.sphere((0, 0, 0), 1, N=10)
dhk = G.cart((0, 0, 0), (0.1, 1, 1), (2, 1, 1))
a = G.addNormalLayers(a, dhk)
a = C.convertArray2NGon(a)
a = G.close(a)
a = C.initVars(a, 'centers:F={centers:CoordinateX}**2')
a = C.initVars(a, 'Density=3*{CoordinateX}+2*{CoordinateY}')
示例#20
0
# - extractPoint (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Post.PyTree as P
import KCore.test as test

# Maillage en noeuds
ni = 10
nj = 10
nk = 10
a = G.cart((0, 0, 0), (1. / (ni - 1), 1. / (nj - 1), 1. / (nk - 1)),
           (ni, nj, nk))


# Create a function
def F(x, y, z):
    return 2 * x * x * x * x * x + 2. * y * y * z + z * z


# Init by function
a = C.initVars(a, 'F', F, ['CoordinateX', 'CoordinateY', 'CoordinateZ'])
a = C.initVars(a, 'centers:G', 1.)

# 2nd order
val = P.extractPoint(a, (0.55, 0.38, 0.12), 2)
ref = [0.15309556470050301, 1.0]
print "Test1... done."
for i in xrange(len(val)):
    if abs(val[i] - ref[i]) > 1.e-10:
        print 'DIFF: reference: ' + str(ref[i]) + '.'
        print 'DIFF: courant: ' + str(val[i]) + '.'
# - extractAllBCMatch (pyTree) -
import Generator.PyTree as G
import Converter.PyTree as CP
import Connector.PyTree as X
import KCore.test as test

# NGON
a = G.cartNGon((1, 1, 1), (1., 1., 1.), (4, 10, 3))
a[0] = 'cart1'
b = G.cartNGon((4, 2, 0), (1., 1., 1.), (5, 8, 5))
b[0] = 'cart2'

t = CP.newPyTree(['Base', a, b])

t = CP.initVars(t, '{F}=3*{CoordinateX}+2*{CoordinateY}')
t = CP.initVars(t, '{centers:G}=2.53')
t = CP.initVars(t, '{centers:H}={centers:CoordinateY}')
t = CP.initVars(t, '{centers:M}={centers:CoordinateX}')
t = X.connectMatch(t, dim=3)
t = CP.fillEmptyBCWith(t, "wall", 'BCWall')

dico = CP.extractAllBCMatch(t, ['centers:H', 'centers:M'])
test.testO(dico, 1)

dico = CP.extractAllBCMatch(t)
test.testO(dico, 2)
示例#22
0
# - adaptOctree (pyTree) -
import Generator.PyTree as G
import Converter.PyTree as C
import Geom.PyTree as D

s = D.circle((0, 0, 0), 1., N=100)
snear = 0.1
o = G.octree([s], [snear], dfar=5., balancing=1)
o = C.initVars(o, 'centers:indicator', 1.)
res = G.adaptOctree(o)
C.convertPyTree2File(res, 'out.cgns')
# - integNormProduct (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Post.PyTree as P

ni = 30
nj = 40
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, 1))
m = C.initVars(m, 'MomentumX', 1.)
m = C.initVars(m, 'MomentumY', 1.)
m = C.initVars(m, 'MomentumZ', 1.)
res = P.integNormProduct(m, ['MomentumX', 'MomentumY', 'MomentumZ'])
print res
示例#24
0
# - dual (pyTree)
import Converter.PyTree as C
import Generator.PyTree as G
import Transform.PyTree as T
import Geom.PyTree as D

ni = 5; nj = 5
a = G.cart((0,0,0),(1,1,1),(ni,nj,1))
a = C.convertArray2NGon(a); a = G.close(a)
res = T.dual(a)
C.convertPyTree2File(res, 'out.cgns')


示例#25
0
# - projectDir (pyTree) -
import Geom.PyTree as D
import Converter.PyTree as C
import Generator.PyTree as G
import Transform.PyTree as T
import KCore.test as test

# 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.cart((1.1, -0.1, -0.1), (0.1, 0.1, 0.1), (1, 5, 5))
c = T.projectDir(b, a, (1., 0, 0))
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))
c = T.projectDir(b, a, (1., 0, 0))
c[0] = 'projection'
t = C.newPyTree(['Base', 2])
t[2][1][2].append(c)
# - 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, TurbLevelInf=1.e-4) 

# Get the ref state
state = C.getState(t)
test.testO(state, 1)
示例#27
0
# - 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')
# - getNodesFromValue (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.Internal as Internal

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
t = C.newPyTree(['Base', a])

# Return nodes with given value
nodes = Internal.getNodesFromValue(t, 2.4)
print nodes
#>> []
nodes = Internal.getNodesFromValue(t, 'Structured')
print nodes
#>> [['ZoneType', array(..), [], 'ZoneType_t']]
示例#29
0
# - setHoleInterpolatedPts (pyTree) -
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import Transform.PyTree as T
import KCore.test as test
def sphere(x,y,z):
    if x*x+y*y+z*z < 0.5**2 : return 0.
    else: return 1.

#
# Champ en noeuds non structure TETRA
#
a = G.cartTetra((-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,loc='nodes')
    test.testT(t2,nod); nod+=1

# Champ cellN en centres
a = G.cartTetra((-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]:
示例#30
0
# - splitBAR (PyTree) -
import Generator.PyTree as G
import Converter.PyTree as C
import Geom.PyTree as D
import Transform.PyTree as T
import KCore.test as test

a = G.cart((0, 0, 0), (1, 1, 1), (50, 1, 1))
a = C.convertArray2Tetra(a)
a = G.close(a)
B = T.splitBAR(a, 5)
t = C.newPyTree(['Base', 1])
t[2][1][2] += B
test.testT(t, 1)