41 Foam::label Foam::globalIndexAndTransform::matchTransform
43 const List<vectorTensorTransform>& refTransforms,
44 label& matchedRefTransformI,
45 const vectorTensorTransform& testTransform,
50 matchedRefTransformI = -1;
54 const vectorTensorTransform& refTransform = refTransforms[i];
56 scalar maxVectorMag =
sqrt 65 mag(refTransform.t() - testTransform.t())
66 /(maxVectorMag + vSmall)
75 scalar tensorDiff = 0;
77 if (refTransform.hasR() || testTransform.hasR())
80 mag(refTransform.R() - testTransform.R())
88 if (vectorDiff < 1 && tensorDiff < 1)
90 matchedRefTransformI = i;
100 mag(refTransform.t() + testTransform.t())
101 /(maxVectorMag + vSmall)
106 if (refTransform.hasR() || testTransform.hasR())
109 mag(refTransform.R() - testTransform.R().T())
114 if (vectorDiff < 1 && tensorDiff < 1)
116 matchedRefTransformI = i;
127 void Foam::globalIndexAndTransform::determineTransforms()
129 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
131 DynamicList<vectorTensorTransform> localTransforms;
132 DynamicField<scalar> localTols;
134 label dummyMatch = -1;
138 const polyPatch& pp = patches[
patchi];
146 isA<coupledPolyPatch>(pp)
148 isA<cyclicPolyPatch>(pp)
149 && refCast<const cyclicPolyPatch>(pp).
transform()
153 refCast<const coupledPolyPatch>(pp).
transform()
158 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
166 const vector& sepVec = sepVecs[sVI];
168 if (
mag(sepVec) > small)
179 cpp.matchTolerance(),
184 localTransforms.append(transform);
185 localTols.append(cpp.matchTolerance());
190 else if (!cpp.parallel())
196 const tensor& transT = transTensors[tTI];
198 if (
mag(transT -
I) > small)
209 cpp.matchTolerance(),
214 localTransforms.append(transform);
215 localTols.append(cpp.matchTolerance());
236 localTransforms.clear();
238 forAll(allTransforms, proci)
240 const List<vectorTensorTransform>& procTransVecs =
241 allTransforms[proci];
243 forAll(procTransVecs, pSVI)
245 const vectorTensorTransform& transform = procTransVecs[pSVI];
247 if (
mag(transform.t()) > small || transform.hasR())
256 allTols[proci][pSVI],
261 localTransforms.append(transform);
268 transforms_.transfer(localTransforms);
273 void Foam::globalIndexAndTransform::determineTransformPermutations()
275 label nTransformPermutations =
pow(
label(3), transforms_.size());
277 transformPermutations_.setSize(nTransformPermutations);
279 forAll(transformPermutations_, tPI)
283 label transformIndex = tPI;
290 const label w = (transformIndex % 3) - 1;
296 transform &= transforms_[
b];
300 transform &=
inv(transforms_[
b]);
309 labelList permutationIndices(nIndependentTransforms(), 0);
310 nullTransformIndex_ = encodeTransformIndex(permutationIndices);
314 void Foam::globalIndexAndTransform::determinePatchTransformSign()
316 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
318 patchTransformSign_.setSize(patches.size(),
labelPair(-1, 0));
322 const polyPatch& pp = patches[
patchi];
330 isA<coupledPolyPatch>(pp)
332 isA<cyclicPolyPatch>(pp)
333 && refCast<const cyclicPolyPatch>(pp).
transform()
337 refCast<const coupledPolyPatch>(pp).
transform()
342 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
352 const vector& sepVec = sepVecs[sVI];
354 if (
mag(sepVec) > small)
356 vectorTensorTransform t(sepVec);
364 cpp.matchTolerance(),
367 patchTransformSign_[
patchi] =
373 else if (!cpp.parallel())
381 const tensor& transT = transTensors[tTI];
383 if (
mag(transT -
I) > small)
385 vectorTensorTransform t(transT);
393 cpp.matchTolerance(),
397 patchTransformSign_[
patchi] =
407 bool Foam::globalIndexAndTransform::uniqueTransform
418 if (trafos.size() == 3)
424 <<
" is on patch " << mesh_.boundaryMesh()[
patchi].name();
429 <<
"Point " << pt <<
" is on a coupled patch";
432 <<
" with transformation " << patchTrafo
433 <<
" but also on 3 other patches with transforms " 435 <<
"This is not a space filling tiling and might" 436 <<
" indicate a setup problem and give problems" 437 <<
" for e.g. lagrangian tracking or interpolation" <<
endl;
455 Foam::globalIndexAndTransform::globalIndexAndTransform(
const polyMesh&
mesh)
459 transformPermutations_(),
460 patchTransformSign_()
462 determineTransforms();
464 determineTransformPermutations();
466 determinePatchTransformSign();
468 if (debug && transforms_.size() > 0)
472 Info<<
"Determined global transforms :" <<
endl;
473 Info<<
"\t\ttranslation\trotation" <<
endl;
476 Info<<
'\t' << i <<
'\t';
480 Info<< trafo.
t() <<
'\t' << trafo.
R();
484 Info<< trafo.
t() <<
'\t' <<
"---";
491 Info<<
"\tpatch\ttransform\tsign" <<
endl;
492 forAll(patchTransformSign_, patchi)
494 if (patchTransformSign_[patchi].first() != -1)
497 <<
'\t' << patchTransformSign_[
patchi].first()
498 <<
'\t' << patchTransformSign_[
patchi].second()
505 Info<<
"Permutations of transformations:" << endl
506 <<
"\t\ttranslation\trotation" <<
endl;
507 forAll(transformPermutations_, i)
509 Info<<
'\t' << i <<
'\t';
513 Info<< trafo.
t() <<
'\t' << trafo.
R();
517 Info<< trafo.
t() <<
'\t' <<
"---";
526 if (transforms_.size() > 0)
544 if (transSign.
first() > -1)
551 bool newTransform = uniqueTransform
561 trafos.append(transSign);
582 elems[i] = pointToTrafos[meshPoints[i]];
593 const labelList& slavePoints = slaves[i];
600 forAll(slaveTrafos, slaveI)
602 bool newTransform = uniqueTransform
604 mesh_.
points()[meshPoints[i]],
612 trafos.append(slaveTrafos[slaveI]);
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
dimensionedScalar sign(const dimensionedScalar &ds)
const mapDistribute & globalCoPointSlavesMap() const
#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.
const word & name() const
Return name.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
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.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
virtual const pointField & points() const
Return raw points.
A list of faces which address into the list of points.
An ordered pair of two objects of type <T> with first() and second() elements.
static const Identity< scalar > I
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Pair< label > labelPair
Label pair.
const globalMeshData & globalData() const
Return parallel info.
List< label > labelList
A List of labels.
List< labelPair > labelPairList
List of labelPairs.
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)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
label constructSize() const
Constructed data size.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Class containing processor-to-processor mapping information.
vector point
Point is a vector.
#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.
A patch is a list of labels that address the faces in the global face list.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
const Type & first() const
Return first.
Tensor< scalar > tensor
Tensor of scalars.
const dimensionedScalar mp
Proton mass.
dimensionSet transform(const dimensionSet &)
const labelListList & globalCoPointSlaves() const