コード例 #1
0
# - sharpEdges (array) -
import Converter as C
import Generator as G
import Post as P
import Transform as T
import Geom as D
import KCore.test as test

# structure
a1 = G.cart((0., 0., 0.), (1.5, 1., 1.), (2, 2, 1))
a2 = T.rotate(a1, (0., 0., 0.), (0., 1., 0.), 100.)
A = [a1, a2]
A = C.initVars(A, 'v', 0.)
res = P.sharpEdges(A, alphaRef=45.)
test.testA(res, 1)

# QUAD
A = C.convertArray2Hexa([a1, a2])
A = C.initVars(A, 'v', 0.)
res = P.sharpEdges(A, alphaRef=45.)
test.testA(res, 2)

# HEXA
A = C.convertArray2Tetra([a1, a2])
A = C.initVars(A, 'v', 0.)
res = P.sharpEdges(A, alphaRef=45.)
test.testA(res, 3)

# 1D structure
l1 = D.line((0., 0., 0.), (1., 0., 0.))
l2 = D.line((0., 0., 0.), (0., 1., 0.))
コード例 #2
0
import Generator.PolyC1 as GP
import Generator as G
import Geom as D
import Transform as T
import KCore.test as test

# Definition de la geometrie
a = D.naca(12., 101)
a = T.reorder(a, (-1, 2, 3))

h = 0.1
hp = 0.001
density = 100.
m = GP.polyC1Mesher(a, h, hp, density)

for i in m[0]:
    v = G.getVolumeMap(i)
    min = C.getMinValue(v, 'vol')
    if (min <= 0):
        print 'negative volume detected.'
test.testA(m[0], 1)

# avec raccord coincident : critere de split de la courbure faible
m = GP.polyC1Mesher(a, h, hp, density, splitCrit=0.01)
for i in m[0]:
    v = G.getVolumeMap(i)
    min = C.getMinValue(v, 'vol')
    if (min <= 0):
        print 'negative volume detected.'
test.testA(m[0], 2)
コード例 #3
0
import Post as P
import Generator as G
import KCore.test as T


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


# cas 3D structure
ni = 30
nj = 40
nk = 3
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
m = C.initVars(m, 'ro', F, ['x', 'y'])
p = P.computeGrad(m, 'ro')  # p is defined on centers
T.testA([p], 1)

# cas 2D structure
ni = 10
nj = 20
nk = 1
m2 = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
m2 = C.initVars(m2, 'ro', F, ['x', 'y'])
p2 = P.computeGrad(m2, 'ro')  # p is defined on centers
T.testA([p2], 2)

# test sur une liste
P = P.computeGrad([m, m2], 'ro')  # p is defined on centers
T.testA(P, 3)
コード例 #4
0
# - octree2Struct (array) -
import Generator as G
import Geom as D
import KCore.test as test

# cas 3D : contours->QUAD avec liste de vmin
s = D.sphere((0,0,0), 1., N=100); snear = 0.5
res = G.octree([s], [snear], dfar=5., balancing=1)
res1 = G.octree2Struct(res, vmin=[5,7,10], ext=0)
test.testA(res1,1)
res = G.octree([s], [snear], dfar=5., balancing=1)
res1 = G.octree2Struct(res, vmin=[5,7,10], ext=0, optimized=0)
test.testA(res1,2)
#
res1 = G.octree2Struct(res, vmin=[5,7,10], ext=1)
test.testA(res1,3)
res1 = G.octree2Struct(res, vmin=[5,7,10], ext=1,optimized=0)
test.testA(res1,4)
#
res1 = G.octree2Struct(res, vmin=[5,7,10], ext=0,merged=1)
test.testA(res1,7)
# Cas equilibre
res = G.octree([s], [snear], dfar=5., balancing=1)
res1 = G.octree2Struct(res, vmin=[5,7,10], ext=0, optimized=0,merged=1)
test.testA(res1,8)
コード例 #5
0
# - expandLayer (array) -
import Generator as G
import Geom as D
import KCore.test as test

