34 const label globalIndexAndTransform::base_ = 32;
40 Foam::label Foam::globalIndexAndTransform::matchTransform
42 const List<vectorTensorTransform>& refTransforms,
43 label& matchedRefTransformI,
44 const vectorTensorTransform& testTransform,
49 matchedRefTransformI = -1;
53 const vectorTensorTransform& refTransform = refTransforms[i];
55 scalar maxVectorMag =
sqrt 64 mag(refTransform.t() - testTransform.t())
65 /(maxVectorMag + VSMALL)
74 scalar tensorDiff = 0;
76 if (refTransform.hasR() || testTransform.hasR())
79 mag(refTransform.R() - testTransform.R())
87 if (vectorDiff < 1 && tensorDiff < 1)
89 matchedRefTransformI = i;
99 mag(refTransform.t() + testTransform.t())
100 /(maxVectorMag + VSMALL)
105 if (refTransform.hasR() || testTransform.hasR())
108 mag(refTransform.R() - testTransform.R().T())
113 if (vectorDiff < 1 && tensorDiff < 1)
115 matchedRefTransformI = i;
126 void Foam::globalIndexAndTransform::determineTransforms()
128 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
130 transforms_ = List<vectorTensorTransform>(6);
135 label dummyMatch = -1;
139 const polyPatch& pp = patches[
patchi];
145 isA<coupledPolyPatch>(pp)
147 isA<cyclicPolyPatch>(pp)
149 refCast<const cyclicPolyPatch>(pp).
transform()
155 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
163 const vector& sepVec = sepVecs[sVI];
165 if (
mag(sepVec) > SMALL)
176 cpp.matchTolerance(),
184 <<
"More than six unsigned transforms" 185 <<
" detected:" <<
nl << transforms_
189 maxTol[nextTrans++] = cpp.matchTolerance();
194 else if (!cpp.parallel())
200 const tensor& transT = transTensors[tTI];
202 if (
mag(transT -
I) > SMALL)
213 cpp.matchTolerance(),
221 <<
"More than six unsigned transforms" 222 <<
" detected:" <<
nl << transforms_
226 maxTol[nextTrans++] = cpp.matchTolerance();
248 transforms_ = List<vectorTensorTransform>(3);
252 forAll(allTransforms, proci)
254 const List<vectorTensorTransform>& procTransVecs =
255 allTransforms[proci];
257 forAll(procTransVecs, pSVI)
259 const vectorTensorTransform& transform = procTransVecs[pSVI];
261 if (
mag(transform.t()) > SMALL || transform.hasR())
270 allTols[proci][pSVI],
281 <<
"More than three independent basic " 282 <<
"transforms detected:" <<
nl 291 transforms_.setSize(nextTrans);
296 if (transforms_.size() > 3)
299 <<
"More than three independent basic " 300 <<
"transforms detected:" <<
nl 302 <<
"This is not a space filling tiling and will probably" 303 <<
" give problems for e.g. lagrangian tracking or interpolation" 309 void Foam::globalIndexAndTransform::determineTransformPermutations()
311 label nTransformPermutations =
pow(
label(3), transforms_.size());
313 transformPermutations_.setSize(nTransformPermutations);
315 forAll(transformPermutations_, tPI)
319 label transformIndex = tPI;
326 const label w = (transformIndex % 3) - 1;
332 transform &= transforms_[
b];
336 transform &=
inv(transforms_[
b]);
345 labelList permutationIndices(nIndependentTransforms(), 0);
346 nullTransformIndex_ = encodeTransformIndex(permutationIndices);
350 void Foam::globalIndexAndTransform::determinePatchTransformSign()
352 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
354 patchTransformSign_.setSize(patches.size(), Pair<label>(-1, 0));
356 label matchTransI = -1;
360 const polyPatch& pp = patches[
patchi];
368 isA<coupledPolyPatch>(pp)
370 isA<cyclicPolyPatch>(pp)
372 refCast<const cyclicPolyPatch>(pp).
transform()
378 const coupledPolyPatch& cpp =
379 refCast<const coupledPolyPatch>(pp);
391 const vector& sepVec = sepVecs[sVI];
393 if (
mag(sepVec) > SMALL)
395 vectorTensorTransform t(sepVec);
402 cpp.matchTolerance(),
419 patchTransformSign_[
patchi] =
420 Pair<label>(matchTransI,
sign);
425 else if (!cpp.parallel())
435 const tensor& transT = transTensors[tTI];
437 if (
mag(transT -
I) > SMALL)
439 vectorTensorTransform t(transT);
446 cpp.matchTolerance(),
463 patchTransformSign_[
patchi] =
464 Pair<label>(matchTransI,
sign);
477 Foam::globalIndexAndTransform::globalIndexAndTransform
484 transformPermutations_(),
485 patchTransformSign_()
487 determineTransforms();
489 determineTransformPermutations();
491 determinePatchTransformSign();
493 if (debug && transforms_.size() > 0)
497 Info<<
"Determined global transforms :" <<
endl;
498 Info<<
"\t\ttranslation\trotation" <<
endl;
501 Info<<
'\t' << i <<
'\t';
505 Info<< trafo.
t() <<
'\t' << trafo.
R();
509 Info<< trafo.
t() <<
'\t' <<
"---";
516 Info<<
"\tpatch\ttransform\tsign" <<
endl;
519 if (patchTransformSign_[
patchi].first() != -1)
522 <<
'\t' << patchTransformSign_[
patchi].first()
523 <<
'\t' << patchTransformSign_[
patchi].second()
530 Info<<
"Permutations of transformations:" << endl
531 <<
"\t\ttranslation\trotation" <<
endl;
532 forAll(transformPermutations_, i)
534 Info<<
'\t' << i <<
'\t';
538 Info<< trafo.
t() <<
'\t' << trafo.
R();
542 Info<< trafo.
t() <<
'\t' <<
"---";
546 Info<<
"nullTransformIndex:" << nullTransformIndex() << endl
dimensionedScalar sign(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool master(const label communicator=0)
Am I the master process.
Vector< scalar > vector
A scalar version of the templated Vector.
static const Identity< scalar > I
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< label > labelList
A List of labels.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
static label nProcs(const label communicator=0)
Number of processes in parallel run.
#define WarningInFunction
Report a warning using Foam::Warning.
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
Tensor< scalar > tensor
Tensor of scalars.
const word & name() const
Return name.
dimensionSet transform(const dimensionSet &)