44 Foam::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;
130 void 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);
276 void 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);
317 void 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] =
410 bool 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;
456 Foam::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());
541 const polyPatch& pp =
patches[patchi];
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]);
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
dimensionedScalar sign(const dimensionedScalar &ds)
List< labelList > labelListList
A List of labelList.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label nPoints() const noexcept
Number of mesh points.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
constexpr char nl
The newline '\n' character (0x0a)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field...
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator) is 1 for serial run.
static void gatherList(const List< commsStruct > &comms, List< T > &values, const int tag, const label comm)
Gather data, but keep individual values separate. Uses the specified communication schedule...
static const Identity< scalar > I
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
label size() const noexcept
The number of elements in the list.
const globalMeshData & globalData() const
Return parallel info.
List< labelPair > labelPairList
List of labelPairs.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
defineTypeNameAndDebug(combustionModel, 0)
void setSize(const label newLen)
Same as resize()
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text...
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
static bool master(const label communicator=worldComm)
Am I the master rank.
const polyBoundaryMesh & patches
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
const dimensionedScalar mp
Proton mass.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0)