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];
144 isA<coupledPolyPatch>(pp)
146 isA<cyclicPolyPatch>(pp)
148 refCast<const cyclicPolyPatch>(pp).
transform()
154 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
162 const vector& sepVec = sepVecs[sVI];
164 if (
mag(sepVec) > SMALL)
175 cpp.matchTolerance(),
180 localTransforms.append(transform);
181 localTols.append(cpp.matchTolerance());
186 else if (!cpp.parallel())
192 const tensor& transT = transTensors[tTI];
194 if (
mag(transT -
I) > SMALL)
205 cpp.matchTolerance(),
210 localTransforms.append(transform);
211 localTols.append(cpp.matchTolerance());
232 localTransforms.clear();
234 forAll(allTransforms, proci)
236 const List<vectorTensorTransform>& procTransVecs =
237 allTransforms[proci];
239 forAll(procTransVecs, pSVI)
241 const vectorTensorTransform& transform = procTransVecs[pSVI];
243 if (
mag(transform.t()) > SMALL || transform.hasR())
252 allTols[proci][pSVI],
257 localTransforms.append(transform);
264 transforms_.transfer(localTransforms);
269 void Foam::globalIndexAndTransform::determineTransformPermutations()
271 label nTransformPermutations =
pow(
label(3), transforms_.size());
273 transformPermutations_.setSize(nTransformPermutations);
275 forAll(transformPermutations_, tPI)
279 label transformIndex = tPI;
286 const label w = (transformIndex % 3) - 1;
292 transform &= transforms_[
b];
296 transform &=
inv(transforms_[
b]);
305 labelList permutationIndices(nIndependentTransforms(), 0);
306 nullTransformIndex_ = encodeTransformIndex(permutationIndices);
310 void Foam::globalIndexAndTransform::determinePatchTransformSign()
312 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
314 patchTransformSign_.setSize(patches.size(),
labelPair(-1, 0));
318 const polyPatch& pp = patches[
patchi];
324 isA<coupledPolyPatch>(pp)
326 isA<cyclicPolyPatch>(pp)
328 refCast<const cyclicPolyPatch>(pp).
transform()
334 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
344 const vector& sepVec = sepVecs[sVI];
346 if (
mag(sepVec) > SMALL)
348 vectorTensorTransform t(sepVec);
356 cpp.matchTolerance(),
359 patchTransformSign_[
patchi] =
365 else if (!cpp.parallel())
373 const tensor& transT = transTensors[tTI];
375 if (
mag(transT -
I) > SMALL)
377 vectorTensorTransform t(transT);
385 cpp.matchTolerance(),
389 patchTransformSign_[
patchi] =
399 bool Foam::globalIndexAndTransform::uniqueTransform
410 if (trafos.size() == 3)
416 <<
" is on patch " << mesh_.boundaryMesh()[
patchi].name();
421 <<
"Point " << pt <<
" is on a coupled patch";
424 <<
" with transformation " << patchTrafo
425 <<
" but also on 3 other patches with transforms " 427 <<
"This is not a space filling tiling and might" 428 <<
" indicate a setup problem and give problems" 429 <<
" for e.g. lagrangian tracking or interpolation" <<
endl;
447 Foam::globalIndexAndTransform::globalIndexAndTransform(
const polyMesh&
mesh)
451 transformPermutations_(),
452 patchTransformSign_()
454 determineTransforms();
456 determineTransformPermutations();
458 determinePatchTransformSign();
460 if (debug && transforms_.size() > 0)
464 Info<<
"Determined global transforms :" <<
endl;
465 Info<<
"\t\ttranslation\trotation" <<
endl;
468 Info<<
'\t' << i <<
'\t';
472 Info<< trafo.
t() <<
'\t' << trafo.
R();
476 Info<< trafo.
t() <<
'\t' <<
"---";
483 Info<<
"\tpatch\ttransform\tsign" <<
endl;
484 forAll(patchTransformSign_, patchi)
486 if (patchTransformSign_[patchi].first() != -1)
489 <<
'\t' << patchTransformSign_[
patchi].first()
490 <<
'\t' << patchTransformSign_[
patchi].second()
497 Info<<
"Permutations of transformations:" << endl
498 <<
"\t\ttranslation\trotation" <<
endl;
499 forAll(transformPermutations_, i)
501 Info<<
'\t' << i <<
'\t';
505 Info<< trafo.
t() <<
'\t' << trafo.
R();
509 Info<< trafo.
t() <<
'\t' <<
"---";
518 if (transforms_.size() > 0)
536 if (transSign.
first() > -1)
543 bool newTransform = uniqueTransform
553 trafos.append(transSign);
574 elems[i] = pointToTrafos[meshPoints[i]];
585 const labelList& slavePoints = slaves[i];
592 forAll(slaveTrafos, slaveI)
594 bool newTransform = uniqueTransform
596 mesh_.
points()[meshPoints[i]],
604 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 occurence 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