# 2D
s = D.circle((0., 0., 0.), 1., N=100)
o = G.octree([s], [0.1], dfar=1., balancing=1)
o2 = G.expandLayer(o, level=0, balancing=0)
test.testA([o2], 1)

# 3D
s = D.sphere((0., 0., 0.), 1., N=100)
o = G.octree([s], [0.1], dfar=1., balancing=1)
o2 = G.expandLayer(o, level=0, balancing=0)
test.testA([o2], 2)
# 2D
s = D.circle((0., 0., 0.), 1., N=100)
o = G.octree([s], [0.1], dfar=1., balancing=1)
o2 = G.expandLayer(o, level=0, balancing=1)
test.testA([o2], 3)
#
# 3D
s = D.sphere((0., 0., 0.), 1., N=100)
o = G.octree([s], [0.1], dfar=1., balancing=1)
o2 = G.expandLayer(o, level=0, balancing=1)
test.testA([o2], 4)
コード例 #6
0
import KCore.test as test

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

c = C.array('ro,rou, rov,row,roe,cellN', ni, nj, nk)
c = C.initVars(c, 'ro', 1.)
c = C.initVars(c, 'rou', 1.)
c = C.initVars(c, 'rov', 0.)
c = C.initVars(c, 'row', 0.)
c = C.initVars(c, 'roe', 1.)
c = C.initVars(c, 'cellN', 1)
m = C.addVars([m, c])

# Cree un maillage d'extraction non structure
a = G.cart((0., 0., 0.), (1., 0.1, 0.1), (20, 20, 1))
a = C.convertArray2Tetra(a)

# sur une liste - ordre 2 seulement
a2 = P.extractMesh([m], [a])
test.testA(a2, 1)

# Extrait la solution sur le maillage d'extraction
for i in [2, 3, 5]:
    print('Computing order %d...' % i)
    a2 = P.extractMesh([m], a, i)
    test.testA([a2], i)
コード例 #7
0
# - initVisbal -
import Generator as G
import Initiator as I
import KCore.test as test
import Converter as C

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

# Structure
a = G.cart( (0.,0.,0.), (HI,HJ,1.), (NI,NJ,2))
a = C.initVars(a, 'Density', 1.)
ac = I.initVisbal(a, (25.,25.), 2., 0.8)
test.testA([ac],1)

# Non structure
a = G.cartTetra( (0.,0.,0.), (HI,HJ,1.), (NI,NJ,2))
a = C.initVars(a, 'Density', 1.)
ac = I.initVisbal(a, (25.,25.), 2., 0.8)
test.testA([ac],2)
コード例 #8
0
# - lineGenerate (array) -
import Geom as D
import Generator as G
import KCore.test as test
import Converter as C

# 1D structure
a = D.naca(12.)
b = D.line((0, 0, 0), (0, 0., 1.))
c = D.lineGenerate(a, b)
test.testA([c], 1)

# 1D structure + champ
a = D.circle((0, 0, 0), 1)
a = C.addVars(a, 'var')
b = D.line((0, 0, 0), (0, 0., 1.))
c = D.lineGenerate(a, b)
test.testA([c], 2)

# 2D structure
a = G.cylinder((0, 0, 0), 1, 2, 360, 0, 1, (50, 21, 1))
a = C.addVars(a, 'var')
b = D.line((0, 0, 0), (0, 0., 1.))
c = D.lineGenerate(a, b)
test.testA([c], 3)

# BAR
a = D.line((0, 0, 0), (1, 0, 0), N=10)
a = C.convertArray2Tetra(a)
b = D.line((0, 0, 0), (0, 0., 1.), N=10)
c = D.lineGenerate(a, b)
コード例 #9
0
# - Extract pathological cells (uncomputable or non-star) - (array)

import Converter as C
import Intersector as XOR
import KCore.test as test

M1 = C.convertFile2Arrays('boolNG_M1.tp')
M1 = C.convertArray2NGon(M1[0])

