39 # ifdef DEBUGBalancing
61 const scalar t1 = omp_get_wtime();
67 label localNumWeighs(0);
74 if( leaves[leafI]->cubeType() & usedType )
76 globalLeafWeight[leafI] = localNumWeighs;
81 globalLeafWeight[leafI] = -1;
89 globalLeafWeight[leafI] = localNumWeighs;
96 const scalar t2 = omp_get_wtime();
97 Info <<
"Creation of global leaf weights lasted " << t2-t1 <<
endl;
106 label doBalancing(0);
110 scalar(localNumWeighs - nWeightsPerProcessor) /
118 if( doBalancing == 0 )
121 Info <<
"Distributing load between processors" <<
endl;
133 doBalancing += procWeights[procI];
135 forAll(globalLeafWeight, lI)
137 if( globalLeafWeight[lI] != -1 )
138 globalLeafWeight[lI] += doBalancing;
143 std::map<label, labelLongList> leavesToSend;
145 bool oneRemainingBox(
false);
146 forAll(globalLeafWeight, leafI)
148 if( globalLeafWeight[leafI] == -1 )
150 if( !oneRemainingBox && (leafI == leaves.
size() -1) )
153 const label newProc =
156 globalLeafWeight[leafI] / nWeightsPerProcessor,
162 leavesToSend[newProc].append(leafI);
163 leaves[leafI]->setProcNo(newProc);
165 # ifdef DEBUGBalancing
166 if( leaves[leafI]->hasContainedElements() )
168 << leaves[leafI]->coordinates() <<
" data is "
169 << leaves[leafI]->containedElements() <<
endl;
174 oneRemainingBox =
true;
180 const scalar t3 = omp_get_wtime();
181 Info <<
"Completed assignment of leaves to processors in " << t3-t2 <<
endl;
193 std::map<label, labelLongList>::const_iterator it=leavesToSend.begin();
194 it!=leavesToSend.end();
203 forAll(sendToProcesssors, procI)
204 forAll(sendToProcesssors[procI], neiI)
206 receiveFrom.
insert(procI);
222 migratedCubes.
setSize(currSize+mc.size());
225 migratedCubes[currSize] = mc[mcI];
234 const label procI = sendToProcs[i];
241 leavesToSend[procI].size()
244 forAll(leavesToSend[procI], lI)
247 sendCoordinates[lI] =
259 sendCoordinates.byteSize()
262 toOtherProc << sendCoordinates;
278 migratedCubes.
setSize(currSize+mc.size());
281 migratedCubes[currSize] = mc[mcI];
289 const label procI = sendToProcs[i];
296 leavesToSend[procI].size()
299 forAll(leavesToSend[procI], lI)
302 sendCoordinates[lI] =
314 sendCoordinates.byteSize()
317 toOtherProc << sendCoordinates;
322 const scalar t4 = omp_get_wtime();
323 Info <<
"Data exchange lasted " << t4-t3 <<
endl;
331 const scalar t5 = omp_get_wtime();
332 Info <<
"Purging lasted " << t5-t4 <<
endl;
336 forAll(migratedCubes, mcI)
342 migratedCubes[mcI].cubeType()
350 const scalar t6 = omp_get_wtime();
351 Info <<
"Tree refinement lasted " << t6-t5 <<
endl;
359 const scalar endTime = omp_get_wtime();
360 Info <<
"Updating of communication pattern lasted " << endTime-t6 <<
endl;
364 Info <<
"Finished distributing load between processors" <<
endl;