# - getProc (pyTree) -
import Generator.PyTree as G
import Distributor2.PyTree as D2
import KCore.test as test

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
a = D2.addProcNode(a, 12)
proc = D2.getProc(a)
test.testO(proc, 1)
# - getFamilyBCNamesOfType (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

a = G.cart((0., 0., 0), (0.01, 0.01, 1.), (20, 20, 2))
b = G.cart((1., 0., 0), (0.01, 0.01, 1.), (20, 20, 2))

a = C.addBC2Zone(a, 'walla', 'FamilySpecified:CARTER', 'imin')
a = C.addBC2Zone(a, 'nref', 'FamilySpecified:LOIN', 'imax')
b = C.addBC2Zone(b, 'wallb', 'FamilySpecified:CARTER', 'jmin')

t = C.newPyTree(['Base'])
t[2][1][2] += [a, b]

t[2][1] = C.addFamily2Base(t[2][1], 'CARTER', bndType='BCWall')
t[2][1] = C.addFamily2Base(t[2][1], 'LOIN', bndType='BCFarfield')

# Toutes les familyBCs de type BCwall
names1 = C.getFamilyBCNamesOfType(t, 'BCWall')
# Toutes les familyBCs de l'arbre
names2 = C.getFamilyBCNamesOfType(t)
test.testO([names1, names2], 1)
예제 #3
0
# - getFamilyBCNamesDict (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import KCore.test as test

a = G.cart((0., 0., 0), (0.01, 0.01, 1.), (20, 20, 2))
b = G.cart((1., 0., 0), (0.01, 0.01, 1.), (20, 20, 2))

a = C.addBC2Zone(a, 'walla', 'FamilySpecified:CARTER', 'imin')
b = C.addBC2Zone(b, 'wallb', 'FamilySpecified:CARTER', 'jmin')

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

C._addFamily2Base(t[2][1], 'CARTER', bndType='BCWall')

# Toutes les familyBCs
dict = C.getFamilyBCNamesDict(t)
test.testO(dict)
예제 #4
0
import Post.PyTree as P
import KCore.test as test

# 2D
ni = 30
nj = 40
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, 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', 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, 1)

# 1D
ni = 30
m = G.cart((0, 0, 0), (10. / (ni - 1), 1, 1), (ni, 1, 1))
m = C.initVars(m, 'vx', 1.)
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')
b = G.cartNGon((4, 2, 1), (1., 1., 1.), (5, 8, 1))
b[0] = 'cart2'
c = G.cartNGon((4, 9, 1), (1., 1., 1.), (4, 5, 1))
c[0] = 'cart3'

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

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

varL = ['H']

zones = Internal.getZones(t)
it = 0

for z in zones:
    dim = Internal.getZoneDim(z)
    gcs = Internal.getNodesFromType2(z, 'GridConnectivity_t')

    for gc in gcs:
        it = it + 1
        zname = Internal.getValue(gc)
        zdonor = Internal.getNodeFromName(t, zname)

        [indFaceR, fldFace] = CP.extractBCMatch(zdonor, gc, dim, varL)
        test.testO([indFaceR, fldFace], it)
# - getDistantIndex (PyTree)-
import Geom.PyTree as D
import KCore.test as test
import Converter.PyTree as C

a = D.naca(12., 5001)
l = D.getLength(a)
l2 = D.getDistantIndex(a, 1, l / 10.)
test.testO(l2, 1)
예제 #7
0
# - getVarNames (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))
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin')
a = C.addVars(a, ['Density', 'centers:cellN'])
val = C.getVarNames(a)
test.testO(val, 1)

# Sur un arbre
b = C.addVars(a, ['Density', 'centers:cellN'])
b[0] = 'cart2'
t = C.newPyTree(['Base'])
t[2][1][2] += [a, b]
t[2][1] = C.addState(t[2][1], 'Mach', 0.6)
val = C.getVarNames(t)
test.testO(val, 2)