M2 = C.convertFile2Arrays('boolNG_M2.tp')
M2 = C.convertArray2NGon(M2[0])

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.extractPathologicalCells(m, 2)  # ask for 2 level of neighgbors

test.testA(m, 1)
コード例 #10
0
# - distance2Walls (array) -
# test des types d array
import Dist2Walls
import Generator as G
import Transform as T
import KCore.test as test
import Geom as D
import Converter as C

sphere = D.sphere((0.5,0.5,0.5),0.2,20)
# sur une liste de zones
a1 = G.cart((0.,0.,0.),(0.1,0.1,0.1),(11,11,11))
dist = Dist2Walls.distance2Walls([a1], [sphere])
test.testA(dist,1)

# sur un array HEXA
a1 = G.cartHexa((0.,0.,0.),(0.1,0.1,0.1),(11,11,11))
dist = Dist2Walls.distance2Walls([a1], [sphere])
test.testA(dist,2)

# sur un array TETRA
a1 = G.cartTetra((0.,0.,0.),(0.1,0.1,0.1),(11,11,11))
dist = Dist2Walls.distance2Walls([a1], [sphere])
test.testA(dist,3)

# MIXTE
a1 = G.cart((0.,0.,0.),(0.1,0.1,0.1),(11,11,11))
a2 = G.cartHexa((1.,0.,0.),(0.1,0.1,0.1),(11,11,11))
a3 = G.cartTetra((-1.,0.,0.),(0.1,0.1,0.1),(11,11,11))
dist = Dist2Walls.distance2Walls([a1], [sphere])
test.testA(dist,4)
コード例 #11
0
# - addSeparationLine (array) -
import Geom as D
import Converter as C
import KCore.test as test

# Add a line to a circle
a1 = D.circle((0, 0, 0), 1, 0., 360, 1000)
a2 = D.line((0., 1., 0.), (0., 2., 0), 100)
a0 = D.addSeparationLine(a1, a2)
test.testA(a0, 1)

# Avec un demi cercle
a1 = D.circle((0, 0, 0), 1, 180, 360, 1000)
a2 = D.line((0., -1., 0.), (0., -2., 0), 100)
a0 = D.addSeparationLine(a1, a2)
test.testA(a0, 2)

# Avec un champ en plus
a1 = D.circle((0, 0, 0), 1, 0., 360, 1000)
a1 = C.initVars(a1, '{F}=3*{x}+{y}')
a2 = D.line((0., 1., 0.), (0., 2., 0), 100)
a2 = C.initVars(a2, '{F}=3*{x}+{y}')
a0 = D.addSeparationLine(a1, a2)
test.testA(a0, 3)
コード例 #12
0
# - cylinder2 (array) -
import Generator as G
import KCore.test as test

# Regular cylinder
r = G.cart((0., 0., 0.), (0.1, 1., 1.), (11, 1, 1))
teta = G.cart((0., 0., 0.), (0.1, 1., 1.), (11, 1, 1))
z = G.cart((0., 0., 0.), (0.1, 1., 1.), (11, 1, 1))
cyl = G.cylinder2((0., 0., 0.), 0.5, 1., 360., 0., 10., r, teta, z)
test.testA([cyl], 1)
コード例 #13
0
a = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (11, 11, 11))
sphere = D.sphere((0.5, 0.5, 0.5), 0.2, 30)
# pas de points masques
cellns = C.initVars(sphere, 'cellnf', 1.)
c = 1
for signed in [0, 1]:
    for loc in ['nodes', 'centers']:
        for type in ['mininterf', 'ortho']:
            dist = Dist2Walls.distance2Walls(a, [sphere],
                                             cellnbodies=[cellns],
                                             loc=loc,
                                             type=type,
                                             signed=signed,
                                             dim=3)
            test.testA([dist], c)
            c += 1


# la moitie de la sphere est masquee
def cellN0__(x):
    if x < 0.5: return 0.
    else: return 1.


cellns = C.initVars(cellns, 'cellN', cellN0__, ['x'])

