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, 3) )
b = G.cylinder( (0,0,0), 1, 2, 3, 160, 1, (30, 20, 3) )
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])
b = C.addBC2Zone(b, 'wall', 'BCWall', 'jmin')
#b = C.addBC2Zone(b, 'wall', 'FamilySpecified:SKN', 'jmin') 
b = C.addBC2Zone(b, 'overlap', 'BCOverlap', 'imin')
b = C.addBC2Zone(b, 'overlap', 'BCOverlap', 'imax')
t = C.newPyTree(['Base','Base2']); t[2][1][2] = [a]; t[2][2][2] = [b]
t = C.fillEmptyBCWith(t,'nref','BCFarfield')
t = C.initVars(t,'Density',1.); t = C.initVars(t,'centers:G',10.)
t[2][1] = C.addState(t[2][1], 'EquationDimension',2)

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

t1 = X.applyBCOverlaps(t, depth=2)
t1 = C.center2Node(t1,['centers:cellN'])
t1[2][2] = X.setInterpData(t1[2][2],t1[2][1], double_wall=1, loc='nodes')
test.testT(t1,2)    

t1 = X.applyBCOverlaps(t, depth=1) 
t1[2][2] = X.setInterpData(t1[2][2],t1[2][1], double_wall=1, loc='faces')
test.testT(t1,3)
Beispiel #2
0
ni = 11
nj = 11
nk = 11
m = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
m = C.initVars(m, 'F', F, ['CoordinateX', 'CoordinateY', 'CoordinateZ'])
m = 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'

# 2nd order, centers, direct storage
t = C.newPyTree(['Rcv', 'Dnr'])
t[2][1][2] = [a]
t[2][2][2] = [m]
t[2][1] = C.initVars(t[2][1], '{centers:cellN}=2')
t[2][1] = X.setInterpData(t[2][1], t[2][2], loc='centers', storage='direct')
t[2][1] = C.initVars(t[2][1], 'centers:F', 0.)
t[2][1] = X.setInterpTransfers(t[2][1], t[2][2], variables=['F'])
test.testT(t, 1)

# 2nd order, centers, inverse storage
t = C.newPyTree(['Rcv', 'Dnr'])
t[2][1][2] = [a]
t[2][2][2] = [m]
t[2][1] = C.initVars(t[2][1], '{centers:cellN}=2')
t[2][2] = X.setInterpData(t[2][1], t[2][2], loc='centers', storage='inverse')
t[2][1] = C.initVars(t[2][1], 'centers:F', 0.)
t[2][1] = X.setInterpTransfers(t[2][1], t[2][2], variables=['F'])
test.testT(t, 2)

# 2nd order, nodes, direct storage, sans variables en entree
Beispiel #3
0
# - setInterpData (pyTree) - 
# case without cellN field: the whole receiver zone is interpolated
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

# Tetra donor zone
a = G.cartTetra((0,0,-0.2),(0.01,0.01,0.1),(101,101,5))
pts = D.circle((0.5,0.5,0),0.05,N=20)
C._initVars(pts, 'cellN', 2); C._initVars(pts, 'centers:cellN',2) 
# options to combine
notest = 1
for location in ['nodes', 'centers']:
    for stk in ['direct', 'indirect']:
        for pen in [0,1]:
            for nat in [0,1]:
                for order in [2,3,5]:
                    pts2 = X.setInterpData(pts, a, order=order, penalty=pen,
                                           nature=nat, loc=location, 
                                           storage=stk, hook=None)
                    test.testT(pts2, notest)
                    notest += 1
Beispiel #4
0
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import KCore.test as test

# Donor
zD = G.cart((0.,0.,0.), (0.1,0.1,0.1), (11,11,11))
C._initVars(zD,'centers:cellN',1.)

