Go to the documentation of this file.
51 if (order.size() != 3)
56 ) <<
"number of characters in order (" << order <<
") != 3"
60 for (
label i = 0; i < 3; ++i)
66 else if (order[i] ==
'y')
70 else if (order[i] ==
'z')
79 ) <<
"Illegal decomposition order " << order <<
endl
94 if (initHigh <= initLow)
100 label high = initHigh;
102 while ((high - low) > 1)
104 label mid = (low + high)/2;
141 const label globalCurrentSize,
147 sortedWeightedSizes[0] = 0;
150 label pointI = current[indices[i]];
151 sortedWeightedSizes[i + 1] = sortedWeightedSizes[i] + weights[pointI];
156 sortedWeightedSizes[current.
size()],
161 sortedWeightedSizes *= (globalCurrentSize/globalCurrentLength);
171 const label minIndex,
174 const scalar wantedSize,
181 label low = minIndex;
189 scalar midValuePrev = VGREAT;
197 Pout<<
" low:" << low <<
" lowValue:" << lowValue
198 <<
" high:" << high <<
" highValue:" << highValue
199 <<
" mid:" << mid <<
" midValue:" << midValue <<
endl
200 <<
" globalSize:" << size <<
" wantedSize:" << wantedSize
201 <<
" sizeTol:" << sizeTol <<
endl;
204 if (wantedSize < size - sizeTol)
207 highValue = midValue;
209 else if (wantedSize > size + sizeTol)
220 midValue = 0.5*(lowValue+highValue);
221 mid =
findLower(values, midValue, low, high);
224 bool hasNotChanged = (
mag(midValue-midValuePrev) < SMALL);
229 <<
"unable to find desired decomposition split, making do!"
234 midValuePrev = midValue;
246 const label minIndex,
249 const scalar wantedSize,
256 label low = minIndex;
264 scalar midValuePrev = VGREAT;
270 sortedWeightedSizes[mid] - sortedWeightedSizes[minIndex],
276 Pout<<
" low:" << low <<
" lowValue:" << lowValue
277 <<
" high:" << high <<
" highValue:" << highValue
278 <<
" mid:" << mid <<
" midValue:" << midValue <<
endl
279 <<
" globalSize:" << weightedSize
280 <<
" wantedSize:" << wantedSize
281 <<
" sizeTol:" << sizeTol <<
endl;
284 if (wantedSize < weightedSize - sizeTol)
287 highValue = midValue;
289 else if (wantedSize > weightedSize + sizeTol)
300 midValue = 0.5*(lowValue+highValue);
301 mid =
findLower(values, midValue, low, high);
304 bool hasNotChanged = (
mag(midValue-midValuePrev) < SMALL);
309 <<
"unable to find desired deomposition split, making do!"
314 midValuePrev = midValue;
331 label compI = decompOrder_[componentIndex];
335 Pout<<
"sortComponent : Sorting slice of size " << current.
size()
336 <<
" in component " << compI <<
endl;
344 label pointI = current[i];
346 sortedCoord[i] =
points[pointI][compI];
374 Pout<<
"sortComponent : minCoord:" << minCoord
375 <<
" maxCoord:" << maxCoord <<
endl;
381 scalar leftCoord = minCoord;
384 for (
label bin = 0; bin < n_[compI]; bin++)
392 label localSize = -1;
395 scalar rightCoord = -GREAT;
397 if (bin == n_[compI]-1)
400 localSize = current.
size()-leftIndex;
401 rightCoord = maxCoord;
406 localSize =
label(current.
size()/n_[compI]);
407 if (leftIndex+localSize < sortedCoord.size())
409 rightCoord = sortedCoord[leftIndex+localSize];
413 rightCoord = maxCoord;
423 rightCoord = maxCoord;
433 globalCurrentSize/n_[compI],
438 localSize = rightIndex - leftIndex;
443 Pout<<
"For component " << compI <<
", bin " << bin
444 <<
" copying" <<
endl
445 <<
"from " << leftCoord <<
" at local index "
447 <<
"to " << rightCoord <<
" localSize:"
458 label pointI = current[sortedCoord.
indices()[leftIndex+i]];
461 finalDecomp[pointI] += bin*mult;
468 if (componentIndex < 2)
494 leftIndex += localSize;
495 leftCoord = rightCoord;
513 label compI = decompOrder_[componentIndex];
517 Pout<<
"sortComponent : Sorting slice of size " << current.
size()
518 <<
" in component " << compI <<
endl;
526 label pointI = current[i];
528 sortedCoord[i] =
points[pointI][compI];
537 calculateSortedWeightedSizes
568 Pout<<
"sortComponent : minCoord:" << minCoord
569 <<
" maxCoord:" << maxCoord <<
endl;
575 scalar leftCoord = minCoord;
578 for (
label bin = 0; bin < n_[compI]; bin++)
586 label localSize = -1;
589 scalar rightCoord = -GREAT;
591 if (bin == n_[compI]-1)
594 localSize = current.
size()-leftIndex;
595 rightCoord = maxCoord;
605 rightCoord = maxCoord;
616 globalCurrentSize/n_[compI],
621 localSize = rightIndex - leftIndex;
626 Pout<<
"For component " << compI <<
", bin " << bin
627 <<
" copying" <<
endl
628 <<
"from " << leftCoord <<
" at local index "
630 <<
"to " << rightCoord <<
" localSize:"
641 label pointI = current[sortedCoord.
indices()[leftIndex+i]];
644 finalDecomp[pointI] += bin*mult;
651 if (componentIndex < 2)
678 leftIndex += localSize;
679 leftCoord = rightCoord;
A class for handling words, derived from string.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void sort()
(stable) sort the list (if changed after construction time)
#define forAll(list, i)
Loop across all elements in list.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static label nProcs(const label communicator=0)
Number of processes in parallel run.
FixedList< direction, 3 > decompOrder_
Decomposition order in terms of components.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
static label findLower(const List< scalar > &, const scalar t, const label left, const label right)
Find index of t in list inbetween indices left and right.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< scalar > mag(const dimensioned< Type > &)
void setDecompOrder()
Convert ordering string ("xyz") into list of components.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Geometrical domain decomposition.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
label findLower(const ListType &, typename ListType::const_reference, const label start, const BinaryOp &bop)
Find last element < given value in sorted list and return index,.
const dictionary & decompositionDict_
A list of keyword definitions, which are a keyword followed by any number of values (e....
A list that is sorted upon construction or when explicitly requested with the sort() method.
Macros for easy insertion into run-time selection tables.
void sortComponent(const label sizeTol, const pointField &, const labelList &slice, const direction componentIndex, const label prevMult, labelList &finalDecomp)
Recursively sort in x,y,z (or rather acc. to decompOrder_)
const double e
Elementary charge.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const dictionary & geomDecomDict_
prefixOSstream Pout(cout, "Pout")
static void calculateSortedWeightedSizes(const labelList ¤t, const labelList &indices, const scalarField &weights, const label globalCurrentSize, scalarField &sortedWeightedSizes)
Evaluates the weighted sizes for each sorted point.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
static void findBinary(const label sizeTol, const List< scalar > &, const label leftIndex, const scalar leftValue, const scalar maxValue, const scalar wantedSize, label &mid, scalar &midValue)
Find midValue (at local index mid) such that the number of.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void size(const label)
Override size to be inconsistent with allocated storage.
hierarchGeomDecomp(const hierarchGeomDecomp &)
virtual labelList decompose(const pointField &, const scalarField &weights)
Return for every coordinate the wanted processor number.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
const string & prefix() const
Return the prefix of the stream.