for signed in [0, 1]:
    for loc in ['nodes', 'centers']:
        for type in ['mininterf', 'ortho']:
            dist = Dist2Walls.distance2Walls(a, [sphere],
コード例 #14
0
BM = N.array([[1]], N.int32)
t = X.blankCells(t, bodies, BM, blankingType='center_in')
t = X.setHoleInterpolatedPoints(t, depth=-2)

# Dist2Walls
t = DTW.distance2Walls(t, [s], type='ortho', loc='centers', signed=1)
t = C.center2Node(t, 'centers:TurbulentDistance')
# Gradient de distance localise en centres => normales
t = P.computeGrad(t, 'TurbulentDistance')
t = C.rmVars(t, ['TurbulentDistance'])
t = I.initConst(t, MInf=0.2, loc='centers')
tc = C.node2Center(t)
tc = X.setIBCData(t, tc, loc='centers', storage='inverse')
info = X.setInterpTransfersD(tc)
test.testO(info)
test.testA([info[0][1]], 2)
#
# variable turbulente SA
#
tc = C.initVars(tc, 'TurbulentSANuTilde', 15.)
vars = [
    'Density', 'MomentumX', 'MomentumY', 'MomentumZ',
    'EnergyStagnationDensity', 'TurbulentSANuTilde'
]
info = X.setInterpTransfersD(tc, bcType=0, varType=11, variablesIBC=vars)
test.testO(info, 3)
test.testA([info[0][1]], 4)

info = X.setInterpTransfersD(tc, bcType=1, varType=11, variablesIBC=vars)
test.testO(info, 5)
test.testA([info[0][1]], 6)
コード例 #15
0
m = C.initVars(m, 'rou', 1.)
m = C.initVars(m, 'rov', F, ['x'])
m = C.initVars(m, 'row', 0.)

# 2D
s1 = G.cart((0,0,0), (9./(ni-1),9./(nj-1),1), (ni,nj,1))
s2 = G.cart((5.5,0,0), (9./(ni-1),9./(nj-1),1), (ni,nj,1))
s = [s1,s2]
s = C.initVars(s, 'rou', 1.)
s = C.initVars(s, 'rov', F, ['x'])
s = C.initVars(s, 'row', 0.)

# 3D struct
x0 = 0.1; y0 = 5.; z0 = 0.
p = P.streamLine(m, (x0,y0,z0),['rou','rov','row'])
test.testA([p], 1)

# 2D struct
x0 = 5.; y0 = 5.; z0 = 0.
p = P.streamLine(s, (x0,y0,z0),['rou','rov','row'] , N=200)
test.testA([p], 2)
    
# 3D non struct
m2 = C.convertArray2Tetra(m)
p = P.streamLine(m2,(x0,y0,z0),['rou','rov','row'])
test.testA([p], 3)

# 2D non struct
s2 = C.convertArray2Tetra(s)
p = P.streamLine(s2, (x0,y0,z0),['rou','rov','row'])
test.testA([p], 4)
コード例 #16
0
# - makeCartesian (array) -
import Generator as G
import Transform as T
import KCore.test as test
a = G.cart((0., 0., 0.), (1., 1., 1.), (10, 10, 10))
a = T.reorder(a, (3, 2, -1))
a = T.makeCartesianXYZ(a)
test.testA([a])
コード例 #17
0
import Generator as G
import Converter as C
import Geom as D
import KCore.test as test

# Tests sans lissage

d = C.array('d', 3, 1, 1)
d[1][0, 0] = 0.1
d[1][0, 1] = 0.2
d[1][0, 2] = 0.3

# Structured (i,j-array)
a = D.sphere((0, 0, 0), 1, 50)
a = G.addNormalLayers(a, d)
test.testA([a], 1)

# Structured (i,j-array) avec champ
a = D.sphere((0, 0, 0), 1, 50)
a = C.initVars(a, 'Density', 1.)
a = G.addNormalLayers(a, d)
test.testA([a], 11)

# Unstructured (TRI)
a = D.sphere((0, 0, 0), 1, 50)
a = C.convertArray2Tetra(a)
a = G.addNormalLayers(a, d)
a = C.convertArray2Tetra(a)
test.testA([a], 2)

# Unstructured (TRI) avec champ
コード例 #18
0
# - stitchedHat (array) -
import Geom as D
import Generator as G
import Transform as T
import KCore.test as test

c = D.circle((0, 0, 0), 1., 360., 0., 100)
c = T.contract(c, (0, 0, 0), (0, 1, 0), (0, 0, 1), 0.1)
c = G.stitchedHat(c, (0, 0, 0), 1.e-4)
test.testA([c], 1)
コード例 #19
0
ファイル: F_t1.py プロジェクト: MicK7/cassiopee_anaconda
# - F (array) -
import Converter as C
import Generator as G
import KCore.test as test


def F(x):
    return x


# Structure 1D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 1, 1))
a = C.initVars(a, 'F={x}+{y}')
b = F(a)
test.testA([b], 1)

# Structure 2D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 1))
a = C.initVars(a, 'F={x}+{y}')
b = F(a)
test.testA([b], 2)

# Structure 3D
a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10))
a = C.initVars(a, 'F={x}+{y}')
b = F(a)
test.testA([b], 3)

