Skip to content

Commit 6b6e9d7

Browse files
committed
[DISTRIB] Change the input arguments for _distributeSkeletonTree. Function only needs fileName list as input.
1 parent 95501a7 commit 6b6e9d7

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

Cassiopee/Distributor2/Distributor2/PyTree.py

+16-27
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ def printStats(t, useCom='match', mode='nodes'):
523523
# Efficient distribute
524524
#==================================================================================
525525
def _checkNcellsNptsPerProc(ts, NP, isAtCenter=False):
526+
## Calculate and prints the number of cells & points for each proc. Provides a human-readable summary of the MPI distribution.
526527
import Converter.Mpi as Cmpi
527528
NPTS = numpy.zeros(NP, dtype=Internal.E_NpyInt)
528529
NCELLS = numpy.zeros(NP, dtype=Internal.E_NpyInt)
@@ -552,6 +553,7 @@ def _checkNcellsNptsPerProc(ts, NP, isAtCenter=False):
552553

553554

554555
def _write2pathLocal__(tsLocal, tLocal):
556+
##Modifies the .Solver#Param/proc only in the files
555557
import Converter.Mpi as Cmpi
556558
import Converter.Filter as Filter
557559
paths = []; ns = []
@@ -564,31 +566,18 @@ def _write2pathLocal__(tsLocal, tLocal):
564566
p = 'CGNSTree/%s/%s/.Solver#Param/proc'%(b[0],z[0])
565567
paths.append(p); ns.append(n)
566568
Filter.writeNodesFromPaths(tLocal, paths, ns, maxDepth=0, mode=1)
567-
568-
569-
def _distributeSkeletonTree(tIn, tcIn, NP, algorithm='graph', tc2In=None, useCom='ID'):
570-
"""Distribute t and tc PyTrees over NP processors. If t & tc are the file names this function efficient loads, distributes, and write the new distributed files. This approach is the recommended one.
571-
Usage: _distributeSkeletonTree(t, tc, NP, algorithm='graph', tc2In=None, useCom='all')"""
572-
import Converter.Mpi as Cmpi
573-
574-
if isinstance(tcIn, str): tcs = Cmpi.convertFile2SkeletonTree(tcIn, maxDepth=3)
575-
else: tcs = tcIn
576-
577-
if isinstance(tIn, str): ts = Cmpi.convertFile2SkeletonTree(tIn, maxDepth=3)
578-
else: ts = tIn
579-
580-
stats = _distribute(tcs, NP, algorithm=algorithm, useCom=useCom)
581-
_copyDistribution(ts, tcs)
582-
583-
if isinstance(tcIn, str): _write2pathLocal__(tcs, tcIn)
584-
if isinstance(tIn, str): _write2pathLocal__(ts, tIn)
585-
586-
if tc2In is not None:
587-
if isinstance(tc2In, str): tc2s = Cmpi.convertFile2SkeletonTree(tc2In, maxDepth=3)
588-
else: tc2s = tc2In
589-
_copyDistribution(tc2s, tcs)
590-
591-
if isinstance(tc2In, str): _write2pathLocal__(tc2s, tc2In)
592-
593-
_checkNcellsNptsPerProc(ts,NP)
569+
570+
571+
def _distributeSkeletonTree(tIn, NP, algorithm='graph', useCom='ID'):
572+
"""Distribute PyTrees over NP processors. t is a list with the file names.
573+
Usage: _distributeSkeletonTree(t=[], NP, algorithm='graph', useCom='all')"""
574+
import Converter.Mpi as Cmpi
575+
fileNameLength = len(tIn)
576+
for fileName in tIn:
577+
ts = Cmpi.convertFile2SkeletonTree(fileName, maxDepth=3)
578+
stats = _distribute(ts, NP, algorithm=algorithm, useCom=useCom)
579+
_write2pathLocal__(ts, fileName)
580+
if fileName==tIn[0]: tcs = Internal.copyTree(ts)
581+
if fileNameLength>1 and fileName!=tIn[0]: _copyDistribution(ts, tcs)
582+
_checkNcellsNptsPerProc(tcs,NP)
594583
return None

0 commit comments

Comments
 (0)