# - getProc (pyTree) - import Converter.PyTree as C import Generator.PyTree as G import Distributor2.PyTree as D2 a = G.cart((0, 0, 0), (1, 1, 1), (10, 10, 10)) a = D2.addProcNode(a, 12) proc = D2.getProc(a) print proc
def loadAndSplit(fileName, NParts=None, noz=None, NProc=None, rank=None, variables=[]): if NParts is None: NParts = NProc if NProc is None: NProc = NParts import Transform.PyTree as T a = convertFile2SkeletonTree(fileName) # split on skeleton splitDict = {} b = T.splitNParts(a, N=NParts, splitDict=splitDict) zones = Internal.getZones(b) if rank is not None: import Distributor2.PyTree as D2 D2._distribute(b, NProc) noz = [] for i, z in enumerate(zones): p = D2.getProc(z) if p == rank: noz.append(i) f = {} for i in noz: z = zones[i] j = splitDict[z[0]] # Correction de dimension en attendant que subzone fonctionne sur un skel ni = j[2] - j[1] + 1 nj = j[4] - j[3] + 1 nk = j[6] - j[5] + 1 ni1 = max(ni - 1, 1) nj1 = max(nj - 1, 1) nk1 = max(nk - 1, 1) d = numpy.empty((3, 3), numpy.int32, order='Fortran') d[0, 0] = ni d[1, 0] = nj d[2, 0] = nk d[0, 1] = ni1 d[1, 1] = nj1 d[2, 1] = nk1 d[0, 2] = 0 d[1, 2] = 0 d[2, 2] = 0 z[1] = d # END correction zname = z[0] # zone name in b pname = zname.rsplit('.', 1)[0] # parent name (guessed) (base, c) = Internal.getParentOfNode(b, z) bname = base[0] f = {} # Node fields path = [] cont = Internal.getNodeFromName2(z, Internal.__GridCoordinates__) if cont is not None: for c in cont[2]: if c[3] == 'DataArray_t': path += ['/%s/%s/%s/%s' % (bname, pname, cont[0], c[0])] cont = Internal.getNodeFromName2(z, Internal.__FlowSolutionNodes__) if cont is not None: for c in cont[2]: if c[3] == 'DataArray_t' and c[0] in variables: path += ['/%s/%s/%s/%s' % (bname, pname, cont[0], c[0])] DataSpaceMMRY = [[0, 0, 0], [1, 1, 1], [ni, nj, nk], [1, 1, 1]] DataSpaceFILE = [[j[1] - 1, j[3] - 1, j[5] - 1], [1, 1, 1], [ni, nj, nk], [1, 1, 1]] DataSpaceGLOB = [[0]] for p in path: f[p] = DataSpaceMMRY + DataSpaceFILE + DataSpaceGLOB # Center fields path = [] cont = Internal.getNodeFromName2(z, Internal.__FlowSolutionCenters__) if cont is not None: for c in cont[2]: if c[3] == 'DataArray_t' and 'centers:' + c[0] in variables: path += ['/%s/%s/%s/%s' % (bname, pname, cont[0], c[0])] DataSpaceMMRY = [[0, 0, 0], [1, 1, 1], [ni1, nj1, nk1], [1, 1, 1]] DataSpaceFILE = [[j[1] - 1, j[3] - 1, j[5] - 1], [1, 1, 1], [ni1, nj1, nk1], [1, 1, 1]] DataSpaceGLOB = [[0]] for p in path: f[p] = DataSpaceMMRY + DataSpaceFILE + DataSpaceGLOB r = readNodesFromFilter(fileName, f) # Repositionne les chemins for k in r: k2 = k.replace(pname, zname) n = Internal.getNodeFromPath(b, k2) n[1] = r[k] b = convert2PartialTree(b) return b