Exemple #1
0
# - interiorFaces (pyTree) -
import Converter.PyTree as C
import Post.PyTree as P
import Generator.PyTree as G
import KCore.test as test

# test faces interieures au sens large
# faces ayant 2 voisins
a = G.cartTetra((0, 0, 0), (1, 1., 1), (20, 2, 1))
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)
t = P.interiorFaces(t)
test.testT(t, 1)

# test faces interieures au sens strict :
# faces n'ayant que des noeuds interieurs
a = G.cartTetra((0, 0, 0), (1, 1., 1), (20, 3, 1))
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)
t = P.interiorFaces(t, 1)
test.testT(t, 2)

# test faces interieures au sens strict :
# faces n'ayant que des noeuds interieurs
# ici aucune
a = G.cartTetra((0, 0, 0), (1, 1., 1), (20, 2, 1))
C._addVars(a, 'Density')
Exemple #2
0
# - rmVars (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

# Sur une zone
a = G.cart((0,0,0),(1,1,1),(10,10,10))
C._addBC2Zone(a, 'wall1', 'BCWall', 'jmin')
C._addVars(a, ['Density', 'centers:cellN', 'rou', 'rov', 'Hx', 'centers:Hy'])
C._rmVars(a, 'Density')
C._rmVars(a, ['Hx', 'centers:Hy'])
C._rmVars(a, 'FlowSolution#Centers')
t = C.newPyTree(['Base',a])
test.testT(t, 1)

# Sur un arbre
a = G.cart((0,0,0),(1,1,1),(10,10,10))
C._addBC2Zone(a, 'wall1', 'BCWall', 'jmin')
C._addVars(a, ['Density', 'centers:cellN'])
b = G.cart((10,0,0),(1,1,1),(10,10,10))
C._addVars(b, ['Density', 'centers:cellN'])
t = C.newPyTree(['Base',a,b])
C._addState(t[2][1], 'Mach', 0.6)
C._rmVars(t, 'Density')
test.testT(t, 2)

# Sur une liste de zones
A = C.rmVars([a,b], 'Density')
t = C.newPyTree(['Base']); t[2][1][2] += A
test.testT(t, 3)
# - projectAllDirs (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])
C._addVars(a, 'F')
C._addVars(a, 'centers:G')
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, 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])
C._addVars(a, 'F')
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'])
# - splitSize (pyTree) -
import Generator.PyTree as G
import Transform.PyTree as T
import Converter.PyTree as C
import Connector.PyTree as X
import KCore.test as test

# Structure + Champs + CL
a = G.cart((0, 0, 0), (1, 1, 1), (50, 20, 10))
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, 'Density')
C._initVars(a, 'centers:cellN', 1)
t = C.newPyTree(['Base'])
t[2][1][2].append(a)
t = T.splitSize(t, 1000)
t = X.connectMatch(t)
test.testT(t, 1)

# 2D Structure + Champs + CL
a = G.cart((0, 0, 0), (1, 1, 1), (50, 20, 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])
C._addVars(a, 'Density')
C._initVars(a, 'centers:cellN', 1)
t = C.newPyTree(['Base', 3])
t[2][1][2].append(a)
t = T.splitSize(t, 100)
t = X.connectMatch(t)
Exemple #5
0
import Generator.PyTree as G
import Connector.PyTree as X

a = G.cylinder((0,0,0),1.,3.,360,0,1,(200,30,3)); a[0] = 'cylindre1'
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'jmin')
a = C.addBC2Zone(a, 'ov1', 'BCOverlap', 'jmax')
b = G.cylinder((4,0,0),1.,3.,360,0,1,(200,30,3)); b[0] = 'cylindre2'
b = C.addBC2Zone(b, 'wall1', 'BCWall', 'jmin')
b = C.addBC2Zone(b, 'ov1', 'BCOverlap', 'jmax')
c = G.cart((-5.,-7.5,0), (15./200,15./200,1), (200,200,3))
t = C.newPyTree(['Corps1','Corps2','Bgrd'])
t[2][1][2].append(a); t[2][2][2].append(b); t[2][3][2].append(c)
t = X.connectMatch(t, dim=2)
t = C.fillEmptyBCWith(t,'nref','BCFarfield', dim=3)
t = X.applyBCOverlaps(t, depth=2)
t = X.setInterpolations(t, storage = 'direct')

C._addVars(t,'centers:Density')
C._addVars(t,'centers:MomentumX')
C._addVars(t,'centers:MomentumY') 
C._addVars(t,'centers:MomentumZ')
C._addVars(t,'centers:StagnationEnergy')
for i in range(len(t[2])):
    C._initVars(t[2][i], 'centers:Density', float(i+1))
    C._initVars(t[2][i], 'centers:MomentumX', float(i+1))
    C._initVars(t[2][i], 'centers:MomentumY', float(i+1))
    C._initVars(t[2][i], 'centers:MomentumZ', float(i+1))
    C._initVars(t[2][i], 'centers:StagnationEnergy', float(i+1))
