Skip to content

Commit 34ce6f8

Browse files
authored
Merge pull request #80 from antjost/devDistrib
[DISTRIB] Move & slightly modify the distributor in Apps/Fast/IBM.py into Distributor2. This is an efficient distribution of t & tc and should be independent of Fast.
2 parents 55e4bc0 + 599ed61 commit 34ce6f8

File tree

1 file changed

+10
-84
lines changed

1 file changed

+10
-84
lines changed

Fast/Fast/Fast/IBM.py

Lines changed: 10 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,96 +1208,22 @@ def setInterpData_Hybride(t_octree, tc_octree, t_curvi, blankingMatrix=None, bla
12081208
#====================================================================================
12091209
# Redistrib on NP processors
12101210
#====================================================================================
1211-
def _distribute(t_in, tc_in, NP, algorithm='graph', tc2_in=None, useCom='ID'):
1212-
if isinstance(tc_in, str):
1213-
tcs = Cmpi.convertFile2SkeletonTree(tc_in, maxDepth=3)
1214-
else: tcs = tc_in
1215-
stats = D2._distribute(tcs, NP, algorithm=algorithm, useCom=useCom)
1216-
if isinstance(tc_in, str):
1217-
paths = []; ns = []
1218-
bases = Internal.getBases(tcs)
1219-
for b in bases:
1220-
zones = Internal.getZones(b)
1221-
for z in zones:
1222-
nodes = Internal.getNodesFromName2(z, 'proc')
1223-
for n in nodes:
1224-
p = 'CGNSTree/%s/%s/.Solver#Param/proc'%(b[0],z[0])
1225-
paths.append(p); ns.append(n)
1226-
Filter.writeNodesFromPaths(tc_in, paths, ns, maxDepth=0, mode=1)
1227-
1228-
if isinstance(t_in, str):
1229-
ts = Cmpi.convertFile2SkeletonTree(t_in, maxDepth=3)
1230-
else: ts = t_in
1231-
1232-
D2._copyDistribution(ts, tcs)
1233-
1234-
if isinstance(t_in, str):
1235-
paths = []; ns = []
1236-
bases = Internal.getBases(ts)
1237-
for b in bases:
1238-
zones = Internal.getZones(b)
1239-
for z in zones:
1240-
nodes = Internal.getNodesFromName2(z, 'proc')
1241-
for n in nodes:
1242-
p = 'CGNSTree/%s/%s/.Solver#Param/proc'%(b[0],z[0])
1243-
paths.append(p); ns.append(n)
1244-
Filter.writeNodesFromPaths(t_in, paths, ns, maxDepth=0, mode=1)
1245-
1246-
if tc2_in is not None:
1247-
if isinstance(tc2_in, str):
1248-
tc2s = Cmpi.convertFile2SkeletonTree(tc2_in, maxDepth=3)
1249-
else: tc2s = tc2_in
1250-
D2._copyDistribution(tc2s, tcs)
1251-
1252-
if isinstance(tc2_in, str):
1253-
paths = []; ns = []
1254-
bases = Internal.getBases(tc2s)
1255-
for b in bases:
1256-
zones = Internal.getZones(b)
1257-
for z in zones:
1258-
nodes = Internal.getNodesFromName2(z, 'proc')
1259-
for n in nodes:
1260-
p = 'CGNSTree/%s/%s/.Solver#Param/proc'%(b[0],z[0])
1261-
paths.append(p); ns.append(n)
1262-
Filter.writeNodesFromPaths(tc2_in, paths, ns, maxDepth=0, mode=1)
1263-
1264-
_checkNcellsNptsPerProc(ts,NP)
1211+
def _distribute(tIn, tcIn, NP, algorithm='graph', tc2In=None, useCom='ID'):
1212+
if isinstance(tIn , str)==False or isinstance(tcIn, str)==False or (isinstance(tc2In, str)==False and tc2In):
1213+
print("ERROR:: The arguments for Fast/Apps/IBM.py have changed. tIn, tcIn, & tc2In must be a filename. Exiting...", flush=True)
1214+
exit()
1215+
tInLocal = [tIn,tcIn]
1216+
if tc2In: tInLocal.append(tc2In)
1217+
D2._distributeSkeletonTree(tInLocal, NP, algorithm=algorithm, useCom=useCom)
12651218
return None
12661219

1267-
12681220
#====================================================================================
12691221
# Check number of points and cells per zone & in total
12701222
#====================================================================================
12711223
def _checkNcellsNptsPerProc(ts, NP, isAtCenter=False):
1272-
NPTS = numpy.zeros(NP, dtype=Internal.E_NpyInt)
1273-
NCELLS = numpy.zeros(NP, dtype=Internal.E_NpyInt)
1274-
##Done by zone for flexibility
1275-
for z in Internal.getZones(ts):
1276-
proc_num = Cmpi.getProc(z)
1277-
NPTS[proc_num] += C.getNPts(z)
1278-
if not isAtCenter:
1279-
NCELLS[proc_num] += C.getNCells(z)
1280-
else:
1281-
NCELLS[proc_num] = NPTS[proc_num]
1282-
1283-
NPTS = Cmpi.allreduce(NPTS ,op=Cmpi.SUM)
1284-
NCELLS = Cmpi.allreduce(NCELLS,op=Cmpi.SUM)
1285-
NptsTot = numpy.sum(NPTS)
1286-
NcellsTot= numpy.sum(NCELLS)
1287-
ncells_percent=[]
1288-
if Cmpi.rank == 0:
1289-
for i in range(NP):
1290-
ncells_percent.append(NCELLS[i]/NcellsTot*100.)
1291-
if isAtCenter: print('Rank {} has {} cells & {} % of cells'.format(i,int(NCELLS[i]),round(ncells_percent[i],2)))
1292-
else: print('Rank {} has {} points & {} cells & {} % of cells'.format(i,int(NPTS[i]),int(NCELLS[i]),round(ncells_percent[i],2)))
1293-
1294-
if isAtCenter: print('All points: {} million cells'.format(NcellsTot/1.e6))
1295-
else: print('All points: {} million points & {} million cells'.format(NptsTot/1.e6,NcellsTot/1.e6))
1296-
print('Range of % of cells: {} - {}'.format(round(min(ncells_percent),2),round(max(ncells_percent),2)))
1297-
1224+
D2._checkNcellsNptsPerProc(ts, NP, isAtCenter=isAtCenter)
12981225
return None
12991226

1300-
13011227
#====================================================================================
13021228
##This interpolation complements the function _initialize_t in the class IBM.
13031229
##If the meshes are large the function in the class IBM can fail due to memory limits
@@ -3443,8 +3369,8 @@ def prepare(self, t_case, t_out, tc_out):
34433369

34443370
##"STAND ALONE" FUNCTIONS
34453371
# distribute
3446-
def _distribute(self, t_in, tc_in,algorithm='graph', tc2_in=None):
3447-
return _distribute(t_in, tc_in, self.NP, algorithm='graph', tc2_in=None)
3372+
def _distribute(self, tIn, tcIn,algorithm='graph', tc2In=None):
3373+
return _distribute(tIn, tcIn, self.NP, algorithm='graph', tc2In=None)
34483374

34493375

34503376
# check nulber of points and cells per zone and i total

0 commit comments

Comments
 (0)