41 Foam::label Foam::globalIndexAndTransform::matchTransform
43 const List<transformer>& refTransforms,
44 label& matchedRefTransformI,
45 const transformer& testTransform,
50 matchedRefTransformI = -1;
54 const transformer& refTransform = refTransforms[i];
56 const scalar maxVectorMag =
sqrt
65 mag(refTransform.t() - testTransform.t())
66 /(maxVectorMag + vSmall)
75 scalar tensorDiff = 0;
77 if (refTransform.transforms() || testTransform.transforms())
80 mag(refTransform.T() - testTransform.T())
88 if (vectorDiff < 1 && tensorDiff < 1)
90 matchedRefTransformI = i;
99 const transformer testInvTransform =
inv(testTransform);
102 mag(refTransform.t() - testInvTransform.t())
103 /(maxVectorMag + vSmall)
108 if (refTransform.transforms() || testTransform.transforms())
111 mag(refTransform.T() - testInvTransform.T())
116 if (vectorDiff < 1 && tensorDiff < 1)
118 matchedRefTransformI = i;
129 void Foam::globalIndexAndTransform::determineTransforms()
131 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
133 DynamicList<transformer> localTransforms;
134 DynamicField<scalar> localTols;
136 label dummyMatch = -1;
142 if (isA<coupledPolyPatch>(pp))
144 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
157 cpp.matchTolerance(),
163 localTols.append(cpp.matchTolerance());
182 localTransforms.clear();
184 forAll(allTransforms, proci)
186 const List<transformer>& procTransVecs =
187 allTransforms[proci];
189 forAll(procTransVecs, pSVI)
191 const transformer&
transform = procTransVecs[pSVI];
202 allTols[proci][pSVI],
214 transforms_.transfer(localTransforms);
219 void Foam::globalIndexAndTransform::determineTransformPermutations()
221 label nTransformPermutations =
pow(
label(3), transforms_.size());
223 transformPermutations_.setSize(nTransformPermutations);
225 forAll(transformPermutations_, tPI)
229 label transformIndex = tPI;
236 const label w = (transformIndex % 3) - 1;
255 labelList permutationIndices(nIndependentTransforms(), 0);
256 nullTransformIndex_ = encodeTransformIndex(permutationIndices);
260 void Foam::globalIndexAndTransform::determinePatchTransformSign()
262 const polyBoundaryMesh&
patches = mesh_.boundaryMesh();
270 if (isA<coupledPolyPatch>(pp))
272 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
284 cpp.matchTolerance(),
294 bool Foam::globalIndexAndTransform::uniqueTransform
305 if (trafos.size() == 3)
311 <<
" is on patch " << mesh_.boundaryMesh()[
patchi].name();
316 <<
"Point " << pt <<
" is on a coupled patch";
319 <<
" with transformation " << patchTrafo
320 <<
" but also on 3 other patches with transforms "
322 <<
"This is not a space filling tiling and might"
323 <<
" indicate a setup problem and give problems"
324 <<
" for e.g. lagrangian tracking or interpolation" <<
endl;
346 transformPermutations_(),
347 patchTransformSign_()
349 determineTransforms();
351 determineTransformPermutations();
353 determinePatchTransformSign();
355 if (debug && transforms_.size() > 0)
359 Info<<
"Determined global transforms :" <<
endl;
360 Info<<
"\t\ttranslation\trotation" <<
endl;
363 Info<<
'\t' << i <<
'\t';
365 Info<< trafo.
t() <<
'\t' << trafo.
T() <<
endl;
370 Info<<
"\tpatch\ttransform\tsign" <<
endl;
376 <<
'\t' << patchTransformSign_[
patchi].first()
377 <<
'\t' << patchTransformSign_[
patchi].second()
384 Info<<
"Permutations of transformations:" <<
endl
385 <<
"\t\ttranslation\trotation" <<
endl;
386 forAll(transformPermutations_, i)
388 Info<<
'\t' << i <<
'\t';
389 const transformer& trafo = transformPermutations_[i];
390 Info<< trafo.
t() <<
'\t' << trafo.
T() <<
endl;
397 if (transforms_.size() > 0)
415 if (transSign.
first() > -1)
422 bool newTransform = uniqueTransform
453 elems[i] = pointToTrafos[meshPoints[i]];
464 const labelList& slavePoints = slaves[i];
471 forAll(slaveTrafos, slaveI)
473 bool newTransform = uniqueTransform
475 mesh_.
points()[meshPoints[i]],
483 trafos.
append(slaveTrafos[slaveI]);
#define forAll(list, i)
Loop across all elements in list.
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 &)
Append an element at the end of the list.
const Type & first() const
Return first.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
static bool master(const label communicator=0)
Am I the master process.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
label size() const
Return the number of elements in the UPtrList.
label constructSize() const
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.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const labelListList & globalCoPointSlaves() const
const distributionMap & globalCoPointSlavesMap() const
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
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.
const fvPatchList & patches
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar mp
Proton mass.
List< labelPair > labelPairList
List of labelPairs.
Pair< label > labelPair
Label pair.
List< label > labelList
A List of labels.
dimensionedScalar sign(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vector point
Point is a vector.
labelList first(const UList< labelPair > &p)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensionSet transform(const dimensionSet &)
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
dimensioned< scalar > magSqr(const dimensioned< Type > &)