# Receptor
zR = G.cart((0.25,0.25,0.25), (0.1,0.1,0.1), (5,5,5))
C._initVars(zR,'{centers:cellN}=2.*({centers:CoordinateX}<1.)')
zR=X.setInterpData(zR, zD, order=2, penalty=1, nature=0, method='conservative', hook=None, dim=3, loc='centers',itype='chimera')   
test.testT(zR,1)
#
zD=X.setInterpData(zR, zD, order=2, penalty=1, nature=0, method='conservative', hook=None, dim=3, loc='centers',itype='chimera',storage='inverse')   
test.testT(zD,2)
# case without cellN field: the whole receiver zone is interpolated
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

# Structured zone
a = G.cart((0, 0, -0.2), (0.01, 0.01, 0.1), (101, 101, 5))
pts = D.circle((0.5, 0.5, 0), 0.05, N=20)
pts = C.initVars(pts, 'cellN=2')
pts = C.initVars(pts, 'centers:cellN=2')

# options to combine
notest = 1
for location in ['nodes', 'centers']:
    for stk in ['direct', 'indirect']:
        for pen in [0, 1]:
            for nat in [0, 1]:
                for order in [2, 3, 5]:
                    pts2 = X.setInterpData(pts, a, order=order, penalty=pen, \
                                               nature=nat, loc=location, \
                                               storage=stk)
                    test.testT(pts2, notest)
                    notest += 1

# le cas 'faces' n'est pas encore disponible pour tt le champ
pts2 = X.setInterpData(pts, a, loc='faces')
test.testT(pts2, notest)
notest += 1
Beispiel #6
0
# - setInterpolation (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Connector.PyTree as X

a = G.cylinder((0,0,0),1.,3.,360,0,1,(200,30,2)); 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,2)); 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,2))
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=2)
t = X.applyBCOverlaps(t, depth=1)
t[2][2:] = X.setInterpData(t[2][1], t[2][2:], loc='centers', storage='inverse')
C.convertPyTree2File(t, "out.cgns")
Beispiel #7
0
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._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')
import Connector.PyTree as X
import Generator.PyTree as G

a = G.cylinder( (0,0,0), 1, 2, 0, 360, 1, (60, 20, 3) )
b = G.cylinder( (0,0,0), 1, 2, 3, 160, 1, (30, 10, 3) )
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])
b = C.addBC2Zone(b, 'wall', 'BCWall', 'jmin')
b = C.addBC2Zone(b, 'overlap', 'BCOverlap', 'imin')
b = C.addBC2Zone(b, 'overlap', 'BCOverlap', 'imax')
tD = C.newPyTree(['Base']); tD[2][1][2] = [a]; 
tR = C.newPyTree(['Base']); tR[2][1][2] = [b]
tD = C.fillEmptyBCWith(tD, 'nref', 'BCFarfield')
tR = C.fillEmptyBCWith(tR, 'nref', 'BCFarfield')

tD = C.initVars(tD, '{Density}=1.')
tD = C.initVars(tD, '{cellN}=1.')
tD = C.initVars(tD, '{MomentumX}= -0.1')
tD = C.initVars(tD, '{MomentumY}= -0.2')

tR = C.initVars(tR, '{centers:Density}=-1.')
tR = C.initVars(tR, '{centers:cellN}=1.')
tR = C.initVars(tR, '{centers:MomentumX}=0.1')
tR = C.initVars(tR, '{centers:MomentumY}=0.2')
tR = X.applyBCOverlaps(tR, depth=1) 
tD = X.setInterpData(tR, tD, double_wall=1, loc='centers',
                     storage='inverse', order=3)
info = X.setInterpTransfersD(tD,variables=['MomentumX'])
print info
# - getOversetInfo (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Connector.PyTree as X

a = G.cylinder((0, 0, 0), 1., 3., 360, 0, 1, (200, 30, 4))
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, 4))
b[0] = 'cylindre2'
b = C.addBC2Zone(b, 'wall1', 'BCWall', 'jmin')
b = C.addBC2Zone(b, 'ov1', 'BCOverlap', 'jmax')
c = G.cart((-5., -7.5, -2), (15. / 200, 15. / 200, 1), (200, 200, 8))
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=3)
t = C.fillEmptyBCWith(t, 'nref', 'BCFarfield', dim=3)
t = X.applyBCOverlaps(t, depth=1, loc='centers')
t[2][1][2] = X.setInterpData(t[2][1][2],
                             t,
                             loc='centers',
                             storage='direct',
                             sameName=1)
