47 void Foam::hierarchGeomDecomp::setDecompOrder()
49 const word order(geomDecomDict_.lookup(
"order"));
51 if (order.size() != 3)
55 "hierarchGeomDecomp::hierarchGeomDecomp" 56 "(const dictionary& decompositionDict)",
58 ) <<
"number of characters in order (" << order <<
") != 3" 62 for (
label i = 0; i < 3; ++i)
68 else if (order[i] ==
'y')
72 else if (order[i] ==
'z')
80 "hierarchGeomDecomp::hierarchGeomDecomp" 81 "(const dictionary& decompositionDict)",
83 ) <<
"Illegal decomposition order " << order <<
endl 92 const List<scalar>& l,
98 if (initHigh <= initLow)
104 label high = initHigh;
106 while ((high - low) > 1)
108 label mid = (low + high)/2;
140 void Foam::hierarchGeomDecomp::calculateSortedWeightedSizes
145 const label globalCurrentSize,
151 sortedWeightedSizes[0] = 0;
154 label pointI = current[indices[i]];
155 sortedWeightedSizes[i + 1] = sortedWeightedSizes[i] + weights[pointI];
160 sortedWeightedSizes[current.size()],
165 sortedWeightedSizes *= (globalCurrentSize/globalCurrentLength);
171 void Foam::hierarchGeomDecomp::findBinary
174 const List<scalar>& values,
175 const label minIndex,
176 const scalar minValue,
177 const scalar maxValue,
178 const scalar wantedSize,
185 label low = minIndex;
190 label high = values.size();
193 scalar midValuePrev = VGREAT;
201 Pout<<
" low:" << low <<
" lowValue:" << lowValue
202 <<
" high:" << high <<
" highValue:" << highValue
203 <<
" mid:" << mid <<
" midValue:" << midValue <<
endl 204 <<
" globalSize:" << size <<
" wantedSize:" << wantedSize
205 <<
" sizeTol:" << sizeTol <<
endl;
208 if (wantedSize < size - sizeTol)
211 highValue = midValue;
213 else if (wantedSize > size + sizeTol)
224 midValue = 0.5*(lowValue+highValue);
225 mid =
findLower(values, midValue, low, high);
228 bool hasNotChanged = (
mag(midValue-midValuePrev) < SMALL);
232 WarningIn(
"hierarchGeomDecomp::findBinary(..)")
233 <<
"unable to find desired decomposition split, making do!" 238 midValuePrev = midValue;
245 void Foam::hierarchGeomDecomp::findBinary
248 const List<scalar>& sortedWeightedSizes,
249 const List<scalar>& values,
250 const label minIndex,
251 const scalar minValue,
252 const scalar maxValue,
253 const scalar wantedSize,
260 label low = minIndex;
265 label high = values.size();
268 scalar midValuePrev = VGREAT;
274 sortedWeightedSizes[mid] - sortedWeightedSizes[minIndex],
280 Pout<<
" low:" << low <<
" lowValue:" << lowValue
281 <<
" high:" << high <<
" highValue:" << highValue
282 <<
" mid:" << mid <<
" midValue:" << midValue <<
endl 283 <<
" globalSize:" << weightedSize
284 <<
" wantedSize:" << wantedSize
285 <<
" sizeTol:" << sizeTol <<
endl;
288 if (wantedSize < weightedSize - sizeTol)
291 highValue = midValue;
293 else if (wantedSize > weightedSize + sizeTol)
304 midValue = 0.5*(lowValue+highValue);
305 mid =
findLower(values, midValue, low, high);
308 bool hasNotChanged = (
mag(midValue-midValuePrev) < SMALL);
312 WarningIn(
"hierarchGeomDecomp::findBinary(..)")
313 <<
"unable to find desired deomposition split, making do!" 318 midValuePrev = midValue;
324 void Foam::hierarchGeomDecomp::sortComponent
335 label compI = decompOrder_[componentIndex];
339 Pout<<
"sortComponent : Sorting slice of size " << current.size()
340 <<
" in component " << compI <<
endl;
344 SortableList<scalar> sortedCoord(current.size());
348 label pointI = current[i];
350 sortedCoord[i] = points[pointI][compI];
378 Pout<<
"sortComponent : minCoord:" << minCoord
379 <<
" maxCoord:" << maxCoord <<
endl;
385 scalar leftCoord = minCoord;
388 for (
label bin = 0; bin < n_[compI]; bin++)
396 label localSize = -1;
399 scalar rightCoord = -GREAT;
401 if (bin == n_[compI]-1)
404 localSize = current.size()-leftIndex;
405 rightCoord = maxCoord;
410 localSize =
label(current.size()/n_[compI]);
411 rightCoord = sortedCoord[leftIndex+localSize];
419 label rightIndex = current.size();
420 rightCoord = maxCoord;
430 globalCurrentSize/n_[compI],
435 localSize = rightIndex - leftIndex;
440 Pout<<
"For component " << compI <<
", bin " << bin
441 <<
" copying" <<
endl 442 <<
"from " << leftCoord <<
" at local index " 444 <<
"to " << rightCoord <<
" localSize:" 455 label pointI = current[sortedCoord.indices()[leftIndex+i]];
458 finalDecomp[pointI] += bin*mult;
465 if (componentIndex < 2)
491 leftIndex += localSize;
492 leftCoord = rightCoord;
498 void Foam::hierarchGeomDecomp::sortComponent
510 label compI = decompOrder_[componentIndex];
514 Pout<<
"sortComponent : Sorting slice of size " << current.size()
515 <<
" in component " << compI <<
endl;
519 SortableList<scalar> sortedCoord(current.size());
523 label pointI = current[i];
525 sortedCoord[i] = points[pointI][compI];
533 scalarField sortedWeightedSizes(current.size()+1, 0);
534 calculateSortedWeightedSizes
537 sortedCoord.indices(),
565 Pout<<
"sortComponent : minCoord:" << minCoord
566 <<
" maxCoord:" << maxCoord <<
endl;
572 scalar leftCoord = minCoord;
575 for (
label bin = 0; bin < n_[compI]; bin++)
583 label localSize = -1;
586 scalar rightCoord = -GREAT;
588 if (bin == n_[compI]-1)
591 localSize = current.size()-leftIndex;
592 rightCoord = maxCoord;
601 label rightIndex = current.size();
602 rightCoord = maxCoord;
613 globalCurrentSize/n_[compI],
618 localSize = rightIndex - leftIndex;
623 Pout<<
"For component " << compI <<
", bin " << bin
624 <<
" copying" <<
endl 625 <<
"from " << leftCoord <<
" at local index " 627 <<
"to " << rightCoord <<
" localSize:" 638 label pointI = current[sortedCoord.indices()[leftIndex+i]];
641 finalDecomp[pointI] += bin*mult;
648 if (componentIndex < 2)
675 leftIndex += localSize;
676 leftCoord = rightCoord;
701 label allSize = points.size();
742 label allSize = points.size();
765 Foam::hierarchGeomDecomp::hierarchGeomDecomp
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const string & prefix() const
Return the prefix of the stream.
Geometrical domain decomposition.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< scalar > mag(const dimensioned< Type > &)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
const double e
Elementary charge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Macros for easy insertion into run-time selection tables.
label findLower(const ListType &, typename ListType::const_reference, const label stary, const BinaryOp &bop)
Find last element < given value in sorted list and return index,.
List< label > labelList
A List of labels.
virtual labelList decompose(const pointField &, const scalarField &weights)
Return for every coordinate the wanted processor number.
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")