Beispiel #1
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')
# - getAllIBMPoints (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Connector.ToolboxIBM as IBM
import Post.PyTree as P
import Converter
import KCore.test as test
N = 21
a = G.cart((0, 0, 0), (1, 1, 1), (N, N, N))
C._initVars(a, '{centers:TurbulentDistance}={centers:CoordinateZ}')
C._initVars(
    a,
    '{centers:cellN}=({centers:CoordinateZ}>0.8)*1.+({centers:CoordinateZ}<0.8)*2.'
)
a = P.computeGrad(a, 'centers:TurbulentDistance')
res = IBM.getAllIBMPoints(a, loc='centers', hi=0., he=2., tb=None)
correctedPts = list(res[0].values())[0]
wallPts = list(res[1].values())[0]
interpPts = list(res[2].values())[0]
test.testA(correctedPts + wallPts)
test.testA(interpPts, 12)
N = 21
a = G.cart((0, 0, 0), (1, 1, 1), (N, N, N))
C._initVars(a, '{TurbulentDistance}={CoordinateZ}')
C._initVars(a, '{cellN}=({CoordinateZ}>0.8)*1.+({CoordinateZ}<0.8)*2.')
a = P.computeGrad(a, 'TurbulentDistance')
a = C.center2Node(a, 'FlowSolution#Centers')
res = IBM.getAllIBMPoints(a, loc='nodes', hi=0., he=2., tb=None)
correctedPts = list(res[0].values())[0]
wallPts = list(res[1].values())[0]
interpPts = list(res[2].values())[0]
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 = 21
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)
res = IBM.extractIBMInfo(tc)
test.testT(res,1)
# CAS 2D
N = 21
a = G.cart((0,0,0),(1./(N-1),1./(N-1),1./(N-1)),(N,N,2))
body = D.circle((0.5,0,0),0.1)
t = C.newPyTree(['Base',a])
tb = C.newPyTree(['Base',body])
tb = C.addState(tb, 'EquationDimension',2)
tb = C.addState(tb, 'GoverningEquations', 'NSTurbulent')
t = DTW.distance2Walls(t,bodies=tb,loc='centers',type='ortho',dim=2)
t = P.computeGrad(t,'centers:TurbulentDistance')
t,tc=IBM.prepareIBMData(t,tb,DEPTH=2)
res = IBM.extractIBMInfo(tc)
test.testT(res,2)
s = G.close(s)
t = C.newPyTree(['Base', a])

# Blanking
bodies = [[s]]
BM = numpy.array([[1]], numpy.int32)
t = X.blankCells(t, bodies, BM, blankingType='center_in')
t = X.setHoleInterpolatedPoints(t, depth=-2)
# Dist2Walls
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')
I._initConst(t, MInf=0.2, loc='centers')
tc = C.node2Center(t)

tb = C.newPyTree(['Base', s])
C._addState(tb, 'EquationDimension', 3)
C._addState(tb, 'GoverningEquations', 'NSTurbulent')

tp = X.setIBCData(t, tc, loc='centers', storage='direct', bcType=0)
t2 = X.setInterpTransfers(tp, tc, bcType=0, varType=1)
z = IBM.extractIBMWallFields(t2, tb=tb)
test.testT(z, 1)

#
tp = X.setIBCData(t, tc, loc='centers', storage='direct', bcType=3)
t2 = X.setInterpTransfers(tp, tc, bcType=3, varType=1)
z = IBM.extractIBMWallFields(t2, tb=tb)
test.testT(z, 2)
import Converter.PyTree as C
import Dist2Walls.PyTree as DTW
import Generator.PyTree as G
import Geom.PyTree as D
import Connector.PyTree as X
import Transform.PyTree as T
import Connector.ToolboxIBM as TIBM

