import Converter.PyTree as C import Generator.PyTree as G import Post.PyTree as P import Converter.Internal as Internal import KCore.test as test # z2 sans solutions z1 = G.cart((0., 0., 0.), (0.1, 0.1, 0.1), (3, 3, 3)) C._addBC2Zone(z1, 'overlap', 'BCOverlap', 'imin') C._fillEmptyBCWith(z1, 'nref', 'BCFarfield') t1 = C.newPyTree(['Base', z1]) t2 = Internal.copyRef(t1) C._initVars(t1, 'centers:cellN', 1.) C._initVars(t1, 'Pressure', 10.) C._initVars(t1, 'Density', 1.) C._addState(t1[2][1], 'Mach', 0.6) C._addState(t2[2][1], 'Mach', 0.6) t2 = P.importVariables(t1, t2) test.testT(t2, 1) # z2 avec cellN = 0 C._initVars(t2, 'centers:cellN', 0.) t2 = P.importVariables(t1, t2) test.testT(t2, 2) # z1 en centres avec z2 sans solution Internal._rmNodesByType(t2, 'FlowSolution_t') t1 = C.node2Center(t1) t2 = P.importVariables(t1, t2) test.testT(t2, 3)
# - addState (pyTree) - import Converter.PyTree as C import Generator.PyTree as G a = G.cylinder((0, 0, 0), 1., 1.5, 0., 360., 1., (80, 30, 2)) t = C.newPyTree(['Base', a]) # Specifie un etat de reference adimensionne par: # Mach, alpha, Re, MutSMu, TurbLevel (adim1) C._addState(t, adim='adim1', MInf=0.5, alphaZ=0., alphaY=0., ReInf=1.e8, MutSMuInf=0.2, TurbLevelInf=1.e-4) # Specifie un etat de reference adimensionne par: # Mach, alpha, Re, MutSMu, TurbLevel (adim2) C._addState(t, adim='adim2', MInf=0.5, alphaZ=0., alphaY=0., ReInf=1.e8, MutSMuInf=0.2, TurbLevelInf=1.e-4) # Specifie un etat de reference dimensionne par: # U, T, P, L, MutSMu, TurbLevel (dim1)
# - getState (pyTree) - import Converter.PyTree as C import Generator.PyTree as G a = G.cylinder((0, 0, 0), 1., 1.5, 0., 360., 1., (80, 30, 2)) t = C.newPyTree(['Base', a]) # Specifie un etat de reference adimensionne par: # Mach, alpha, Re, MutSMu, TurbRate (adim1) C._addState(t, adim='adim1', MInf=0.5, alphaZ=0., alphaY=0., ReInf=1.e8, MutSMuInf=0.2, TurbRateInf=1.e-8) # Get the ref state state = C.getState(t) print state
# - computeWallShearStress (pyTree) - import Generator.PyTree as G import Converter.PyTree as C import Transform.PyTree as T import Post.PyTree as P import KCore.test as test a = G.cart((0, 0, 0), (1, 1, 1), (50, 50, 1)) t = C.newPyTree(['Base', a]) C._addState(t, state='EquationDimension', value=3) C._addState(t, adim='adim1') C._initVars(t, '{VelocityX}=0.2*{CoordinateX}**2') C._initVars(t, '{VelocityY}=0.3*{CoordinateY}*{CoordinateX}') C._initVars(t, 'VelocityZ', 0.) for var in ['VelocityX', 'VelocityY', 'VelocityZ']: t = P.computeGrad(t, var) t = C.node2Center(t, var) C._initVars(t, 'centers:Density', 1.) C._initVars(t, 'centers:EnergyStagnationDensity', 1.) C._initVars(t, 'centers:Temperature', 1.) tw = P.computeWallShearStress(t) test.testT(tw, 1) # t = C.newPyTree(['Base', a]) C._addState(t, state='EquationDimension', value=3) C._addState(t, adim='adim1') C._initVars(t, '{VelocityX}=0.2*{CoordinateX}**2') C._initVars(t, '{VelocityY}=0.3*{CoordinateY}*{CoordinateX}') C._initVars(t, 'VelocityZ', 0.) for var in ['VelocityX', 'VelocityY', 'VelocityZ']: t = P.computeGrad(t, var)
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)
b = G.cylinder((0, 0, 0), 1, 1.5, 0, 30, 1, (30, 20, NK)) b[0] = 'cyl2' C._addBC2Zone(a, 'wall', 'BCWall', 'jmin') C._addBC2Zone(b, 'wall', 'BCWall', 'jmin') C._fillEmptyBCWith(b, 'overlap', 'BCOverlap', dim=DIM) t = C.newPyTree(['Base', 'Base2']) t[2][1][2] = [a] t[2][2][2] = [b] C._initVars(t, 'Density', 1.) C._initVars(t, 'centers:cellN', 1) t = X.connectMatchPeriodic(t, rotationCenter=[0., 0., 0.], rotationAngle=[0., 0., 120.], dim=DIM) C._fillEmptyBCWith(t, 'nref', 'BCFarfield', dim=DIM) C._addState(t[2][1], 'EquationDimension', DIM) t = X.applyBCOverlaps(t, depth=1) t = X.setInterpolations(t, double_wall=1, storage='direct', prefixFile=LOCAL + '/chm') C.convertPyTree2File(t, "out.cgns") test.testT(t, 1) # test avec Chimere periodique NK = 51 a = G.cylinder((0, 0, 0), 1, 2, 10, 130, 4., (60, 20, NK)) a[0] = 'cyl1' b = G.cart((0.4, 1.2, -0.3), (0.04, 0.04, 0.1), (11, 11, 21)) a = X.connectMatchPeriodic(a, rotationCenter=[0., 0., 0.], rotationAngle=[0., 0., 120.])
# - rmVars (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import KCore.test as test # Sur une zone a = G.cart((0,0,0),(1,1,1),(10,10,10)) C._addBC2Zone(a, 'wall1', 'BCWall', 'jmin') C._addVars(a, ['Density', 'centers:cellN', 'rou', 'rov', 'Hx', 'centers:Hy']) C._rmVars(a, 'Density') C._rmVars(a, ['Hx', 'centers:Hy']) C._rmVars(a, 'FlowSolution#Centers') t = C.newPyTree(['Base',a]) test.testT(t, 1) # Sur un arbre a = G.cart((0,0,0),(1,1,1),(10,10,10)) C._addBC2Zone(a, 'wall1', 'BCWall', 'jmin') C._addVars(a, ['Density', 'centers:cellN']) b = G.cart((10,0,0),(1,1,1),(10,10,10)) C._addVars(b, ['Density', 'centers:cellN']) t = C.newPyTree(['Base',a,b]) C._addState(t[2][1], 'Mach', 0.6) C._rmVars(t, 'Density') test.testT(t, 2) # Sur une liste de zones A = C.rmVars([a,b], 'Density') t = C.newPyTree(['Base']); t[2][1][2] += A test.testT(t, 3)
import KCore.test as test a = G.cylinder((0, 0, 0), 1., 3., 360, 0, 1, (200, 30, 4)) a[0] = 'cylindre1' C._addBC2Zone(a, 'wall1', 'BCWall', 'jmin') C._addBC2Zone(a, 'ov1', 'BCOverlap', 'jmax') 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._initVars(t, 'F', 0.) C._initVars(t, 'centers:G', 1.) t = X.applyBCOverlaps(t, depth=1) t1 = X.setInterpolations(t, loc='cell', storage='direct') X._chimeraInfo(t1, type='interpolated') X._chimeraInfo(t1, type='extrapolated') X._chimeraInfo(t1, type='orphan') interpPts = X.extractChimeraInfo(t1, type='interpolated', loc='centers') test.testT(interpPts, 1) extrapPts = X.extractChimeraInfo(t1, type='extrapolated', loc='centers') test.testT(extrapPts, 2) cfExtrapPts = X.extractChimeraInfo(t1, type='cf>1.5', loc='centers') test.testO(cfExtrapPts, 3) orphanPts = X.extractChimeraInfo(t1, type='orphan', loc='centers') test.testT(orphanPts, 4)
C._initVars(a, '{centers:Density}={centers:CoordinateX}') C._initVars(a, '{F}={CoordinateY}*{CoordinateX}') C._addBC2Zone(a, 'wall1', 'BCWall', 'jmin') # partiellement coincident a2 = G.cart((1.,y0, 0.), (0.1, 0.1, 0.1), (11, 21,nk)) a2 = T.oneovern(a2,(2,2,1)) C._initVars(a2, '{centers:Density}={centers:CoordinateX}') C._initVars(a2, '{F}={CoordinateY}*{CoordinateX}') C._addBC2Zone(a2, 'overlap1', 'BCOverlap', 'imax') t = C.newPyTree(['Base',a,a2]) t = X.connectNearMatch(t,2,dim=dimPb) t = Internal.addGhostCells(t,t,2,adaptBCs=0,fillCorner=1) test.testT(t,1) # t = C.newPyTree(['Base',a,a2]) C._addState(t[2][1], 'EquationDimension',dimPb) t = X.connectNearMatch(t,2) t = Internal.addGhostCells(t,t,2,adaptBCs=1,fillCorner=1) test.testT(t,2) # geometrical extrapolation of corner cells t = C.newPyTree(['Base',a,a2]) C._addState(t[2][1], 'EquationDimension',dimPb) t = X.connectNearMatch(t,2) t = Internal.addGhostCells(t,t,2,adaptBCs=0,fillCorner=0) test.testT(t,3) # geometrical extrapolation of corner cells t = C.newPyTree(['Base',a,a2]) C._addState(t[2][1], 'EquationDimension',dimPb) t = X.connectNearMatch(t,2)
def setState(event=None): if CTK.t == []: return nzs = CPlot.getSelectedZones() # Mach mach = VARS[2].get() try: mach = float(mach) except: mach = 0. # Reynolds Re = VARS[3].get() try: Re = float(Re) except: Re = 1.e6 # Incidences alphaZ = VARS[4].get() try: alphaZ = float(alphaZ) except: alphaZ = 0. alphaY = VARS[5].get() try: alphaY = float(alphaY) except: alphaY = 0. # Grandeurs turb MutSMuInf = VARS[9].get() try: MutSMuInf = float(MutSMuInf) except: MutSMuInf = 0.2 TurbLevelInf = VARS[10].get() try: TurbLevelInf = float(TurbLevelInf) except: TurbLevelInf = 1.e-4 adim = '' ADIM = VARS[11].get() if ADIM == 'adim1(Ro,A,T)': adim = 'adim1' elif ADIM == 'adim2(Ro,U,T)': adim = 'adim2' elif ADIM == 'dim1(real UInf,TInf,PInf,Rgp=287.053)': adim = 'dim1' elif ADIM == 'dim2(real UInf,TInf,RoInf,Rgp=287.053)': adim = 'dim2' elif ADIM == 'dim3(real UInf,PInf,RoInf,Rgp=287.053)': adim = 'dim3' CTK.saveTree() if CTK.__MAINTREE__ <= 0 or nzs == []: nodes = Internal.getBases(CTK.t) fullBase = False else: fullBase = CPlot.isSelAFullBase(CTK.t, CTK.Nb, nzs) if fullBase > 0: nodes = [CTK.t[2][fullBase]] else: nodes = [] for nz in nzs: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] nodes.append(CTK.t[2][nob][2][noz]) for b in nodes: p, r = Internal.getParentOfNode(CTK.t, b) C.addState2Node__(p[2][r], 'GoverningEquations', VARS[1].get()) if VARS[1].get() == 'NSTurbulent': if VARS[6].get() == 'SpalartAllmaras': C.addState2Node__(p[2][r], 'TurbulenceModel', 'OneEquation_SpalartAllmaras') elif VARS[6].get() == 'JonesLaunder(k-eps)': C.addState2Node__(p[2][r], 'TurbulenceModel', 'TwoEquation_JonesLaunder') elif VARS[6].get() == 'Wilcox(k-w)': C.addState2Node__(p[2][r], 'TurbulenceModel', 'TwoEquation_Wilcox') elif VARS[6].get() == 'MenterSST(k-w)': C.addState2Node__(p[2][r], 'TurbulenceModel', 'TwoEquation_MenterSST') C._addState(p[2][r], MInf=mach, alphaZ=alphaZ, alphaY=alphaY, ReInf=Re, MutSMuInf=MutSMuInf, TurbLevelInf=TurbLevelInf, adim=adim) (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) CTK.TKTREE.updateApp() if nzs == []: CTK.TXT.insert('START', 'State set in all bases.\n') elif fullBase > 0: CTK.TXT.insert('START', 'State set in selected base.\n') else: CTK.TXT.insert('START', 'State set in selected zones.\n')
# - addState (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Converter.Internal as Internal a = G.cylinder((0,0,0), 1., 1.5, 0., 360., 1., (80,30,2)) t = C.newPyTree(['Base',a]) # Specifie des valeurs b = Internal.getNodeFromName1(t, 'Base') C._addState(b, 'EquationDimension', 2) C._addState(b, 'GoverningEquations', 'Euler') C._addState(b, 'Mach', 0.6) C._addState(b, 'Reynolds', 100000) # Specifie un etat de reference adimensionne par: # Mach, alpha, Re, MutSMu, TurbRate (adim1) C._addState(t, adim='adim1', MInf=0.5, alphaZ=0., alphaY=0., ReInf=1.e8, MutSMuInf=0.2, TurbRateInf=1.e-8) # Specifie un etat de reference adimensionne par: # Mach, alpha, Re, MutSMu, TurbRate (adim2) C._addState(t, adim='adim2', MInf=0.5, alphaZ=0., alphaY=0., ReInf=1.e8, MutSMuInf=0.2, TurbRateInf=1.e-8) # Specifie un etat de reference dimensionne par: # U, T, P, L, MutSMu, TurbRate (dim1) C._addState(t, adim='dim1', UInf=35, TInf=294., PInf=101325, LInf=1., alphaZ=0., alphaY=0., MutSMuInf=0.2, TurbRateInf=1.e-8) # Specifie un etat de reference dimensionne par:
def generateCompositeIBMMesh(tb, vmin, snears, dfar, dfarloc=0., DEPTH=2, NP=0, check=True, merged=1, sizeMax=4000000, symmetry=0, externalBCType='BCFarfield'): tbox = None snearsf = None dimPb = Internal.getNodeFromName(tb, 'EquationDimension') if dimPb is None: raise ValueError('EquationDimension is missing in input body tree.') dimPb = Internal.getValue(dimPb) model = Internal.getNodeFromName(tb, 'GoverningEquations') refstate = C.getState(tb) # list of near body meshes t = Internal.copyRef(tb) Internal._rmNodesFromType(t, "Zone_t") snearsExt = [] tblank = Internal.copyRef(tb) DEPTHEXT = 3 * DEPTH + 1 tov = Internal.rmNodesFromType(tb, 'Zone_t') for nob in range(len(tb[2])): base = tb[2][nob] if base[3] == 'CGNSBase_t': basename = base[0] res = generateIBMMesh(base, vmin, snears, dfarloc, DEPTH=DEPTH, NP=NP, tbox=None, snearsf=None, check=check, merged=merged, symmetry=symmetry, sizeMax=sizeMax, externalBCType='BCDummy', to=None, composite=1, mergeByParents=False) res = Internal.getZones(res) t[2][nob][2] = res # blanking box for off-body mesh extFacesL = C.extractBCOfType(res, "BCDummy") bbl = G.bbox(extFacesL) lMax = 0. for extf in extFacesL: if dimPb == 2: extf = T.subzone(extf, (1, 1, 1), (-1, 1, 1)) extf = G.getVolumeMap(extf) dxloc = C.getValue(extf, 'centers:vol', 0) if dimPb == 3: dxloc = dxloc**0.5 lMax = max(lMax, dxloc) snearsExt.append(dxloc) tov[2][nob][2].append(extf) # ATTENTION : engendre une boite parallelepipedique - peut ne pas etre valide dans # les cas ou le maillage cartesien proche corps n est pas parallelepipedique # A ameliorer # IDEM pour les conditions aux limites dans octree2StructLoc et generateIBMMesh xminb = bbl[0] + DEPTHEXT * lMax xmaxb = bbl[3] - DEPTHEXT * lMax yminb = bbl[1] + DEPTHEXT * lMax ymaxb = bbl[4] - DEPTHEXT * lMax if dimPb == 3: zminb = bbl[2] + DEPTHEXT * lMax zmaxb = bbl[5] - DEPTHEXT * lMax blankingBoxL = G.cart( (xminb, yminb, zminb), (xmaxb - xminb, ymaxb - yminb, zmaxb - zminb), (2, 2, 2)) else: blankingBoxL = G.cart((xminb, yminb, 0.), (xmaxb - xminb, ymaxb - yminb, 1.), (2, 2, 1)) blankingBoxL = P.exteriorFaces(blankingBoxL) tblank[2][nob][2] = [blankingBoxL] tcart = generateIBMMesh(tov, vmin, snearsExt, dfar, DEPTH=DEPTH, NP=NP, tbox=tbox, snearsf=snearsf, check=check, merged=1, sizeMax=sizeMax, symmetry=symmetry, externalBCType='BCFarfield', to=None, mergeByParents=True) tcart[2][1][0] = 'OffBody' C._rmBCOfType( t, 'BCDummy') # near body grids external borders must be BCOverlap t = C.fillEmptyBCWith(t, 'ov_ext', 'BCOverlap', dim=dimPb) t = C.mergeTrees(t, tcart) model = Internal.getValue(model) C._addState(t, 'GoverningEquations', model) C._addState(t, 'EquationDimension', dimPb) C._addState(t, state=refstate) return t, tblank
# - addState (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Converter.Internal as Internal a = G.cylinder((0, 0, 0), 1., 1.5, 0., 360., 1., (80, 30, 2)) t = C.newPyTree(['Base', a]) # Specifie des valeurs b = Internal.getNodeFromName1(t, 'Base') C._addState(b, 'EquationDimension', 2) C._addState(b, 'GoverningEquations', 'Euler') C._addState(b, 'Mach', 0.6) C._addState(b, 'Reynolds', 100000)