# Sur une liste de zones
val = C.getVarNames([a, b])
test.testO(val, 3)
예제 #8
0
a = G.cylinder((0, 0, 0), 1., 3., 360, 0, 1, (200, 30, 4))
a[0] = 'cylindre1'
C._addBC2Zone(a, 'wall1', 'BCWall', 'jmin')
C._addBC2Zone(a, 'ov1', 'BCOverlap', 'jmax')
b = G.cylinder((4, 0, 0), 1., 3., 360, 0, 1, (200, 30, 4))
b[0] = 'cylindre2'
C._addBC2Zone(b, 'wall1', 'BCWall', 'jmin')
C._addBC2Zone(b, 'ov1', 'BCOverlap', 'jmax')
t = C.newPyTree(['Corps1', 'Corps2'])
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._initVars(t, 'F', 0.)
C._initVars(t, 'centers:G', 1.)
t = X.applyBCOverlaps(t, depth=1)
t1 = X.setInterpolations(t, loc='cell', storage='direct')
X._chimeraInfo(t1, type='interpolated')
X._chimeraInfo(t1, type='extrapolated')
X._chimeraInfo(t1, type='orphan')
interpPts = X.extractChimeraInfo(t1, type='interpolated', loc='centers')
test.testT(interpPts, 1)
extrapPts = X.extractChimeraInfo(t1, type='extrapolated', loc='centers')
test.testT(extrapPts, 2)
cfExtrapPts = X.extractChimeraInfo(t1, type='cf>1.5', loc='centers')
test.testO(cfExtrapPts, 3)
orphanPts = X.extractChimeraInfo(t1, type='orphan', loc='centers')
test.testT(orphanPts, 4)
예제 #9
0
# - getMaxValue (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
maxval = C.getMaxValue(a, 'CoordinateX')
test.testO(maxval, 1)
# test sur une liste de zones
maxval = C.getMaxValue([a, b], 'CoordinateX')
test.testO(maxval, 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)
maxval = C.getMaxValue(t, 'CoordinateX')
test.testO(maxval, 3)
예제 #10
0
# - getParentOfNode (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), (10, 10, 10))
t = C.newPyTree(['Base'])
t[2][1][2].append(a)

# from tree
(p, c) = Internal.getParentOfNode(t, a)
test.testO([p, c], 1)

# from list
(p, c) = Internal.getParentOfNode([a], a)
test.testO(p, 2)
# - getNodesFromType (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), (10, 10, 10))
t = C.newPyTree(['Base'])
t[2][1][2].append(a)

zones = Internal.getNodesFromType(t, 'Zone_t')
test.testO(zones, 1)
# - 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)

# - getNearestPointIndex (array) -
import Generator as G
import Converter as C
import Geom as D
import KCore.test as test

a = G.cart((0.,0.,0.), (0.1,0.1,0.2),(10,10,1))
inds = D.getNearestPointIndex(a, (0.54,0.34,0))
test.testO(inds, 1)
inds = D.getNearestPointIndex(a, [(0.54,0.34,0), (1,1,1)])
test.testO(inds, 2)
a2 = G.cart((2.,0.,0.), (0.1,0.1,0.2),(10,10,1))
inds = D.getNearestPointIndex([a,a2], [(0.54,0.34,0), (1,1,1)])
test.testO(inds, 3)
예제 #14
0
# - copyNode (pyTree) -
import Converter.PyTree as C
import Converter.Internal as Internal
import Generator.PyTree as G
import KCore.test as test

a = Internal.newDataArray(value=[1, 2, 3])
# Copy only the numpy of this node
b = Internal.copyNode(a)
# Modify numpy of b
b[1][0] = 5
test.testO([a, b], 1)
# - getZoneType (pyTree) -
import Generator.PyTree as G
import Converter.Internal as Internal
import KCore.test as test

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
type = Internal.getZoneType(a)
test.testO(type, 1)

a = G.cartTetra((0, 0, 0), (1, 1, 1), (10, 10, 10))
type = Internal.getZoneType(a)
test.testO(type, 2)
예제 #16
0
# - getNCells (array2) -
import Converter as C
import KCore.test as test

a = C.array('x,y,z', 2, 2, 2, api=2)
n = C.getNCells(a)
test.testO(n, 1)