N = 11
N2 = 2 * N - 1
h = 1. / (N - 1)
a = G.cart((-1., -1., -1.), (h, h, h), (N2, N2, 2))
zmean = C.getMeanValue(a, 'CoordinateZ')
surf = D.sphere((0, 0, zmean), 0.5, 20)
t = C.newPyTree(['Cart', a])
C.convertPyTree2File(surf, "in.cgns")
bodies = [[surf]]
# Matrice de masquage (arbre d'assemblage)
import numpy

BM = numpy.array([[1]])
C._initVars(t, 'centers:cellN', 1.)
t = X.blankCells(t, bodies, BM, blankingType='center_in', delta=0.)
DTW._distance2Walls(t, surf, loc='centers', type='ortho')
C._initVars(t, "{centers:F}={centers:cellN}")
TIBM._blankClosestTargetCells(t)
C.convertPyTree2File(t, 'out.cgns')
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 = 21
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)
tb = C.newPyTree(['Base', body])
C._addState(tb, 'EquationDimension', 3)
C._addState(tb, 'GoverningEquations', 'NSTurbulent')
t = C.newPyTree(['Base', a])
DTW._distance2Walls(t, bodies=tb, loc='centers', type='ortho')
C._initVars(t, 'centers:cellN', 1.)
t, tc = IBM.prepareIBMData(t, tb, DEPTH=2, frontType=0, interpDataType=1)
res = IBM.extractIBMInfo(tc)
test.testT(tc, 1)

# front 1
tb = C.newPyTree(['Base', body])
C._addState(tb, 'EquationDimension', 3)
C._addState(tb, 'GoverningEquations', 'NSTurbulent')
DTW._distance2Walls(t, bodies=tb, loc='centers', type='ortho')
C._initVars(t, 'centers:cellN', 1.)
t, tc = IBM.prepareIBMData(t, tb, DEPTH=2, frontType=1, interpDataType=1)
test.testT(tc, 12)

# front2
t = C.newPyTree(['Base', a])
tb = C.newPyTree(['Base', body])
Beispiel #7
0
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 = 21
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])
C._addState(tb, 'EquationDimension', 3)
C._addState(tb, 'GoverningEquations', 'NSTurbulent')
DTW._distance2Walls(t, bodies=tb, loc='centers', type='ortho')
t = P.computeGrad(t, 'centers:TurbulentDistance')
t, tc = IBM.prepareIBMData(t, tb, DEPTH=2, frontType=0)
res = IBM.extractIBMInfo(tc)
test.testT(res, 1)

# CAS 2D
N = 21
a = G.cart((0, 0, 0), (1. / (N - 1), 1. / (N - 1), 1. / (N - 1)), (N, N, 2))
body = D.circle((0.5, 0, 0), 0.1)
t = C.newPyTree(['Base', a])
tb = C.newPyTree(['Base', body])
C._addState(tb, 'EquationDimension', 2)
C._addState(tb, 'GoverningEquations', 'NSTurbulent')
DTW._distance2Walls(t, bodies=tb, loc='centers', type='ortho', dim=2)
t = P.computeGrad(t, 'centers:TurbulentDistance')
t, tc = IBM.prepareIBMData(t, tb, DEPTH=2, frontType=0)
res = IBM.extractIBMInfo(tc)
import Initiator.PyTree as I
import Converter.Internal as Internal
import Connector.ToolboxIBM as IBM
import KCore.test as test
import numpy
N = 41
a = G.cart((0, 0, 0), (1. / (N - 1), 1. / (N - 1), 1. / (N - 1)), (N, N, N))
xm = 0.5 * N / (N - 1)
s = D.sphere((xm, xm, xm), 0.1, N=20)
s = C.convertArray2Tetra(s)
s = G.close(s)
t = C.newPyTree(['Base'])
t[2][1][2] = [a]

# Blanking
bodies = [[s]]
BM = numpy.array([[1]], numpy.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)
t2 = X.setIBCData(t, tc, loc='centers', storage='direct')
t2 = X.setInterpTransfers(t2, tc, bcType=0, varType=1)
z = IBM.extractIBMWallFields(t2)
C.convertPyTree2File(z, "out.cgns")