t = X.getOversetInfo(t, t, loc='centers', type='interpolated')
t = X.getOversetInfo(t, t, loc='centers', type='orphan')
C.convertPyTree2File(t, "out.cgns")
Beispiel #10
0
# - setInterpData (pyTree) - 
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

# 2D structured donor zone 
a = G.cart((0,0,0.),(0.01,0.01,0.1),(101,101,1))
pts = D.circle((0.5,0.5,0),0.05,N=20)
C._initVars(pts, 'cellN', 2); C._initVars(pts, '{centers:cellN}=2')
pts2 = X.setInterpData(pts, a, order=2,storage='direct',loc='nodes')
test.testT(pts2,1)
pts2 = X.setInterpData(pts, a, order=2,storage='direct',loc='centers')
test.testT(pts2,2)
# - setInterpData (pyTree) -
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

# Tetra donor zone
a = G.cartTetra((0, 0, -0.2), (0.01, 0.01, 0.1), (101, 101, 5))
points = D.circle((0.5, 0.5, 0), 0.05, N=20)
points = C.convertArray2Tetra(points)

# Receiver 'BAR'
pts = C.initVars(points, 'cellN', 2)  # interpole tout
pts2 = X.setInterpData(pts, a, loc='nodes')
test.testT(pts2, 1)

pts = C.initVars(points, 'centers:cellN', 2)  # interpole tout
pts2 = X.setInterpData(pts, a, loc='centers')
test.testT(pts2, 2)

# Receiver 'NODE'
pts = C.initVars(points, 'cellN', 2)  # interpole tout
pts = C.convertArray2Node(pts)
pts2 = X.setInterpData(pts, a, loc='nodes')
test.testT(pts2, 3)
nj = 11
nk = 11
m = G.cartTetra((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk))
C._initVars(m, 'F', F, ['CoordinateX', 'CoordinateY', 'CoordinateZ'])
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'

# 2nd order, nodes, direct storage
t = C.newPyTree(['Rcv', a, 'Dnr', m])
t[2][1] = C.initVars(t[2][1], 'cellN', 2)  # tag pour interpoler tous les pts
t[2][1] = X.setInterpData(t[2][1],
                          t[2][2],
                          loc='nodes',
                          storage='direct',
                          order=2)
t[2][1] = C.initVars(t[2][1], 'F', 0.)
t[2][1] = X.setInterpTransfers(t[2][1], t[2][2], variables=['F'])
t[2][1] = C.rmVars(t[2][1], 'cellN')
test.testT(t, 1)
#
t = C.newPyTree(['Rcv', a, 'Dnr', m])
C._initVars(t[2][1], 'centers:cellN', 2)  # tag pour interpoler tous les pts
t[2][1] = X.setInterpData(t[2][1],
                          t[2][2],
                          loc='centers',
                          storage='direct',
                          order=2)
t[2][1] = C.rmVars(t[2][1], ['F'])
Beispiel #13
0
    deg = 1
    if deg == 0 : return 10.
    elif deg == 1 : return x + 2.*y + 3.*z
    elif deg == 2 : return x*x + 2.*y*y + 3*z
    elif deg == 3 : return x*x*y + 2.*y*y*y + 3*z
    elif deg == 4 : return x*x*x*x + 2.*y*y*y*y +z*z
    else : return 2*x*x*x*x*x + 2.*y*y*z + z*z
 
# Donor mesh 
ni = 11; nj = 11; nk = 11
m = G.cartNGon((0,0,0), (10./(ni-1),10./(nj-1),1), (ni,nj,nk))
m = C.initVars(m, 'F', F, ['CoordinateX','CoordinateY','CoordinateZ'])
m = 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'