a = C.array('x,y,z', 12, 4, 'HEXA', api=2)
n = C.getNCells(a)
test.testO(n, 2)
예제 #17
0
# - sortByName (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), (10, 10, 10))
a[0] = 'b'
b = G.cart((12, 0, 0), (1, 1, 1), (10, 10, 10))
b[0] = 'a'
t = C.newPyTree(['Base', a, b])
t = Internal.sortByName(t)
test.testO(t, 1)
t = C.newPyTree(['Base', a, b])
Internal._sortByName(t)
test.testO(t, 1)
예제 #18
0
# - autoSetContainers (pyTree) -
import Converter.PyTree as C
import Converter.Internal as Internal
import Generator.PyTree as G
import KCore.test as test

a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
Internal.__FlowSolutionCenters__ = 'FlowSolution#EndOfRun'
C._initVars(a, 'F={CoordinateX}')
C._initVars(a, 'centers:G={CoordinateY}')
Internal.__FlowSolutionCenters__ = 'FlowSolution#Centers'
t = C.newPyTree(['Base', a])
Internal.autoSetContainers(t)
test.testO([Internal.__FlowSolutionNodes__, Internal.__FlowSolutionCenters__])
예제 #19
0
# - checkPointInCEBB (array) -
import Generator as G
import Transform as T
import KCore.test as test

Ni = 20
Nj = 20
a2 = G.cart((-0.1, 0, 0), (0.5 / Ni, 0.5 / Nj, 1), (Ni, Nj, 2))
a2 = T.rotate(a2, (-0.1, 0, 0), (0, 0, 1), 0.22)
val = G.checkPointInCEBB(a2, (0.04839, 0.03873, 0.5))
test.testO(val, 1)
# - getSizeOf (pyTree) -
import Generator.PyTree as G
import Converter.Internal as Internal
import KCore.test as test

a = G.cart((0,0,0), (1,1,1), (10,10,10))
mem = Internal.getSizeOf(a)
test.testO(mem)

예제 #21
0
# - test de base sur mpi4py -
import KCore.test as test
try: from mpi4py import MPI
except: raise ImportError, 'FAILED mpi4py'

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
print rank, size
test.testO([rank, size], 1)

try: import Converter.Mpi as Cmpi
except: raise ImportError, 'FAILED Cmpi'

rank = Cmpi.rank
size = Cmpi.size
print rank, size
test.testO([rank, size], 2)
예제 #22
0
# - setValue (pyTree) -
import Converter.Internal as Internal
import KCore.test as test
import numpy

node = Internal.createNode('node1', 'DataArray_t', value=12.)

# Set a scalar value in node
Internal.setValue(node, 1.)
test.testO(node, 1)

# Set a numpy array in node
Internal.setValue(node, numpy.zeros(10))
test.testO(node, 2)

# Set an array as a list
Internal.setValue(node, [1., 12., 13.])
test.testO(node, 3)

# Set a string
Internal.setValue(node, 'toto')
test.testO(node, 4)

# Set a list of strings
Internal.setValue(node, ['toto', 'tata'])
test.testO(node, 5)
예제 #23
0
# - getPathsFromType (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), (10, 10, 10))
t = C.newPyTree(['Base', a])

# Return nodes with given value
paths = Internal.getPathsFromType(t, 'Zone_t')
print(paths)
test.testO(paths, 1)
paths = Internal.getPathsFromType(t, 'DataArray_t')
print(paths)
test.testO(paths, 2)
예제 #24
0
# - getBCs (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,2))
a = C.addBC2Zone(a, 'overlap', 'BCOverlap', 'imin')
a = C.addBC2Zone(a, 'match1', 'BCMatch', 'jmin', a, 'jmax', [1,2,3])
a = C.fillEmptyBCWith(a, 'wall', 'BCWall', dim=2)
(BCs,BCNames,BCTypes) = C.getBCs(a)
test.testO(BCNames, 1)

a = G.cartHexa((0,0,0),(1,1,1),(10,10,2))
a = C.addBC2Zone(a, 'wall', 'BCWall', faceList=[1,2])
(BCs,BCNames,BCTypes) = C.getBCs(a)
test.testO(BCNames, 2)

a = G.cartNGon((0,0,0),(1,1,1),(10,10,2))
a = C.addBC2Zone(a, 'wall', 'BCWall', faceList=[1,2])
(BCs,BCNames,BCTypes) = C.getBCs(a)
test.testO(BCNames, 3)



