Пример #1
0
def setHoleInterpolatedPoints():
    if CTK.t == []: return
    CTK.saveTree()
    depth = VARS[7].get()
    depth = int(depth)
    CTK.t = X.setHoleInterpolatedPoints(CTK.t, depth=depth)
    CTK.TXT.insert('START', 'cellN variable modified near holes.\n')
    CTK.TKTREE.updateApp()
    CTK.display(CTK.t)
Пример #2
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')
Пример #3
0
import Initiator.PyTree as I
import KCore.test as test
import sys

a = G.cart((-1, -1, -1), (0.04, 0.04, 1), (51, 51, 3))
s = G.cylinder((0, 0, -1), 0, 0.4, 360, 0, 4, (30, 30, 5))
s = C.convertArray2Tetra(s)
s = T.join(s)
s = P.exteriorFaces(s)
t = C.newPyTree(['Base'])
t[2][1][2] = [a]
# Blanking
bodies = [[s]]
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 = I.initConst(t, MInf=0.2, loc='centers')
tc = C.node2Center(t)
t = X.setIBCData(t, tc, loc='centers', storage='direct')

#test avec arbre tc compact
zones = Internal.getNodesFromType2(t, 'Zone_t')
X.miseAPlatDonnorTree__(zones, t, procDict=None)

t2 = X.setInterpTransfers(t, tc, bcType=0, varType=1)
test.testT(t2, 1)

#
# Champ en noeuds non structure PENTA
#
a = G.cartPenta((-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)
    test.testT(t2, nod)
    nod += 1

# Champ cellN en centres
a = G.cartPenta((-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]:
Пример #5
0
    else: return 1.


#
# Champ en noeuds non structure HEXA
#
a = G.cartHexa((-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', 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.cartHexa((-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', 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]:
    t2 = X.setHoleInterpolatedPoints(t, depth=d, loc='centers')
Пример #6
0
def transferCellN__(t, tc, DEPTH, loc):
    if tc is None: return t
    try:
        import Connector.PyTree as X
    except:
        raise ImportError(
            "Dist2Walls: Eikonal version requires Connector module.")
    # POINTS EXTERIEURS
    # Marquage des pts de front entre du 0 et du 1
    t = X.setHoleInterpolatedPoints(t, depth=DEPTH, loc=loc)
    # transfert du cellN aux raccords
    if tc is not None:
        C._cpVars(t, loc + ':cellN', tc, 'cellN')
        for zc in Internal.getNodesFromType2(tc, "Zone_t"):
            if C.getMaxValue(zc, 'cellN') == 2.:
                X._setInterpTransfers(t, zc, variables=["cellN"])
    if loc == 'nodes':
        C._initVars(t, "cellN=({cellN}>1.5)*2.+({cellN}>0.)*({cellN}<1.5)")
        C._initVars(t, 'cellN = 1-{cellN}+({cellN}>1.5)*3')
    else:
        C._initVars(
            t,
            "centers:cellN=({centers:cellN}>1.5)*2.+({centers:cellN}>0.)*({centers:cellN}<1.5)"
        )
        C._initVars(
            t, 'centers:cellN = 1-{centers:cellN}+({centers:cellN}>1.5)*3')
    t = X.setHoleInterpolatedPoints(t, depth=DEPTH, loc=loc)
    if loc == 'nodes':
        C._initVars(t, 'cellN = 1-{cellN}+({cellN}>1.5)*3')
        C._initVars(t, 'cellN2={cellN}')
    else:
        C._initVars(
            t, 'centers:cellN = 1-{centers:cellN}+({centers:cellN}>1.5)*3')
        C._initVars(t, 'centers:cellN2={centers:cellN}')

    # POINTS INTERIEURS
    if loc == 'nodes': C._initVars(t, 'cellN=minimum(1.,{cellN})')
    else: C._initVars(t, 'centers:cellN=minimum(1.,{centers:cellN})')

    t = X.setHoleInterpolatedPoints(t, depth=-DEPTH, loc=loc)
    # transfert du cellN aux raccords
    if tc is not None:
        C._cpVars(t, loc + ':cellN', tc, 'cellN')
        for zc in Internal.getNodesFromType2(tc, "Zone_t"):
            if C.getMaxValue(zc, 'cellN') == 2.:
                X._setInterpTransfers(t, zc, variables=["cellN"])
    if loc == 'nodes':
        C._initVars(t, "cellN=({cellN}>1.5)*2.+({cellN}>0.)*({cellN}<1.5)")
        C._initVars(t, 'cellN = 1-{cellN}+({cellN}>1.5)*3')
    else:
        C._initVars(
            t,
            "centers:cellN=({centers:cellN}>1.5)*2.+({centers:cellN}>0.)*({centers:cellN}<1.5)"
        )
        C._initVars(
            t, 'centers:cellN = 1-{centers:cellN}+({centers:cellN}>1.5)*3')
    t = X.setHoleInterpolatedPoints(t, depth=-DEPTH, loc=loc)
    if loc == 'nodes':
        C._initVars(t, 'cellN = 1-{cellN}+({cellN}>1.5)*3')
        C._initVars(t, 'cellN=maximum({cellN},{cellN2})')
        C._rmVars(t, ['cellN2'])
    else:
        C._initVars(
            t, 'centers:cellN = 1-{centers:cellN}+({centers:cellN}>1.5)*3')
        C._initVars(t,
                    'centers:cellN=maximum({centers:cellN},{centers:cellN2})')
        C._rmVars(t, ['centers:cellN2'])
    return t
Пример #7
0
def sphere(x,y,z):
    if x*x+y*y+z*z < 0.5**2 : return 0.
    else: return 1.

# Cas structure
# Champ cellN en noeud
a = G.cart((-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 = X.connectMatch(t)
t = C.fillEmptyBCWith(t,'nref','BCFarfield')
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,dir=1)
    test.testT(t2,nod); nod+=1

#
# Champ en centres
#
a = G.cart((-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 = X.connectMatch(t)
t = C.fillEmptyBCWith(t,'nref','BCFarfield')
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]:
    t2 = X.setHoleInterpolatedPoints(t,depth=d,dir=1)