t = X.chimeraTransfer(t, storage='direct', variables=['centers:Density','centers:MomentumX','centers:MomentumY','centers:MomentumZ','centers:StagnationEnergy'])
C.convertPyTree2File(t, 'out.cgns')
Exemple #6
0
# - getVarNames (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
C._addVars(a, ['Density', 'centers:cellN'])
# one zone
print(C.getVarNames(a, loc='nodes'))
#>> [['CoordinateX', 'CoordinateY', 'CoordinateZ', 'Density']]
print(C.getVarNames(a, loc='centers'))
#>> [['CoordinateX', 'CoordinateY', 'CoordinateZ', 'centers:cellN']]
print(C.getVarNames(a, excludeXYZ=True, loc='both'))
#>> [['Density', 'centers:cellN']]
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import Geom.PyTree as D
import Transform.PyTree as T
import KCore.test as test
import numpy

surf = D.sphere((0,0,0), 0.5, 20)
T._rotate(surf,(0.,0.,0.),(0.,1.,0.), 90.)
a = G.cart((-1.,-1.,-1.),(0.1,0.1,0.1), (20,20,20))
C._addBC2Zone(a, 'ov', 'BCOverlap', 'jmin')
t = C.newPyTree(['Cart',a])
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
C._fillEmptyBCWith(t, 'wall', 'BCWall')
C._addVars(t, 'Density')
bodies = [[surf]]
C._initVars(t, 'centers:cellN', 1.)

# Matrice de masquage (arbre d'assemblage)
BM = numpy.array([[1]])
t2 = X.blankCells(t, bodies, BM)            
test.testT(t2, 1)

# in place
C._initVars(t2, 'centers:cellN', 1.)
X._blankCells(t2, bodies, BM)            
test.testT(t2,1)

# masque inverse
BM = numpy.array([[-1]])
# - axisym (pyTree) -
import Generator.PyTree as G
import Converter.PyTree as C
import Geom.PyTree as D
import KCore.test as test


def F(x):
    return x


# test 1D structure (i-array) + variable en noeuds
a = D.circle((0, 0, 0), 1., 20., 60.)
C._addVars(a, 'F')
C._initVars(a, 'F', F, ['CoordinateY'])
a = D.axisym(a, (0, 0, 0), (0, 1, 0), 360., 50)
t = C.newPyTree(['Base', 2, a])
test.testT(t, 1)

# test 2D structure (i,j-array) + variable en centres
a = G.cart((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 1))
a = C.addVars(a, 'centers:F')
a = D.axisym(a, (1., 0., 0.), (0., 1., 0.), 30., 20)
t = C.newPyTree(['Base', 3, a])
test.testT(t, 2)

# test BAR-array + variable
a = D.circle((0, 0, 0), 1., 20., 60., 10)
a = C.convertArray2Tetra(a)
a = C.addVars(a, 'F')
a = C.initVars(a, 'F', F, ['CoordinateY'])
ni = 30
nj = 40
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, 2))
varsN = ['Density', 'MomentumX']
varsP = ['density', 'velocity_x']
for v in varsP:
    m = C.addVars(m, v)
m2 = P.renameVars(m, varsP, varsN)
test.testT([m2], 1)

# 2 zones with different variables
ni = 30
nj = 40
m1 = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, 2))
m2 = G.cart((10, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, 2))
m2[0] = 'cart2'
varsN = ['Density', 'MomentumX', 'centers:cellN']
varsP = ['density', 'velocity_x', 'centers:ichim']
for v in varsP:
    m1 = C.addVars(m, v)
C._addVars(m1, 'ichim')
C._addVars(m2, 'density')
C._initVars(m2, 'centers:ichim', 1.)
t = C.newPyTree(['Base', m1, m2])
t = P.renameVars(t, varsP, varsN)
test.testT(t, 2)

t = C.newPyTree(['Base', m1, m2])
P._renameVars(t, varsP, varsN)
test.testT(t, 3)
# - smooth (pyTree) -
import Transform.PyTree as T
import Geom.PyTree as D
import Converter.PyTree as C
import KCore.test as test

# TRI
a = D.sphere((0., 0., 0.), 1)
b = C.convertArray2Tetra(a)
C._addVars(b, 'Density')
C._initVars(b, 'centers:cellN', 1.)
b = T.smooth(b, eps=0.5, niter=10)
test.testT(b, 1)

# QUAD
b = C.convertArray2Hexa(a)
C._addVars(b, 'Density')
C._initVars(b, 'centers:cellN', 1.)
b = T.smooth(b, eps=0.5, niter=10)
test.testT(b, 2)
Exemple #11
0
# - homothety (pyTree) -
# traitement par zone
import Transform.PyTree as T
import Generator.PyTree as G
import Converter.PyTree as C
import KCore.test as test

# Structure 3D + champs + CL 
a = G.cart((0,0,0), (1,1,1), (10,10,3))
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,3]) 
a = T.homothety(a, (0.,0.,0.), 2.)
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 = T.homothety(a, (0.,0.,0.), 2.)
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.homothety(a, (0.,0.,0.), 2.)
test.testT(a, 3)

# HEXA