44Foam::label Foam::globalIndexAndTransform::matchTransform
46 const List<vectorTensorTransform>& refTransforms,
47 label& matchedRefTransformI,
48 const vectorTensorTransform& testTransform,
53 matchedRefTransformI = -1;
57 const vectorTensorTransform& refTransform = refTransforms[i];
59 scalar maxVectorMag =
sqrt
68 mag(refTransform.t() - testTransform.t())
69 /(maxVectorMag + VSMALL)
78 scalar tensorDiff = 0;
80 if (refTransform.hasR() || testTransform.hasR())
83 mag(refTransform.R() - testTransform.R())
91 if (vectorDiff < 1 && tensorDiff < 1)
93 matchedRefTransformI = i;
103 mag(refTransform.t() + testTransform.t())
104 /(maxVectorMag + VSMALL)
109 if (refTransform.hasR() || testTransform.hasR())
112 mag(refTransform.R() - testTransform.R().T())
117 if (vectorDiff < 1 && tensorDiff < 1)
119 matchedRefTransformI = i;
130void Foam::globalIndexAndTransform::determineTransforms()
132 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
134 DynamicList<vectorTensorTransform> localTransforms;
135 DynamicField<scalar> localTols;
137 label dummyMatch = -1;
141 const polyPatch& pp =
patches[patchi];
149 isA<coupledPolyPatch>(pp)
151 isA<cyclicPolyPatch>(pp)
152 && refCast<const cyclicPolyPatch>(pp).
transform()
156 refCast<const coupledPolyPatch>(pp).
transform()
161 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
169 const vector& sepVec = sepVecs[sVI];
171 if (
mag(sepVec) > SMALL)
182 cpp.matchTolerance(),
188 localTols.append(cpp.matchTolerance());
193 else if (!cpp.parallel())
199 const tensor& transT = transTensors[tTI];
201 if (
mag(transT -
I) > SMALL)
212 cpp.matchTolerance(),
218 localTols.append(cpp.matchTolerance());
239 localTransforms.clear();
241 forAll(allTransforms, proci)
243 const List<vectorTensorTransform>& procTransVecs =
244 allTransforms[proci];
246 forAll(procTransVecs, pSVI)
248 const vectorTensorTransform&
transform = procTransVecs[pSVI];
259 allTols[proci][pSVI],
271 transforms_.transfer(localTransforms);
276void Foam::globalIndexAndTransform::determineTransformPermutations()
278 label nTransformPermutations =
pow(label(3), transforms_.size());
280 transformPermutations_.setSize(nTransformPermutations);
282 forAll(transformPermutations_, tPI)
286 label transformIndex = tPI;
293 const label w = (transformIndex % 3) - 1;
312 labelList permutationIndices(nIndependentTransforms(),
Zero);
313 nullTransformIndex_ = encodeTransformIndex(permutationIndices);
317void Foam::globalIndexAndTransform::determinePatchTransformSign()
319 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
325 const polyPatch& pp =
patches[patchi];
333 isA<coupledPolyPatch>(pp)
335 isA<cyclicPolyPatch>(pp)
336 && refCast<const cyclicPolyPatch>(pp).
transform()
340 refCast<const coupledPolyPatch>(pp).
transform()
345 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
355 const vector& sepVec = sepVecs[sVI];
357 if (
mag(sepVec) > SMALL)
359 vectorTensorTransform t(sepVec);
362 label
sign = matchTransform
367 cpp.matchTolerance(),
370 patchTransformSign_[patchi] =
376 else if (!cpp.parallel())
384 const tensor& transT = transTensors[tTI];
386 if (
mag(transT -
I) > SMALL)
388 vectorTensorTransform t(transT);
391 label
sign = matchTransform
396 cpp.matchTolerance(),
400 patchTransformSign_[patchi] =
410bool Foam::globalIndexAndTransform::uniqueTransform
418 if (!trafos.found(patchTrafo))
421 if (trafos.size() == 3)
427 <<
" is on patch " << mesh_.boundaryMesh()[patchi].name();
432 <<
"Point " << pt <<
" is on a coupled patch";
435 <<
" with transformation " << patchTrafo
436 <<
" but also on 3 other patches with transforms "
438 <<
"This is not a space filling tiling and might"
439 <<
" indicate a setup problem and give problems"
440 <<
" for e.g. lagrangian tracking or interpolation" <<
endl;
460 transformPermutations_(),
461 patchTransformSign_()
463 determineTransforms();
465 determineTransformPermutations();
467 determinePatchTransformSign();
469 if (debug && transforms_.size() > 0)
473 Info<<
"Determined global transforms :" <<
endl;
474 Info<<
"\t\ttranslation\trotation" <<
endl;
477 Info<<
'\t' << i <<
'\t';
481 Info<< trafo.
t() <<
'\t' << trafo.
R();
485 Info<< trafo.
t() <<
'\t' <<
"---";
492 Info<<
"\tpatch\ttransform\tsign" <<
endl;
493 forAll(patchTransformSign_, patchi)
495 if (patchTransformSign_[patchi].first() != -1)
498 <<
'\t' << patchTransformSign_[patchi].first()
499 <<
'\t' << patchTransformSign_[patchi].second()
506 Info<<
"Permutations of transformations:" <<
endl
507 <<
"\t\ttranslation\trotation" <<
endl;
508 forAll(transformPermutations_, i)
510 Info<<
'\t' << i <<
'\t';
514 Info<< trafo.
t() <<
'\t' << trafo.
R();
518 Info<< trafo.
t() <<
'\t' <<
"---";
527 if (transforms_.size() > 0)
543 const labelPair& transSign = patchTransformSign_[patchi];
545 if (transSign.
first() > -1)
552 bool newTransform = uniqueTransform
583 elems[i] = pointToTrafos[meshPoints[i]];
594 const labelList& slavePoints = slaves[i];
601 forAll(slaveTrafos, slaveI)
603 bool newTransform = uniqueTransform
605 mesh_.
points()[meshPoints[i]],
613 trafos.
append(slaveTrafos[slaveI]);
T & first() noexcept
The first element of the list, position [0].
const word & name() const noexcept
Return the object name.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void append(const T &val)
Append an element at the end of the list.
A list of faces which address into the list of points.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
static void scatter(const List< commsStruct > &comms, T &value, const int tag, const label comm)
Broadcast data: Distribute without modification.
void setSize(const label newLen)
Same as resize()
label size() const noexcept
The number of elements in the list.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const mapDistribute & globalCoPointSlavesMap() const
const labelListList & globalCoPointSlaves() const
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
label constructSize() const noexcept
Constructed data size.
Class containing processor-to-processor mapping information.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
const globalMeshData & globalData() const
Return parallel info.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
label nPoints() const noexcept
Number of mesh points.
int myProcNo() const noexcept
Return processor number.
splitCell * master() const
Tensor of scalars, i.e. Tensor<scalar>.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define WarningInFunction
Report a warning using Foam::Warning.
Pair< label > labelPair
A pair of labels.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< labelPair > labelPairList
List of labelPairs.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
dimensionedScalar sign(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static const Identity< scalar > I
vector point
Point is a vector.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0)
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.