# 2nd order, nodes, direct storage
t = C.newPyTree(['Rcv','Dnr']); t[2][1][2] = [a]; t[2][2][2] = [m]
t[2][1] = C.initVars(t[2][1], 'cellN=2')
t[2][1] = X.setInterpData(t[2][1],t[2][2],loc='nodes',storage='direct',order=2,method='leastsquares')
t[2][1] = C.initVars(t[2][1],'F',0.)
t[2][1] = X.setInterpTransfers(t[2][1],t[2][2],variables=['F'])
test.testT(t,1)

t = C.deleteChimeraInfo__(t)
t[2][1] = C.initVars(t[2][1], 'centers:cellN=2')
t[2][1] = X.setInterpData(t[2][1],t[2][2],loc='centers',storage='direct',order=2,method='leastsquares')
t[2][1] = C.initVars(t[2][1],'centers:F',0.)
t[2][1] = X.setInterpTransfers(t[2][1],t[2][2],variables=['F'])
test.testT(t,2)
Beispiel #14
0
# - dist2WallsEikonal (pyTree) -
import Converter.PyTree as C
import Connector.PyTree as X
import Converter.Internal as Internal
import Dist2Walls.PyTree as DTW
import Geom.PyTree as D
import Generator.PyTree as G
import numpy

DEPTH = 2
snear = 0.4; vmin = 21

# Init wall
body = D.circle((0,0,0),1.,N=60)
res = G.octree([body],[snear], dfar=5., balancing=1)
res = G.octree2Struct(res, vmin=vmin, ext=DEPTH+1,merged=1)
t = C.newPyTree(['Base']); t[2][1][2] = res

# Mark solid and fluid points
t = X.applyBCOverlaps(t,depth=DEPTH,loc='nodes')
tc = Internal.copyRef(t)
tc = X.setInterpData(t,tc,loc='nodes',storage="inverse")
C._initVars(t,"cellN",1.)
t = X.blankCells(t, [[body]], numpy.array([[1]]), blankingType='node_in')
t = X.setHoleInterpolatedPoints(t,depth=1,loc='nodes')
C._initVars(t,'flag=({cellN}>1.)')
t = DTW.distance2WallsEikonal(t,body,tc=tc,DEPTH=DEPTH,nitmax=10)
C.convertPyTree2File(t, 'out.cgns')
Beispiel #15
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)

# 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)
# - setInterpData (pyTree)-
# cas structure 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, 3) )
b = G.cylinder( (0,0,0), 1, 2, 3, 160, 1, (30, 20, 3) )
C._addBC2Zone(a, 'wall', 'FamilySpecified:SKN1', 'jmin') 
C._addBC2Zone(a, 'match', 'BCMatch', 'imin', a, 'imax', trirac=[1,2,3])
C._addBC2Zone(a, 'match', 'BCMatch', 'imax', a, 'imin', trirac=[1,2,3])
C._addBC2Zone(b, 'wall', 'BCWall', 'jmin')
C._addBC2Zone(b, 'wall', 'FamilySpecified:SKN2', 'jmin') 
C._addBC2Zone(b, 'overlap', 'BCOverlap', 'imin')
C._addBC2Zone(b, 'overlap', 'BCOverlap', 'imax')
t = C.newPyTree(['Base',a,'Base2',b])
C._fillEmptyBCWith(t,'nref','BCFarfield')
C._initVars(t,'Density',1.); C._initVars(t,'centers:G',10.)
C._addState(t[2][1], 'EquationDimension',2)
C._addFamily2Base(t[2][1], 'SKN1', bndType="BCWall") 
C._addFamily2Base(t[2][2], 'SKN2', bndType="BCWall") 

t1 = X.applyBCOverlaps(t, depth=2) 
t1[2][2] = X.setInterpData(t1[2][2],t1[2][1], double_wall=0,loc='centers')
test.testT(t1,1)