示例#1
0
def compute():
    if CTK.t == []: return

    nzs = CPlot.getSelectedZones()
    if nzs == []:
        CTK.TXT.insert('START', 'Selection is empty.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
        return

    surf = 0
    walls = []
    name = VARS[1].get()
    if name == '': names = []
    else: names = name.split(';')
    for v in names:
        surf = 1
        v = v.lstrip()
        v = v.rstrip()
        sname = v.split('/', 1)
        bases = Internal.getNodesFromName1(CTK.t, sname[0])
        if bases != []:
            nodes = Internal.getNodesFromType1(bases[0], 'Zone_t')
            for z in nodes:
                if z[0] == sname[1]: walls.append(z)

    if surf == 0:
        walls = C.extractBCOfType(CTK.t, 'BCWall')
        walls += C.extractBCOfType(CTK.t, 'BCWallViscous')
        walls += C.extractBCOfType(CTK.t, 'BCWallInviscid')

    tp = C.newPyTree(['Base'])
    for nz in nzs:
        nob = CTK.Nb[nz] + 1
        noz = CTK.Nz[nz]
        z = CTK.t[2][nob][2][noz]
        tp[2][1][2].append(z)

    try:
        if (VARS[2].get() == 'absolute'): signed = 0
        else: signed = 1
        tp = DTW.distance2Walls(tp,
                                walls,
                                type=VARS[0].get(),
                                loc=VARS[3].get(),
                                signed=signed)
        c = 0
        for nz in nzs:
            nob = CTK.Nb[nz] + 1
            noz = CTK.Nz[nz]
            CTK.t[2][nob][2][noz] = tp[2][1][2][c]
            c += 1
        #C._fillMissingVariables(CTK.t)
        CTK.TKTREE.updateApp()
        CTK.display(CTK.t)
        CTK.TXT.insert('START', 'Distance to walls computed.\n')
    except Exception as e:
        Panels.displayErrors([0, str(e)], header='Error: dist2Walls')
        CTK.TXT.insert('START', 'Distance to walls failed.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
示例#2
0
def initWallDistance():
    if CTK.t == []: return
    bodies = C.extractBCOfType(CTK.t, 'BCWall')
    for c in range(len(bodies)):
        try: bodies[c] = C.node2ExtCenter(bodies[c])
        except: pass
    tb = C.newPyTree(['Base', 2]); tb[2][1][2] += bodies
    CTK.saveTree()
    try:
        CTK.t = DW.distance2Walls(CTK.t, tb, loc='centers', type='ortho')
        CTK.TXT.insert('START', 'Distance to wall computed.\n')
    except Exception as e:
        Panels.displayErrors([0,str(e)], header='Error: wallDistance')
        CTK.TXT.insert('START', 'Wall distance fails.\n')
        CTK.TXT.insert('START', 'Error: ', 'Error')
    CTK.TKTREE.updateApp()
    CTK.display(CTK.t)
示例#3
0
# - prepareIBMData (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Connector.ToolboxIBM as IBM
import Post.PyTree as P
import Geom.PyTree as D
import Dist2Walls.PyTree as DTW
import KCore.test as test
N = 51
a = G.cart((0, 0, 0), (1. / (N - 1), 1. / (N - 1), 1. / (N - 1)), (N, N, N))
body = D.sphere((0.5, 0, 0), 0.1, N=20)
t = C.newPyTree(['Base', a])
tb = C.newPyTree(['Base', body])
tb = C.addState(tb, 'EquationDimension', 3)
tb = C.addState(tb, 'GoverningEquations', 'NSTurbulent')
t = DTW.distance2Walls(t, bodies=tb, loc='centers', type='ortho')
t = P.computeGrad(t, 'centers:TurbulentDistance')
t, tc = IBM.prepareIBMData(t, tb, DEPTH=2, frontType=1)
C.convertPyTree2File(t, 't.cgns')
C.convertPyTree2File(t, 'tc.cgns')
示例#4
0
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)

t2 = X.setInterpTransfers(t, tc, bcType=1, varType=1)
# - distance2Walls (pyTree) -
# - Dump TurbulentDistance node to a file -
import Dist2Walls.PyTree as DW
import Generator.PyTree as G
import Converter.PyTree as C
import Geom.PyTree as D
import Converter.Internal as Internal
import Converter
import numpy

a = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (10, 10, 10))
a = C.initVars(a, 'centers:cellnf', 1.)
sphere = D.sphere((1.2, 0., 0.), 0.2, 100)
sphere = C.initVars(sphere, 'centers:cellnf', 1.)

t = C.newPyTree(['Base', a])
bodies = C.newPyTree(['Bodies', sphere])
t = DW.distance2Walls(t, bodies)
nodes = Internal.getNodesFromName(t, 'TurbulentDistance')
c = 0
for n in nodes:
    ni = n[1].shape[0]
    nj = n[1].shape[1]
    nk = n[1].shape[2]
    a = numpy.reshape(n[1], (ni * nj * nk), order='Fortran')
    a = numpy.reshape(a, (1, ni * nj * nk))
    array = ['walldistance', a, ni, nj, nk]
    array = Converter.initVars(array, 'wallglobalindex', 1)
    Converter.convertArrays2File([array], 'dist' + str(c) + '.v3d', 'bin_v3d')
    c += 1