# - getNodesFromName (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), (10,10,10) )
t = C.newPyTree(['Base']); t[2][1][2].append(a)

nodes = Internal.getNodesFromName(t, 'cart')
test.testO(nodes, 1)

nodes = Internal.getNodesFromName(t, 'Coordinate*')
test.testO(nodes, 2)
예제 #26
0
# - checkPyTree (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Connector.PyTree as X
import Converter.Internal as Internal
import KCore.test as test

a = G.cart( (0,0,0), (1,1,1), (10,10,10) )
b = G.cart( (9,0,0), (1,1,1), (10,10,10) )
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'imin')
t = C.newPyTree(['Base']); t[2][1][2] += [a,b]
t = X.connectMatch(t)

# check nodes conformity
errors = Internal.checkPyTree(t, level=1)
# check unique base names
errors += Internal.checkPyTree(t, level=2)
# check unique zone names
errors += Internal.checkPyTree(t, level=3)
# check unique BC names
errors += Internal.checkPyTree(t, level=4)
# check BC ranges
errors += Internal.checkPyTree(t, level=5)
# check opposite ranges
errors += Internal.checkPyTree(t, level=6)
# check family definition
errors += Internal.checkPyTree(t, level=7)
# check types
errors += Internal.checkPyTree(t, level=8)
test.testO(errors, 1)
# - 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)
# - computeGraph (pyTree) -
import Converter.PyTree as C
import Converter.Mpi as Cmpi
import Distributor2.PyTree as Distributor2
import Generator.PyTree as G
import Connector.PyTree as X
import KCore.test as test

# Through BBox
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
b = G.cart((8, 0, 0), (1, 1, 1), (10, 10, 10))
t = C.newPyTree(['Base', a, b])
(t, dic) = Distributor2.distribute(t, NProc=2, algorithm='fast')
tb = Cmpi.createBBoxTree(t)
graph = Cmpi.computeGraph(tb, type='bbox')
if Cmpi.rank == 0: test.testO(graph, 1)

# Through match
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
b = G.cart((9, 0, 0), (1, 1, 1), (10, 10, 10))
t = C.newPyTree(['Base'])
t[2][1][2] += [a, b]
t = X.connectMatch(t)
(t, dic) = Distributor2.distribute(t, NProc=2, algorithm='fast')
graph = Cmpi.computeGraph(t, type='match')
if Cmpi.rank == 0:
    test.testO(graph, 2)

# Donor mesh
ni = 11
nj = 11
nk = 11
m = G.cartNGon((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
C._initVars(m, '{F}={CoordinateX}+2*{CoordinateY}+3*{CoordinateZ}')
C._initVars(m, '{G}=10*{CoordinateX}')
C._initVars(m, 'centers:G', 1.)
# Receiver mesh
a = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
a[0] = 'extraction'
C._initVars(a, 'F', -1000.)
C._initVars(a, 'G', -1000.)

# 2nd order, nodes, direct storage
t = C.newPyTree(['Rcv', 'Dnr'])
t[2][1][2] = [a]
t[2][2][2] = [m]
C._initVars(t[2][1], 'cellN', 2)
t[2][2] = X.setInterpData(t[2][1],
                          t[2][2],
                          loc='nodes',
                          storage='inverse',
                          order=2,
                          method='leastsquares')
info = X.setInterpTransfersD(t[2][2])
test.testO(info)
test.testA([info[0][1]], 2)
예제 #30
0
# - CEBBIntersection (array) -
import Generator as G
import Converter as C
import Transform as T
import KCore.test as test

ni = 11
nj = 3
nk = 11
a1 = G.cart((0., 0., 0.), (0.1, 0.1, 0.2), (ni, nj, nk))
a2 = G.cart((1., 0., 0.), (0.1, 0.1, 0.2), (ni, nj, nk))
a2 = T.rotate(a2, (0, 0, 0), (0, 0, 1), 12.)
res = G.CEBBIntersection(a1, a2)
test.testO(res, 1)

a2 = T.translate(a2, (-0.1, -0.1, 0))
res = G.CEBBIntersection(a1, a2)
test.testO(res, 2)