# BAR
a = G.cartTetra((0, 0, 0), (1, 1, 1), (10, 1, 1))
a = C.initVars(a, 'F={x}+{y}')
コード例 #20
0
import KCore.test as test

# Donor mesh structure
ni = 21
nj = 21
nk = 21
m = G.cart((0, 0, 0), (1. / (ni - 1), 1. / (nj - 1), 1. / (nk - 1)),
           (ni, nj, nk))
hook = C.createGlobalHook([m], function='nodes')
sol = C.initVars(m, '{ro}={x}')
sol = C.extractVars(sol, ['ro'])

# RCV Structure
a = D.sphere((0, 0, 0), 0.1)
a2 = C.identifySolutions(a, sol, hook, tol=1000.)
test.testA([a2], 1)
# RCV TRI
a1 = C.convertArray2Tetra(a)
a2 = C.identifySolutions(a1, sol, hook, tol=1000.)
test.testA([a2], 2)
# RCV NGON
a1 = C.convertArray2NGon(a)
a2 = C.identifySolutions(a1, sol, hook, tol=1000.)
test.testA([a2], 3)
#
C.freeHook(hook)
#
# Dnrs: list of zones
#
ni = 21
nj = 21
コード例 #21
0
# - cartNGon (array) -
import Generator as G
import Converter as C
import KCore.test as test

# 1D
a = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.1), (11, 1, 1))
test.testA([a], 1)
a = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.1), (1, 11, 1))
test.testA([a], 2)
a = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.1), (1, 1, 11))
test.testA([a], 3)
# 2D
a = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.1), (11, 11, 1))
test.testA([a], 4)
a = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.1), (11, 1, 11))
test.testA([a], 5)
a = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.1), (1, 11, 11))
test.testA([a], 6)
# 3D
a = G.cartNGon((0., 0., 0.), (0.1, 0.1, 0.1), (11, 11, 11))
test.testA([a], 7)
test.writeCoverage(100)
コード例 #22
0
import Converter as C
import Connector as X
import Generator as G
import Geom as D
import KCore.test as test

# 2D QUAD
s = D.circle((0, 0, 0), 1., N=100)
snear = 0.1
res = G.octree([s], [snear], dfar=5.)
res = C.initVars(res, 'cellN', 1.)
ca = C.extractVars(res, ['cellN'])
res = C.extractVars(res, ['x', 'y', 'z'])
celln = X.blankCells([res], [ca], [s], blankingType=0, delta=0.)
res2 = C.addVars([res, celln[0]])
test.testA([res2], 1)

# 3D HEXA
s = D.sphere((0, 0, 0), 1., N=100)
snear = 0.1
res = G.octree([s], [snear], dfar=5.)
res = C.initVars(res, 'cellN', 1.)
ca = C.extractVars(res, ['cellN'])
res = C.extractVars(res, ['x', 'y', 'z'])
celln = X.blankCells([res], [ca], [s], blankingType=0, delta=0.)
res = C.addVars([res, celln[0]])
test.testA([res], 2)

