33bool Foam::globalIndexAndTransform::less::operator()
39 label procA = gi_.processor(a);
40 label procB = gi_.processor(
b);
46 else if (procA > procB)
53 label indexA = gi_.index(a);
54 label indexB = gi_.index(
b);
60 else if (indexA > indexB)
67 label transformA = gi_.transformIndex(a);
68 label transformB = gi_.transformIndex(
b);
70 return transformA < transformB;
78 const labelList& permutationIndices
81 if (permutationIndices.size() != transforms_.size())
84 <<
"permutationIndices " << permutationIndices
85 <<
"are of a different size to the number of independent transforms"
95 if (
mag(permutationIndices[
b]) > 1)
98 <<
"permutationIndices " << permutationIndices
99 <<
"are illegal, they must all be only -1, 0 or +1"
114 const label transformIndex
119 label t = transformIndex;
122 permutation[i] = (t%3)-1;
132 const label transformIndex,
134 const bool isSendingSide,
138 const labelPair& transSign = patchTransformSign_[patchi];
140 label matchTransI = transSign.
first();
142 if (matchTransI >= transforms_.size())
145 <<
"patch:" << mesh_.boundaryMesh()[patchi].name()
146 <<
" transform:" << matchTransI
147 <<
" out of possible transforms:" << transforms_
151 else if (matchTransI == -1)
154 return transformIndex;
159 labelList permutation(decodeTransformIndex(transformIndex));
165 label
sign = transSign.second();
173 if (permutation[matchTransI] != 0)
179 <<
"patch:" << mesh_.boundaryMesh()[patchi].name()
180 <<
" transform:" << matchTransI <<
" sign:" <<
sign
181 <<
" current transforms:" << permutation
184 else if (
sign == permutation[matchTransI])
191 bool antiCyclic =
false;
194 if (
mag(vt.t()) < SMALL && vt.hasR())
197 scalar sumDiag =
tr(
R);
198 scalar sumMagDiag =
mag(
R.xx())+
mag(
R.yy())+
mag(
R.zz());
200 if (
mag(sumMagDiag-3) < tol &&
mag(sumDiag+1) < tol)
209 permutation[matchTransI] = 0;
214 <<
"More than one patch accessing the same transform "
215 <<
"but not of the same sign." <<
endl
216 <<
"patch:" << mesh_.boundaryMesh()[patchi].name()
217 <<
" transform:" << matchTransI <<
" sign:" <<
sign
218 <<
" current transforms:" << permutation
224 permutation[matchTransI] = 0;
229 permutation[matchTransI] =
sign;
243 const label transformIndex0,
244 const label transformIndex1
247 if (transformIndex0 == transformIndex1)
249 return transformIndex0;
254 labelList permutation0(decodeTransformIndex(transformIndex0));
258 if (permutation0[i] != 0)
264 labelList permutation1(decodeTransformIndex(transformIndex1));
268 if (permutation1[i] != 0)
276 return transformIndex0;
280 return transformIndex1;
287 const label transformIndex0,
288 const label transformIndex1
291 labelList permutation0(decodeTransformIndex(transformIndex0));
292 labelList permutation1(decodeTransformIndex(transformIndex1));
296 permutation0[i] -= permutation1[i];
299 return encodeTransformIndex(permutation0);
317 const label transformIndex
320 if (transformIndex < 0 || transformIndex >= transformPermutations_.size())
323 <<
"TransformIndex " << transformIndex
324 <<
" is outside allowed range of 0 to "
325 << transformPermutations_.size() - 1
329 if (proci >
labelMax/transformPermutations_.size())
332 <<
"Overflow : encoding processor " << proci
333 <<
" in base " << transformPermutations_.size()
334 <<
" exceeds capability of label (" <<
labelMax
335 <<
"). Please recompile with larger datatype for label."
352 return globalIAndTransform.
first();
361 return globalIAndTransform.
second()/transformPermutations_.size();
370 return globalIAndTransform.
second()%transformPermutations_.size();
376 return transforms_.size();
390 return transformPermutations_;
396 return nullTransformIndex_;
403 return patchTransformSign_;
425 if (patchis.
empty() || transforms_.empty())
427 return selectedTransformIs;
430 for (
const label patchi : patchis)
432 const labelPair& transSign = patchTransformSign_[patchi];
434 label matchTransI = transSign.
first();
436 if (matchTransI > -1)
438 label
sign = transSign.second();
441 if (permutation[matchTransI] != 0)
447 if (permutation[matchTransI] !=
sign)
450 <<
"More than one patch accessing the same transform "
451 <<
"but not of the same sign."
457 permutation[matchTransI] =
sign;
462 label nUsedTrans = round(
sum(
mag(permutation)));
466 return selectedTransformIs;
470 label nSelTrans =
pow(label(2), nUsedTrans) - 1;
474 selectedTransformIs.setSize(nSelTrans);
480 selectedTransformIs[0] = encodeTransformIndex(permutation);
493 if (transforms_.size() > nUsedTrans)
495 if (permutation[0] == 0)
500 else if (permutation[1] == 0)
505 else if (permutation[2] == 0)
512 tempPermutation[a] = a;
513 tempPermutation[
b] = permutation[
b];
515 selectedTransformIs[0] = encodeTransformIndex(tempPermutation);
517 tempPermutation[a] = permutation[a];
518 tempPermutation[
b] = a;
520 selectedTransformIs[1] = encodeTransformIndex(tempPermutation);
522 tempPermutation[a] = permutation[a];
523 tempPermutation[
b] = permutation[
b];
525 selectedTransformIs[2] = encodeTransformIndex(tempPermutation);
533 tempPermutation[0] = 0;
534 tempPermutation[1] = 0;
535 tempPermutation[2] = permutation[2];
537 selectedTransformIs[0] = encodeTransformIndex(tempPermutation);
539 tempPermutation[0] = 0;
540 tempPermutation[1] = permutation[1];
541 tempPermutation[2] = 0;
543 selectedTransformIs[1] = encodeTransformIndex(tempPermutation);
545 tempPermutation[0] = 0;
546 tempPermutation[1] = permutation[1];
547 tempPermutation[2] = permutation[2];
549 selectedTransformIs[2] = encodeTransformIndex(tempPermutation);
551 tempPermutation[0] = permutation[0];
552 tempPermutation[1] = 0;
553 tempPermutation[2] = 0;
555 selectedTransformIs[3] = encodeTransformIndex(tempPermutation);
557 tempPermutation[0] = permutation[0];
558 tempPermutation[1] = 0;
559 tempPermutation[2] = permutation[2];
561 selectedTransformIs[4] = encodeTransformIndex(tempPermutation);
563 tempPermutation[0] = permutation[0];
564 tempPermutation[1] = permutation[1];
565 tempPermutation[2] = 0;
567 selectedTransformIs[5] = encodeTransformIndex(tempPermutation);
569 tempPermutation[0] = permutation[0];
570 tempPermutation[1] = permutation[1];
571 tempPermutation[2] = permutation[2];
573 selectedTransformIs[6] = encodeTransformIndex(tempPermutation);
580 <<
"Only 1-3 transforms are possible."
585 return selectedTransformIs;
595 labelList transIs = transformIndicesForPatches(patchis);
603 transPts[tII] = transformPermutations_[transIs[tII]].transformPosition
#define R(A, B, C, D, E, F, K, M)
bool empty() const noexcept
True if the hash table is empty.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
const T & first() const noexcept
Access the first element.
const T & second() const noexcept
Access the second element.
void size(const label n)
Older name for setAddressableSize.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Pair< label > labelPair
A pair of labels.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
List< labelPair > labelPairList
List of labelPair.
dimensionedScalar sign(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
vector point
Point is a vector.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define forAll(list, i)
Loop across all elements in list.