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()
137 label dummyMatch = -1;
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)
244 allTransforms[proci];
246 forAll(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()
355 const vector& sepVec = sepVecs[sVI];
357 if (
mag(sepVec) > SMALL)
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)
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;
456Foam::globalIndexAndTransform::globalIndexAndTransform(
const polyMesh&
mesh)
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)
537 List<labelPairList> pointToTrafos(mesh_.
nPoints());
543 const labelPair& transSign = patchTransformSign_[patchi];
545 if (transSign.first() > -1)
552 bool newTransform = uniqueTransform
562 trafos.append(transSign);
574 const globalMeshData& gmd = mesh_.globalData();
576 const labelList& meshPoints = cpp.meshPoints();
577 const mapDistribute& slavesMap = gmd.globalCoPointSlavesMap();
580 List<labelPairList> elems(slavesMap.constructSize());
583 elems[i] = pointToTrafos[meshPoints[i]];
587 slavesMap.distribute(elems,
false);
594 const labelList& slavePoints = slaves[i];
601 forAll(slaveTrafos, slaveI)
603 bool newTransform = uniqueTransform
605 mesh_.points()[meshPoints[i]],
613 trafos.append(slaveTrafos[slaveI]);
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Dynamically sized Field. Similar to DynamicList, but inheriting from a Field instead of a List.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
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.
const T & first() const noexcept
Access the first element.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
void setSize(const label n)
Same as resize().
T & first()
Access first element of the list, position [0].
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
@ gatherList
gatherList [manual algorithm]
@ broadcast
broadcast [MPI]
label size() const noexcept
The number of entries in the list.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
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 List data using default commsType, default flip/negate operator.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
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.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for handling debugging switches.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
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 labelPair.
List< labelList > labelListList
List of labelList.
dimensionedScalar sign(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
messageStream Info
Information stream (stdout output on master, null elsewhere).
static const Identity< scalar > I
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a 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)
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.