# 2D TRI
s = D.circle((0, 0, 0), 1., N=100)
snear = 0.1
コード例 #23
0
# - enforceh (array) -
import Geom as D
import Transform as T
import Converter as C
import KCore.test as test

# broken line (STRUCT)
a = D.line((0, 0, 0), (1, 0, 0), N=10)
D.setF(a, 0, 1.)
D.setF(a, -1, 0.5)
b = D.line((1, 0, 0), (2, 1, 0), N=50)
D.setF(b, 0, 0.5)
D.setF(b, -1, 1.)
a = T.join([a, b])
a = D.enforceh(a, h=0.05)
test.testA([a], 1)
#C.convertArrays2File(a, 'out.plt')

# fourche (BAR)
a = D.line((0, 0, 0), (1, 0, 0), N=10)
D.setH(a, 0, 0.1)
D.setH(a, -1, 0.01)
b = D.line((1, 0, 0), (2, 1, 0), N=50)
D.setH(b, 0, 0.01)
D.setH(b, -1, 0.1)
c = D.line((1, 0, 0), (2, -1, 0), N=100)
D.setH(c, 0, 0.01)
D.setH(c, -1, 0.1)
A = [a, b, c]
A = C.convertArray2Hexa(A)
a = T.join(A)
コード例 #24
0
m = G.cart((0,0,0), (10./(ni-1),10./(nj-1),1), (ni,nj,2))
c = C.array('ro,rou,rov,row,roE', ni, nj, 2)
c = C.initVars(c, 'ro', 1.)
c = C.initVars(c, 'rou', 1.)
c = C.initVars(c, 'rov', 0.)
c = C.initVars(c, 'row', 0.)
c = C.initVars(c, 'roE', 1.)
m = C.addVars([m,c])
A = [m]
vars = ['Pressure', 'Mach', 'Entropy', 'Enthalpy',
        'VelocityX', 'VelocityY', 'VelocityZ',
        'Temperature', 'ViscosityMolecular', 
        'PressureStagnation', 'TemperatureStagnation',
        'PressureDynamic']
sol = P.computeVariables(m, vars)
test.testA([sol], 1)

# test sur une liste 
ni = 20; nj = 10
m = G.cart((0,0,0), (5./(ni-1),10./(nj-1),1), (ni,nj,2))
c = C.array('ro,rou, rov,row,roE', ni, nj, 2)
c = C.initVars(c, 'ro', 1.)
c = C.initVars(c, 'rou', 1.)
c = C.initVars(c, 'rov', 0.)
c = C.initVars(c, 'row', 0.)
c = C.initVars(c, 'roE', 1.)
m = C.addVars([m,c])
A.append(m)
vars = ['Pressure', 'Mach']
sol = P.computeVariables(A, vars)
test.testA(sol, 2)
コード例 #25
0
# - interiorFaces (array) -
import Converter as C
import Post as P
import Generator 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))
b = P.interiorFaces(a)
test.testA([b], 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))
b = P.interiorFaces(a, 1)
test.testA([b], 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))
b = P.interiorFaces(a, 1)
if (b[1].shape[1] != 0):
    print 'FAILED...'
コード例 #26
0
import KCore.test as test

LOCAL = test.getLocal()

# Create test meshes
cart1 = G.cart((0, 0, 0), (0.1, 0.2, 1.), (11, 11, 2))
cart2 = G.cartTetra((0, 0, 0), (0.1, 0.2, 1.), (11, 11, 2))
cart3 = G.cartTetra((0, 0, 0), (0.1, 0.2, 1.), (11, 11, 1))
cart4 = G.cartNGon((0, 0, 0), (1, 1, 1), (10, 10, 10))
l1 = D.line((0, 0, 50), (1, 1, 50))
l2 = D.line((0, 0, 1), (1, 1, 1))

