def extractMesh(t, extractionMesh, order=2, extrapOrder=1, constraint=40., tol=1.e-6, mode='robust', hook=None, graph=None): if graph is None: tb = Cmpi.createBBoxTree(t) tb2 = Cmpi.createBBoxTree(extractionMesh) graph = Cmpi.computeGraph(tb, type='bbox3', t2=tb2) tl = Cmpi.addXZones(t, graph) tl = Cmpi.convert2PartialTree(tl) ext = Cmpi.convert2PartialTree(extractionMesh) # print info zones = Internal.getZones(tl) print('Rank %d has %d source zones.' % (Cmpi.rank, len(zones))) ext = P.extractMesh(tl, ext, order=order, extrapOrder=extrapOrder, constraint=constraint, tol=tol, mode=mode, hook=hook) return ext
def optimizeOverlap(t, double_wall=0, priorities=[], graph=None, intersectionsDict=None): if graph is None: tb = Cmpi.createBBoxTree(t) graph = Cmpi.computeGraph(tb, type='bbox2', intersectionsDict=intersectionsDict) tl = Cmpi.addXZones(t, graph) tl = Cmpi.convert2PartialTree(tl) # print info zones = Internal.getZones(tl) #print 'Rank %d has %d zones.'%(Cmpi.rank, len(zones)) tl = X.optimizeOverlap(tl, double_wall, priorities, intersectionsDict) tl = Cmpi.rmXZones(tl) return tl
def _setInterpTransfers(aR, aD, variables=[], variablesIBC=['Density','MomentumX','MomentumY','MomentumZ','EnergyStagnationDensity'], bcType=0, varType=1, compact=0, graph=None, procDict=None, type='ALLD', Gamma=1.4, Cv=1.7857142857142865, MuS=1.e-08, Cs=0.3831337844872463, Ts=1.0): if (procDict is None): procDict = Cmpi.getProcDict(aD) if (graph is None): graph = Cmpi.computeGraph(aD, type=type) # Transferts locaux/globaux # Calcul des solutions interpolees par arbre donneur # On envoie aussi les indices receveurs pour l'instant datas = {} zonesD = Internal.getZones(aD) for zD in zonesD: infos = X.setInterpTransfersD(zD, variables, variablesIBC, bcType, varType, compact, Gamma, Cv, MuS, Cs, Ts) for n in infos: rcvName = n[0] proc = procDict[rcvName] if (proc == Cmpi.rank): field = n[1] #print 'direct', Cmpi.rank, rcvName if field != []: listIndices = n[2] z = Internal.getNodesFromName2(aR, rcvName)[0] C._setPartialFields(z, [field], [listIndices], loc=n[3]) else: rcvNode = procDict[rcvName] #print Cmpi.rank, 'envoie a ',rcvNode if not datas.has_key(rcvNode): datas[rcvNode] = [n] else: datas[rcvNode] += [n] #print datas # Envoie des numpys suivant le graph rcvDatas = Cmpi.sendRecv(datas, graph) # Remise des champs interpoles dans l'arbre receveur for i in rcvDatas.keys(): #print Cmpi.rank, 'recoit de',i, '->', len(rcvDatas[i]) for n in rcvDatas[i]: rcvName = n[0] #print 'reception', Cmpi.rank, rcvName field = n[1] if field != []: listIndices = n[2] z = Internal.getNodesFromName2(aR, rcvName)[0] C._setPartialFields(z, [field], [listIndices], loc=n[3]) return None
def redispatch(t, graph=None): if graph is None: graph = Cmpi.computeGraph(t, type='proc') procs = D2.getProcDict(t) t = Cmpi.addXZones(t, graph) # Enleve les zones envoyees zones = Internal.getZones(t) for z in zones: tag = Internal.getNodesFromName1(z, 'XZone') if len(tag) == 0: if procs[z[0]] != Cmpi.rank: (p, c) = Internal.getParentOfNode(t, z) del p[2][c] else: # enleve le noeud tag XZone (p, c) = Internal.getParentOfNode(z, tag[0]) del p[2][c] return t
# - computeGraph (pyTree) - import Converter.PyTree as C import Converter.Mpi as Cmpi import Distributor2.PyTree as Distributor2 import Generator.PyTree as G import Connector.PyTree as X import KCore.test as test # Through BBox a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) b = G.cart((8, 0, 0), (1, 1, 1), (10, 10, 10)) t = C.newPyTree(['Base', a, b]) (t, dic) = Distributor2.distribute(t, NProc=2, algorithm='fast') tb = Cmpi.createBBoxTree(t) graph = Cmpi.computeGraph(tb, type='bbox') if Cmpi.rank == 0: test.testO(graph, 1) # Through match a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) b = G.cart((9, 0, 0), (1, 1, 1), (10, 10, 10)) t = C.newPyTree(['Base']) t[2][1][2] += [a, b] t = X.connectMatch(t) (t, dic) = Distributor2.distribute(t, NProc=2, algorithm='fast') graph = Cmpi.computeGraph(t, type='match') if Cmpi.rank == 0: test.testO(graph, 2)
# - addXZones (pyTree) - import Converter.PyTree as C import Converter.Mpi as Cmpi import Distributor2.PyTree as Distributor2 import Generator.PyTree as G import KCore.test as test # Cree le fichier test if (Cmpi.rank == 0): a = G.cart( (0,0,0), (1,1,1), (10,10,10) ) b = G.cart( (9,0,0), (1,1,1), (10,10,10) ) t = C.newPyTree(['Base',a,b]) C.convertPyTree2File(t, 'test.cgns') Cmpi.barrier() # Relit des zones par procs t = Cmpi.convertFile2SkeletonTree('test.cgns') (t, dic) = Distributor2.distribute(t, NProc=Cmpi.size, algorithm='fast') t = Cmpi.readZones(t, 'test.cgns', proc=Cmpi.rank) # Cree le bbox tree tb = Cmpi.createBBoxTree(t) # Cree le graph graph = Cmpi.computeGraph(tb) # Add X Zones t = Cmpi.addXZones(t, graph) if (Cmpi.rank == 0): test.testT(t, 1)
N = 11 # Cas test t = C.newPyTree(['Base']) off = 0 for i in range(N): a = G.cart((off, 0, 0), (1, 1, 1), (10 + i, 10, 10)) off += 9 + i t[2][1][2].append(a) t = X.connectMatch(t) t, stats = D2.distribute(t, NProc=5, algorithm='fast', useCom=0) if Cmpi.rank == 0: C.convertPyTree2File(t, LOCAL + '/in.cgns') Cmpi.barrier() # full graph = Cmpi.computeGraph(t, type='match') if Cmpi.rank == 0: test.testO(graph, 1) # skel (doit etre identique) t = Cmpi.convertFile2SkeletonTree(LOCAL + '/in.cgns') graph = Cmpi.computeGraph(t, type='match') if Cmpi.rank == 0: test.testO(graph, 2) # load skel (doit etre identique) t = Cmpi.convertFile2SkeletonTree(LOCAL + '/in.cgns') t = Cmpi.readZones(t, LOCAL + '/in.cgns', rank=Cmpi.rank) graph = Cmpi.computeGraph(t, type='match') if Cmpi.rank == 0: test.testO(graph, 3) # partial (doit etre identique) t = Cmpi.convertFile2SkeletonTree(LOCAL + '/in.cgns')