示例#6
0
# - distance2Walls (pyTree) -
# - Dump TurbulentDistance node to a file -
import Dist2Walls.PyTree as DW
import Generator.PyTree as G
import Converter.PyTree as C
import Geom.PyTree as D
import Converter.Internal as Internal
import Converter
import numpy
import KCore.test as test

a = G.cart((0.,0.,0.),(0.1,0.1,0.1),(10,10,10))
a = C.initVars(a,'centers:cellnf',1.)
sphere = D.sphere((1.2,0.,0.),0.2,100)
sphere = C.initVars(sphere,'centers:cellnf',1.)

t = C.newPyTree(['Base',a])
bodies = C.newPyTree(['Bodies',sphere])
t = DW.distance2Walls(t, bodies,loc='centers')
nodes = Internal.getNodesFromName(t, 'TurbulentDistance')
dists = []
for n in nodes:
    ni = n[1].shape[0]; nj = n[1].shape[1]; nk = n[1].shape[2]
    a = numpy.reshape(n[1], (ni*nj*nk), order='Fortran')
    a = numpy.reshape(a, (1,ni*nj*nk))
    array = ['walldistance', a, ni, nj, nk]
    array = Converter.initVars(array, 'wallglobalindex', 1)
    dists.append(array)

test.testA(dists, 1)
# - distance2Walls (pyTree) -
import Dist2Walls.PyTree as Dist2Walls
import Generator.PyTree as G
import Converter.PyTree as C
import Converter.Internal as Internal
import Geom.PyTree as D
import Converter.elsAProfile as elsAProfile

a = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (10, 10, 10))
sphere = D.sphere((1.2, 0., 0.), 0.2, 100)
t = C.newPyTree(['Base', a])
t = Dist2Walls.distance2Walls(t, sphere)
Internal._renameNode(t, 'FlowSolution#Centers', 'FlowSolution#Init')
tp = elsAProfile.addTurbulentDistanceIndex(t)
C.convertPyTree2File(tp, 'out.cgns')
示例#8
0
# - Calcul de distance a la paroi en distribue -
import Converter.PyTree as C
import Distributor2.PyTree as Distributor2
import Converter.Mpi as Cmpi
import Transform.PyTree as T
import Dist2Walls.PyTree as Dist2Walls

rank = Cmpi.rank
size = Cmpi.size

# lecture des parois
bodies = C.convertFile2PyTree('walls.cgns')

# lecture du squelette
a = Cmpi.convertFile2SkeletonTree('in.cgns')

# equilibrage
(a, dic) = Distributor2.distribute(a, NProc=size, algorithm='fast', useCom=0)

# load des zones locales dans le squelette
a = Cmpi.readZones(a, 'in.cgns', proc=rank)

# Passage en arbre partiel
a = Cmpi.convert2PartialTree(a)

# Calcul des distances a la paroi
a = Dist2Walls.distance2Walls(a, bodies, type='mininterf')

# Reconstruit l'arbre complet a l'ecriture
Cmpi.convertPyTree2File(a, 'out.cgns')
import Geom.PyTree as D

# Body structured, celln aux centres
sphere = D.sphere((0.5,0.5,0.5), 0.2, 50)
sphere = C.initVars(sphere, 'centers:cellnf', 1.)
bodies = C.newPyTree(['Bodies',2,sphere])

a = G.cart((0.,0.,0.),(0.1,0.1,0.1),(11,11,11))
# --- champ aux noeuds
a = C.initVars(a, 'Density', 0.5)
# --- champ aux centres
a = C.initVars(a, 'Pressure', 0.7)
t = C.newPyTree(['Base', a])
# --- Equation state
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
t2 = DW.distance2Walls(t, bodies, type='mininterf', loc='centers')
test.testT(t2,1)

# Body structured, celln aux noeuds
sphere = D.sphere((0.5,0.5,0.5), 0.2, 50)
sphere = C.initVars(sphere,'cellnf', 1.)
bodies = C.newPyTree(['Bodies',2,sphere])

a = G.cart((0.,0.,0.),(0.1,0.1,0.1),(11,11,11))
# --- champ aux noeuds
a = C.initVars(a, 'Density', 0.5)
# --- champ aux centres
a = C.initVars(a, 'Pressure', 0.7)
t = C.newPyTree(['Base',a])
# --- Equation state
t[2][1] = C.addState(t[2][1], 'EquationDimension', 3)
示例#10
0
t = C.newPyTree(['Base'])
t[2][1][2] = m
t = C.initVars(t, 'centers:cellN', 1.)
#
# Get the wall surfaces
#
walls = C.extractBCOfType(t, 'BCWall')
walls += C.extractBCOfType(t, 'BCWallViscous')
walls += C.extractBCOfType(t, 'BCWallInviscid')

# Convert the wall border to centers
bodies = C.node2Center(walls)
#
# Computes the distance field
#
t = DTW.distance2Walls(t, bodies, loc='centers', type='mininterf')
#
# Write the distance files for elsA
#

nodes = Internal.getNodesFromName(t, 'TurbulentDistance')
c = 0
for n in nodes:
    ni = n[1].shape[0]
    nj = n[1].shape[1]
    nk = n[1].shape[2]
    a = numpy.reshape(n[1], (ni * nj * nk), order='Fortran')
    a = numpy.reshape(a, (1, ni * nj * nk))
    array = ['walldistance', a, ni, nj, nk]
    array = Converter.initVars(array, 'wallglobalindex', 1)
    Converter.convertArrays2File([array], 'dist' + str(c) + '.v3d', 'bin_v3d')