# bin_tp
C.convertArrays2File([cart1, cart2], LOCAL + '/out.plt', 'bin_tp')
A = C.convertFile2Arrays(LOCAL + '/out.plt', 'bin_tp')
test.testA(A, 1)

# fmt_tp
C.convertArrays2File([cart1], LOCAL + '/out.tp', 'fmt_tp')
A = C.convertFile2Arrays(LOCAL + '/out.tp', 'fmt_tp')
test.testA(A, 2)

# fmt_tp
C.convertArrays2File([cart1, cart2, cart4], LOCAL + '/out.tp', 'fmt_tp')
A = C.convertFile2Arrays(LOCAL + '/out.tp', 'fmt_tp')
test.testA(A, 21)

# fmt_tp
C.convertArrays2File([cart1],
                     LOCAL + '/out.tp',
                     'fmt_tp',
コード例 #27
0
# - setHoleInterpolatedPts (array) -
import Converter as C
import Connector as X
import Generator as G
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.


# Cas TETRA: champ cellN en noeud
a = G.cartHexa((-2., -1., -1.), (0.1, 0.1, 0.1), (21, 21, 21))
a = C.initVars(a, 'cellN', sphere, ['x', 'y', 'z'])
nod = 1
for d in [-2, -1, 0, 1, 2, 5]:
    celln = X.setHoleInterpolatedPoints(a, depth=d)
    test.testA([celln], nod)
    nod += 1
#
# Champ en centres
#
a = G.cartHexa((-2., -1., -1.), (0.1, 0.1, 0.1), (21, 21, 21))
ac = C.node2Center(a)
ac = C.initVars(ac, 'cellN', sphere, ['x', 'y', 'z'])
for d in [-2, -1, 0, 1, 2, 5]:
    celln = X.setHoleInterpolatedPoints(ac, depth=d)
    test.testA([celln], nod)
    nod += 1
コード例 #28
0
a = G.cart((0, 0, 0), (1, 1, 1), (ni, nj, nk))
a = C.addVars(a, "F")
a = C.initVars(a, "F", 1.)
a = C.addVars(a, "Q")
a = C.initVars(a, "Q", 1.01)

b = G.cart((0, 0, 0), (1, 1, 1), (ni, nj, nk))
b = C.addVars(b, "F")
b = C.initVars(b, "F", 2.)
b = C.addVars(b, "Q")
b = C.initVars(b, "Q", 1.03)
b = C.addVars(b, "R")
b = C.initVars(b, "R", 1.12)

ret = C.diffArrays([a], [b])
T.testA(ret, 1)

# Test avec des coordonnees differentes
a = G.cart((0.2, 0.3, 0), (1, 1, 1), (ni, nj, nk))
a = C.addVars(a, "F")
a = C.initVars(a, "F", 1.)
a = C.addVars(a, "Q")
a = C.initVars(a, "Q", 1.01)

b = G.cart((0, 0, 0), (1, 1, 1), (ni, nj, nk))
b = C.addVars(b, "F")
b = C.initVars(b, "F", 2.)
b = C.addVars(b, "Q")
b = C.initVars(b, "Q", 1.03)

ret = C.diffArrays([a], [b])
コード例 #29
0
# - TFIO (array) -
import Converter as C
import Generator as G
import Geom as D
import KCore.test as test

a = D.circle((0, 0, 0), 1., N=41)
r = G.TFIO(a)
test.testA(r, 1)
コード例 #30
0
# - splitTBranches (array) -
import Converter as C
import Generator as G
import Transform as T
import KCore.test as test
a = G.cylinder((0.,0.,0.), 0.5, 1., 360., 0., 10., (50,1,50))
c1 = T.subzone(a,(1,1,1),(50,1,1))
c2 = T.subzone(a,(1,1,50),(50,1,50))
c3 = T.subzone(a,(1,1,1),(1,1,50))
c = [c1,c2,c3]; c = C.convertArray2Hexa(c)
c = T.join(c)
C._initVars(c, 'F', 1.)
res = T.splitTBranches(c)
test.testA(res)