a = D.sphere6((0, 0, 0), 0.5, N=20) dk = G.cart((0, 0, 0), (0.01, 1, 1), (11, 1, 1)) a = G.addNormalLayers(a, dk) t = C.newPyTree(['Base']) t[2][1][2] = a t = X.connectMatch(t, dim=3) t = Internal.addGhostCells(t, t, d, adaptBCs=1) #--------- # Centers #--------- t = C.initVars(t, 'centers:F=0.') tc = C.node2Center(t) tc = C.initVars(tc, 'F={CoordinateX}*{CoordinateY}') # stockage direct t1 = X.setInterpDataForGhostCells__(t, tc, storage='direct', loc='centers') t1 = X.setInterpTransfers(t1, tc, variables=['F']) test.testT(t1, 1) # stockage inverse tc1 = X.setInterpDataForGhostCells__(t, tc, storage='inverse', loc='centers') t1 = X.setInterpTransfers(t, tc1, variables=['F']) test.testT(t1, 2) #--------- # Nodes #--------- # noeuds, stockage direct t = C.rmVars(t, ['centers:F']) t = C.initVars(t, 'F=0.') td = C.initVars(t, 'F={CoordinateX}*{CoordinateY}') t1 = X.setInterpDataForGhostCells__(t, td, storage='direct', loc='nodes') t1 = X.setInterpTransfers(t1, td, variables=['F'])
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 t = C.newPyTree(['Rcv', 'Dnr']) t[2][1][2] = [a]
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) test.testT(t2, 2) # # variable turbulente SA # t = C.initVars(t, 'centers:TurbulentSANuTilde', 100.) tc = C.initVars(tc, 'TurbulentSANuTilde', 15.) vars = [ 'Density', 'MomentumX', 'MomentumY', 'MomentumZ', 'EnergyStagnationDensity', 'TurbulentSANuTilde' ]
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)
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') no = 1 for bcType in xrange(4): for varType in xrange(1,4): t2 = X.setInterpTransfers(t,tc,bcType=bcType,varType=varType) test.testT(t2,no) no+=1 # Stockage inverse Internal._rmNodesByName(t,"IBCD_*") tc = X.setIBCData(t, tc, loc='centers', storage='inverse') for bcType in xrange(4): for varType in xrange(1,4): X._setInterpTransfers(t,tc,bcType=bcType,varType=varType) test.testT(tc,no) no += 1
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")
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') t1 = C.newPyTree(['Base']) t1[2][1][2] = [a] t2 = C.newPyTree(['Base']) t2[2][1][2] = [b] t1 = C.fillEmptyBCWith(t1, 'nref', 'BCFarfield') t2 = C.fillEmptyBCWith(t2, 'nref', 'BCFarfield') t1 = C.initVars(t1, '{Density}= 1.') t2 = C.initVars(t2, '{Density}=-1.') t2 = C.node2Center(t2, ['Density']) t2 = X.applyBCOverlaps(t2, depth=1) t1 = X.setInterpData(t2, t1, double_wall=1, loc='centers', storage='inverse', order=3) t2 = X.setInterpTransfers(t2, t1, variables=['Density']) C.convertPyTree2File(t2, 'out.cgns')