def chimeraInfo(): if CTK.t == []: return nzs = CPlot.getSelectedZones() typename = VARS[1].get() CTK.saveTree() X._chimeraInfo(CTK.t, typename) CTK.TXT.insert('START', 'Field %s added.\n' % typename) CTK.TKTREE.updateApp() CTK.display(CTK.t)
def optimize(): if CTK.t == []: return if CTK.__MAINTREE__ <= 0: CTK.TXT.insert('START', 'Fail on a temporary tree.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return dw = 1 if VARS[0].get() == 'inactive': dw = 0 depth = VARS[7].get() depth = int(depth) # Creation de l'arbre temporaire nzs = CPlot.getSelectedZones() if nzs == []: CTK.TXT.insert('START', 'Selection is empty.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return # copie du premier niveau sans les enfants t = ['tree', None, [], 'CGNSTree_t'] for i in CTK.t[2]: t[2].append([i[0], i[1], [], i[3]]) for nz in nzs: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] z = CTK.t[2][nob][2][noz] t[2][nob][2].append(z) # Recuperation des priorites dans l'arbre bases = Internal.getBases(CTK.t) prios = [] for b in bases: cont = Internal.getNodesFromName1(b, '.Solver#Chimera') if cont != []: prio = Internal.getNodesFromName3(cont[0], 'Priority') if prio != []: prios.append(b[0]) prios.append(int(prio[0][1][0, 0])) # Optimisation du recouvrement CTK.saveTree() t = X.optimizeOverlap(t, double_wall=dw, priorities=prios) t = X.maximizeBlankedCells(t, depth=depth) c = [0 for x in xrange(len(bases))] for nz in nzs: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] CTK.t[2][nob][2][noz] = t[2][nob][2][c[nob - 1]] c[nob - 1] += 1 CTK.TXT.insert('START', 'Overlapping optimized.\n') CTK.TKTREE.updateApp() CTK.display(CTK.t)
def applyOverlap(): if CTK.t == []: return CTK.saveTree() depth = VARS[7].get() depth = int(depth) CTK.t = X.applyBCOverlaps(CTK.t, depth=depth) CTK.t = X.setDoublyDefinedBC(CTK.t, depth=depth) CTK.TXT.insert('START', 'cellN variable modified near overlap BCs.\n') CTK.TKTREE.updateApp() CTK.display(CTK.t)
def connectNearMatch(): if CTK.t == []: return eps = VARS[2].get() eps = float(eps) ratio = VARS[3].get() ratio = CTK.varsFromWidget(ratio, type=2) if len(ratio) != 1 and len(ratio) != 3: CTK.TXT.insert('START', 'Invalid ratio for nearmatch.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return if len(ratio) == 1: ratio = ratio[0] node = Internal.getNodeFromName(CTK.t, 'EquationDimension') if node is not None: ndim = Internal.getValue(node) else: CTK.TXT.insert('START', 'EquationDimension not found (tkState). Using 3D.\n') CTK.TXT.insert('START', 'Warning: ', 'Warning') ndim = 3 nzs = CPlot.getSelectedZones() CTK.saveTree() if CTK.__MAINTREE__ <= 0 or nzs == []: try: CTK.t = X.connectNearMatch(CTK.t, ratio=ratio, tol=eps, dim=ndim) CTK.TKTREE.updateApp() CTK.TXT.insert('START', 'n/m matching BCs successfully set.\n') except Exception as e: Panels.displayErrors([0, str(e)], header='Error: connectNearMatch') CTK.TXT.insert('START', 'n/m matching BCs failed.\n') CTK.TXT.insert('START', 'Error: ', 'Error') else: sel = [] for nz in nzs: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] z = CTK.t[2][nob][2][noz] sel.append(z) try: sel = X.connectNearMatch(sel, ratio=ratio, tol=eps, dim=ndim) c = 0 for nz in nzs: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] CTK.t[2][nob][2][noz] = sel[c] c += 1 CTK.TKTREE.updateApp() CTK.TXT.insert('START', 'n/m matching BCs successfully set.\n') except Exception as e: Panels.displayErrors([0, str(e)], header='Error: connectNearMatch') CTK.TXT.insert('START', 'n/m matching BCs failed.\n') CTK.TXT.insert('START', 'Error: ', 'Error') check()
def extract(): if CTK.t == []: return type = VARS[0].get() if CTK.__MAINTREE__ == 1: CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones() active = [] zones = Internal.getZones(CTK.t) for z in CTK.__MAINACTIVEZONES__: active.append(CTK.t[2][CTK.Nb[z] + 1][2][CTK.Nz[z]]) Z = None if type == 'cellN=-99999': Z = selectWithFormula(active, '{cellN} == -99999') elif type == 'cellN=1': Z = selectWithFormula(active, '{cellN} == 1') elif type == 'cellN=0': Z = selectWithFormula(active, '{cellN} == 0') elif type == 'cellN=2': Z = selectWithFormula(active, '{cellN} == 2') elif type == 'cellN<0': Z = selectWithFormula(active, '{cellN}<0') elif type == '0<cellN<1': Z = selectWithFormula(active, '({cellN}>0) & ({cellN}<1)') elif type == 'Interpolated points': Z = X.extractChimeraInfo(zones, type='interpolated', loc='centers') if Z == []: Z = None elif type == 'Extrapolated points': Z = X.extractChimeraInfo(zones, type='extrapolated', loc='centers') if Z == []: Z = None elif type == 'Orphan points': Z = X.extractChimeraInfo(zones, type='orphan', loc='centers') if Z == []: Z = None elif type == 'cf>1': Z = X.extractChimeraInfo(zones, type='cf>1', loc='centers') if Z == []: Z = None if Z is not None: CTK.TXT.insert('START', 'Filter ' + type + ' extracted.\n') C._addBase2PyTree(CTK.t, 'EXTRACT') b = Internal.getNodesFromName1(CTK.t, 'EXTRACT') base = b[0] base[2] += Z (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) #C._fillMissingVariables(CTK.t) CTK.TKTREE.updateApp() CTK.display(CTK.t) else: CTK.TXT.insert('START', 'Nothing extracted.\n') CTK.TXT.insert('START', 'Error: ', 'Error')
def view(): if CTK.t == []: return type = VARS[0].get() if type == 'Mesh': CTK.display(CTK.t) return if CTK.__MAINTREE__ == 1: CTK.__MAINACTIVEZONES__ = CPlot.getActiveZones() tp = Internal.appendBaseName2ZoneName(CTK.t, separator=Internal.SEP1) active = [] zones = Internal.getZones(tp) for z in CTK.__MAINACTIVEZONES__: active.append(zones[z]) Z = None if type == 'cf>1': Z = P.selectCells(active, Filter1, [ 'interpCoefs1', 'interpCoefs2', 'interpCoefs3', 'interpCoefs4', 'interpCoefs5', 'interpCoefs6', 'interpCoefs7', 'interpCoefs8' ]) elif type == 'cellN=-99999': Z = selectWithFormula(active, '{cellN} == -99999') elif type == 'cellN=1': Z = selectWithFormula(active, '{cellN} == 1') elif type == 'cellN=0': Z = selectWithFormula(active, '{cellN} == 0') elif type == 'cellN=2': Z = selectWithFormula(active, '{cellN} == 2') elif type == 'cellN<0': Z = selectWithFormula(active, '{cellN} < 0') elif type == '0<cellN<1': Z = selectWithFormula(active, '({cellN}>0) & ({cellN}<1)') elif type == 'Orphan points': Z = X.extractChimeraInfo(active, 'orphan') elif type == 'Extrapolated points': Z = X.extractChimeraInfo(active, 'extrapolated') if Z is not None: CTK.TXT.insert('START', 'Filter ' + type + ' displayed.\n') CTK.dt = C.newPyTree(['Base']) CTK.dt[2][1][2] += Z CTK.display(CTK.dt, mainTree=CTK.CELLN) else: CTK.TXT.insert('START', 'Nothing to display.\n') CTK.TXT.insert('START', 'Error: ', 'Error')
def setDegeneratedBC(): if CTK.t == []: return eps = VARS[2].get() eps = float(eps) node = Internal.getNodeFromName(CTK.t, 'EquationDimension') if node is not None: ndim = Internal.getValue(node) else: CTK.TXT.insert('START', 'EquationDimension not found (tkState). Using 3D.\n') CTK.TXT.insert('START', 'Warning: ', 'Warning') ndim = 3 nzs = CPlot.getSelectedZones() CTK.saveTree() if CTK.__MAINTREE__ <= 0 or nzs == []: try: CTK.t = X.setDegeneratedBC(CTK.t, tol=eps, dim=ndim) CTK.TKTREE.updateApp() CTK.TXT.insert('START', 'Degenerated BCs successfully set.\n') except Exception as e: Panels.displayErrors([0, str(e)], header='Error: setDegenratedBC') CTK.TXT.insert('START', 'Degenerated BCs failed.\n') CTK.TXT.insert('START', 'Error: ', 'Error') else: sel = [] for nz in nzs: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] z = CTK.t[2][nob][2][noz] sel.append(z) try: sel = X.setDegeneratedBC(sel, tol=eps, dim=ndim) c = 0 for nz in nzs: nob = CTK.Nb[nz] + 1 noz = CTK.Nz[nz] CTK.t[2][nob][2][noz] = sel[c] c += 1 CTK.TKTREE.updateApp() CTK.TXT.insert('START', 'Degenerated BCs successfully set.\n') except Exception as e: Panels.displayErrors([0, str(e)], header='Error: setDegeneratedBC') CTK.TXT.insert('START', 'Degenerated BCs failed.\n') CTK.TXT.insert('START', 'Error: ', 'Error') check()
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)
def splitAndDistribute(event=None): global STATS if CTK.t == []: return try: NProc = int(VARS[0].get()) except: CTK.TXT.insert('START', 'distribute: NProc is invalid.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return try: comSpeed = float(VARS[1].get()) except: CTK.TXT.insert('START', 'distribute: ComSpeed is invalid.\n') CTK.TXT.insert('START', 'Error: ', 'Error') return algo = VARS[2].get() useCom = VARS[3].get() level = int(VARS[5].get()) CTK.saveTree() try: #CTK.t = T.splitNParts(CTK.t, NProc, multigrid=level) CTK.t = T.splitSize(CTK.t, N=0, multigrid=level, R=NProc, type=2) # no need to check inconsistant match (they have been deleted) node = Internal.getNodeFromName(CTK.t, 'EquationDimension') if node is not None: ndim = Internal.getValue(node) # Manque le reglage de la tol else: CTK.TXT.insert( 'START', 'EquationDimension not found (tkState). Using 3D.\n') CTK.TXT.insert('START', 'Warning: ', 'Warning') ndim = 3 CTK.t = X.connectMatch(CTK.t, dim=ndim) CTK.display(CTK.t) except Exception as e: Panels.displayErrors([0, str(e)], header='Error: distribute/split') CTK.TXT.insert('START', 'splitSize fails for at least one zone.\n') CTK.TXT.insert('START', 'Warning: ', 'Warning') (CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t) CTK.t, STATS = D.distribute(CTK.t, NProc, perfo=(1., 0., comSpeed), useCom=useCom, algorithm=algo) CTK.TXT.insert('START', 'Blocks split and distributed.\n') CTK.TKTREE.updateApp() updateStats()
# Donor mesh ni = 11 nj = 11 nk = 11 m = G.cartNGon((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1), (ni, nj, nk)) C._initVars(m, '{F}={CoordinateX}+2*{CoordinateY}+3*{CoordinateZ}') C._initVars(m, '{G}=10*{CoordinateX}') 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' C._initVars(a, 'F', -1000.) C._initVars(a, 'G', -1000.) # 2nd order, nodes, direct storage t = C.newPyTree(['Rcv', 'Dnr']) t[2][1][2] = [a] t[2][2][2] = [m] C._initVars(t[2][1], 'cellN', 2) t[2][2] = X.setInterpData(t[2][1], t[2][2], loc='nodes', storage='inverse', order=2, method='leastsquares') info = X.setInterpTransfersD(t[2][2]) test.testO(info) test.testA([info[0][1]], 2)
# - maximizeBlankedCells (pyTree) - import Converter.PyTree as C import Connector.PyTree as X import Generator.PyTree as G def F(x,y): if (x+y<1): return 1 else: return 2 Ni = 50; Nj = 50 a = G.cart((0,0,0),(1./(Ni-1),1./(Nj-1),1),(Ni,Nj,1)) a = C.initVars(a,'cellN', F, ['CoordinateX','CoordinateY']) a = C.node2Center(a, 'cellN') a = C.rmVars(a,'cellN') t = C.newPyTree(['Base',2]); t[2][1][2].append(a) t = X.maximizeBlankedCells(t, 2) C.convertPyTree2File(t, 'out.cgns')
import Connector.PyTree as X import Geom.PyTree as D import KCore.test as test def f(t, u): x = t + u y = t * t + 1 + u * u z = u return (x, y, z) # surface grid a = D.surface(f, N=50) b = T.splitSize(a, 100) b = X.connectMatch(b, dim=2) t = C.newPyTree(['Surface', 2]) t[2][1][2] += b t = C.initVars(t, 'F', 1.) t = C.initVars(t, 'centers:G', 2.) t[2][1][2][0] = C.addBC2Zone(t[2][1][2][0], 'overlap', 'BCOverlap', 'imin') t = C.fillEmptyBCWith(t, 'wall', 'BCWall', dim=2) b = T.merge(t) t2 = C.newPyTree(['Surface', 2]) t2[2][1][2] += b test.testT(t2, 1) b = T.merge(t, alphaRef=45.) t2 = C.newPyTree(['Surface', 2]) t2[2][1][2] = b test.testT(t2, 2) #
# - blankIntersectingCells (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Geom.PyTree as D import Connector.PyTree as X import KCore.test as test import Transform.PyTree as T body = D.sphere6((0,0,0),1.,10) body = T.reorder(body,(-1,2,3)) dh = G.cart((0,0,0),(0.1,1,1),(10,1,1)) a = G.addNormalLayers(body,dh,niter=0) C._initVars(a,'centers:cellN',1.) C._initVars(a,'F',2.) a = C.addBC2Zone(a, 'wall1', 'BCWall', 'kmin') a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'kmax' ) t = C.newPyTree(['Base',a]) t2 = X.blankIntersectingCells(t, depth=1) test.testT(t2,1)
# - getIntersectingDomains (pyTree) - import Generator.PyTree as G import Connector.PyTree as X import Converter.PyTree as C t = C.newPyTree(['Base1']) Ni = 4 Nj = 4 Nk = 4 dx = 0. for i in xrange(10): z = G.cart((dx, dx, dx), (1. / (Ni - 1), 1. / (Nj - 1), 1. / (Nk - 1)), (Ni, Nj, Nk)) t[2][1][2] += [z] dx += 0.3 interDict = X.getIntersectingDomains(t, method='hybrid') print 'Does cart.1 intersect cart.2 ?', 'cart.1' in interDict['cart.2'] print 'List of zones intersecting cart.2:', interDict['cart.2']
# test maskXRay : points de percage (pyTree) import Connector.PyTree as X import Generator.PyTree as G import Geom.PyTree as D import Transform.PyTree as T import Converter.PyTree as C # retourne les pierce pts sous forme de 'NODE' surf = D.sphere((0, 0, 0), 0.5, 20) surf = T.rotate(surf, (0., 0., 0.), (0., 1., 0.), 90.) xray = X.maskXRay__(surf)
# - blankIntersectingCells (pyTree) import Converter.PyTree as C import Generator.PyTree as G import Transform.PyTree as T import Connector.PyTree as X a1 = G.cart((0., 0., 0.), (1., 1., 1.), (11, 11, 11)) a2 = T.rotate(a1, (0., 0., 0.), (0., 0., 1.), 10.) a2 = T.translate(a2, (7., 5., 5.)) a1[0] = 'cart1' a2[0] = 'cart2' t = C.newPyTree(['Base', a1, a2]) t = C.initVars(t, 'centers:cellN', 1.) t2 = X.blankIntersectingCells(t, tol=1.e-10) C.convertPyTree2File(t2, "out.cgns")
import KCore.test as test a = G.cartNGon((1, 1, 1), (1., 1., 1.), (4, 10, 1)) a[0] = 'cart1' b = G.cartNGon((4, 2, 1), (1., 1., 1.), (5, 8, 1)) b[0] = 'cart2' c = G.cartNGon((4, 9, 1), (1., 1., 1.), (4, 5, 1)) c[0] = 'cart3' t = CP.newPyTree(['Base', a, b, c]) t = CP.initVars(t, '{F}=3*{CoordinateX}+2*{CoordinateY}') t = CP.initVars(t, '{centers:G}=2.3') t = CP.initVars(t, '{centers:H}={centers:CoordinateY}') t = CP.initVars(t, '{centers:M}={centers:CoordinateX}') t = X.connectMatch(t, dim=2) t = CP.fillEmptyBCWith(t, "wall", 'BCWall') varL = ['H'] zones = Internal.getZones(t) it = 0 for z in zones: dim = Internal.getZoneDim(z) gcs = Internal.getNodesFromType2(z, 'GridConnectivity_t') for gc in gcs: it = it + 1 zname = Internal.getValue(gc) zdonor = Internal.getNodeFromName(t, zname)
import Dist2Walls.PyTree as DTW import Geom.PyTree as D import Generator.PyTree as G import numpy DEPTH = 2 # Bloc cartesien N = 128; h = 0.1 a = G.cart((0.,0.,0.),(h,h,h),(N,N,1)) # Init wall sphere = D.sphere((6.4,6.4,0), 1., 100) sphere = C.convertArray2Tetra(sphere) sphere = G.close(sphere) t = C.newPyTree(['Base']); t[2][1][2] = [a]; C._initVars(t,'cellN=1') t = X.blankCellsTri(t, [[sphere]], numpy.array([[1]]), blankingType='node_in') # Condition aux limites t = X.setHoleInterpolatedPoints(t,depth=1,loc='nodes') C._initVars(t,'flag=({cellN}>1.)') t = DTW.distance2WallsEikonal(t,sphere,DEPTH=DEPTH,nitmax=10) C.convertPyTree2File(t, 'out.cgns') # Bloc cartesien N = 64; h = 0.2 a = G.cart((0.,0.,0.),(h,h,h),(N,N,1)); a[0] = 'cart2' # Init wall sphere = D.sphere((6.4,6.4,0), 1., 100) sphere = C.convertArray2Tetra(sphere) sphere = G.close(sphere) t = C.newPyTree(['Base']); t[2][1][2] = [a] C._initVars(t,'cellN=1.')
# - connectMatch (pyTree) - import Generator.PyTree as G import Connector.PyTree as X import Converter.PyTree as C import Converter.elsAProfile as elsAProfile a = G.cylinder((0., 0., 0.), 0.1, 1., 0., 90., 5., (11, 11, 11)) t = C.newPyTree(['Base', a]) t = X.connectMatchPeriodic(t, rotationCenter=[0., 0., 0.], translation=[0., 0., 5.]) t = X.connectMatchPeriodic(t, rotationCenter=[0., 0., 0.], rotationAngle=[0., 0., 90.]) tp = elsAProfile.adaptPeriodicMatch(t) C.convertPyTree2File(tp, 'out.cgns')
# - setDoublyDefinedBC (pyTree) - import Converter.PyTree as C import Connector.PyTree as X import Generator.PyTree as G import KCore.test as test a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) b = G.cart((2.5, 2.5, -2.5), (0.5, 0.5, 0.5), (10, 10, 30)) b[0] = 'fente' a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'kmin', [b], 'doubly_defined') t = C.newPyTree(['Base1', 'Base2']) t[2][1][2].append(a) t[2][2][2].append(b) t[2][1] = C.addState(t[2][1], 'EquationDimension', 3) t[2][2] = C.addState(t[2][2], 'EquationDimension', 3) t = C.initVars(t, 'Density', 1.) t = C.initVars(t, 'centers:Pressure', 1.) t2 = X.applyBCOverlaps(t, depth=1) t2 = X.setDoublyDefinedBC(t2, depth=1) test.testT(t2, 1) t2 = X.applyBCOverlaps(t, depth=2) t2 = X.setDoublyDefinedBC(t2, depth=2) test.testT(t2, 2)
# - 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')
# - setInterpolations (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Connector.PyTree as X import KCore.test as test a = G.cylinder((0, 0, 0), 0., 3., 360, 0, 1, (200, 40, 2)) a[0] = 'cylindre1' b = G.cylinder((0, 0, 0), 1., 2., 360, 0, 1, (200, 10, 2)) b[0] = 'cylindre2' a = C.addBC2Zone(a, 'wall1', 'BCWall', 'jmin') a = C.addBC2Zone(a, 'nref', 'BCFarfield', 'jmax') b = C.addBC2Zone(b, 'overlap', 'BCOverlap', 'jmin') b = C.addBC2Zone(b, 'overlap', 'BCOverlap', 'jmax') t = C.newPyTree(['Cyl1', 'Cyl2']) t[2][1][2].append(a) t[2][2][2].append(b) t = X.connectMatch(t, dim=2) t = C.fillEmptyBCWith(t, 'nref', 'BCFarfield', dim=2) for i in range(1, 3): t[2][i] = C.addState(t[2][i], 'EquationDimension', 2) # depth = 2 t1 = X.applyBCOverlaps(t, depth=2) t1 = X.setInterpolations(t1, loc='cell') test.testT(t1, 1) # depth = 1 t2 = X.applyBCOverlaps(t, depth=1) t2 = X.setInterpolations(t2, loc='face') t2 = X.setInterpolations(t2, loc='cell') test.testT(t2, 2)
# - blankCellsTri (pyTree) - 'NODE IN' import Converter.PyTree as C import Connector.PyTree as X import Generator.PyTree as G import Geom.PyTree as D import Post.PyTree as P # Tet mask m = G.cart((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 10)) m = P.exteriorFaces(m) m = C.convertArray2Tetra(m) # Mesh to blank a = G.cart((-5., -5., -5.), (0.5, 0.5, 0.5), (100, 100, 100)) t = C.newPyTree(['Cart', a]) t = C.initVars(t, 'centers:cellN', 1.) masks = [[m]] # Matrice de masquage (arbre d'assemblage) import numpy BM = numpy.array([[1]]) t = X.blankCellsTri(t, masks, BM, blankingType='node_in', tol=1.e-12) C.convertPyTree2File(t, 'out.cgns')
# - applyBCOverlaps (pyTree) - import Converter.PyTree as C import Connector.PyTree as X import Generator.PyTree as G import Converter.elsAProfile as elsAProfile import Converter.Internal as Internal a = G.cylinder((0, 0, 0), 1., 1.5, 360., 0., 1., (30, 30, 10)) a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmax') a = C.addBC2Zone(a, 'wall1', 'BCWall', 'jmin') b = G.cart((-10., -10., -10.), (0.4, 0.4, 0.4), (50, 50, 50)) t = C.newPyTree(['Cyl', a, 'Cart', b]) t = X.applyBCOverlaps(t) tp = elsAProfile.buildBCOverlap(t) tp = elsAProfile.rmGCOverlap__(tp) tp = elsAProfile.addNeighbours(tp) C.convertPyTree2File(tp, 'out.cgns')
# - merge (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Transform.PyTree as T import Connector.PyTree as X import Geom.PyTree as D def f(t,u): x = t+u y = t*t+1+u*u z = u return (x,y,z) a = D.surface(f) b = T.splitSize(a, 100) b = X.connectMatch(b, dim=2) t = C.newPyTree(['Surface']); t[2][1][2] += b b = T.merge(t) t[2][1][2] = b C.convertPyTree2File(t, "out.cgns")
import Converter.PyTree as C import Generator.PyTree as G import Converter.Internal as Internal import Connector.PyTree as X import Geom.PyTree as D import KCore.test as test d = 2 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) #---------
# - getProcList (pyTree) - import Generator.PyTree as G import Distributor2.PyTree as D2 import Converter.PyTree as C import Connector.PyTree as X N = 11 t = C.newPyTree(['Base']) pos = 0 for i in range(N): a = G.cart((pos,0,0), (1,1,1), (10+i, 10, 10)) pos += 10 + i - 1 t[2][1][2].append(a) t = X.connectMatch(t) t, stats = D2.distribute(t, 3) procList = D2.getProcList(t) print(procList)
m = G.cart((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 10)) m = P.exteriorFaces(m) m = C.convertArray2Tetra(m) m = T.reorder(m, (-1, )) #C.convertPyTree2File(m, 'm.plt') # Mesh to blank a = G.cart((-5., -5., -5.), (0.5, 0.5, 0.5), (100, 100, 100)) t = C.newPyTree(['Cart']) t[2][1][2].append(a) # celln init t = C.initVars(t, 'nodes:cellN', 1.) #C.convertPyTree2File(t, 'b.plt') # Blanking t = X.blankCellsTri(t, [[m]], [], blankingType="node_in", tol=1.e-12, cellnval=4, overwrite=1) #C.convertPyTree2File(t, 'out1t.cgns') test.testT(t, 1) # Test 2 # Tet mask m = G.cart((0., 0., 0.), (0.1, 0.1, 0.2), (10, 10, 10)) m = P.exteriorFaces(m) m = C.convertArray2Tetra(m) m = T.reorder(m, (-1, )) # Mesh to blank a = G.cart((-5., -5., -5.), (0.5, 0.5, 0.5), (100, 100, 100)) #C.convertPyTree2File(a, 'bgm.plt') t = C.newPyTree(['Cart'])
import Generator.PyTree as G import Connector.PyTree as X import KCore.test as test # #---------- # # 2D STRUCT # #---------- ni = 15 nj = 15 m1 = G.cart((0, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1.), (ni, nj, 1)) m2 = G.cart((0, 10, 0), (10. / (ni - 1), 10. / (nj - 1), 1.), (ni, nj, 1)) m3 = G.cart((10, 0, 0), (10. / (ni - 1), 10. / (nj - 1), 1.), (ni, nj, 1)) t = C.newPyTree(['Base', m1, m2, m3]) t = X.connectMatch(t, dim=2) t = C.fillEmptyBCWith(t, "wall", 'BCWall') C._initVars(t, '{centers:fldX}= ({centers:CoordinateX})**2') C._initVars(t, '{centers:fldY}= ({centers:CoordinateY})**2') C._initBCDataSet(t, '{fldX}=0.5') C._initBCDataSet(t, '{fldY}=0.5') P._computeDiv2(t, 'centers:fld') test.testT(t, 1) # #---------- # # 3D STRUCT # #---------- ni = 15
ni = 11 nj = 11 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