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;
140 const polyPatch& pp = patches[
patchi];
142 if (isA<coupledPolyPatch>(pp))
144 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
148 if (transform.transformsPosition())
157 cpp.matchTolerance(),
162 localTransforms.append(transform);
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];
193 if (transform.transformsPosition())
202 allTols[proci][pSVI],
207 localTransforms.append(transform);
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();
264 patchTransformSign_.setSize(patches.size(),
labelPair(-1, 0));
268 const polyPatch& pp = patches[
patchi];
270 if (isA<coupledPolyPatch>(pp))
272 const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>(pp);
276 if (transform.transformsPosition())
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;
371 forAll(patchTransformSign_, patchi)
373 if (patchTransformSign_[patchi].first() != -1)
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
432 trafos.append(transSign);
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]);
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)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
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.
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.
const dimensionedScalar mp
Proton mass.
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,.
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 > &)
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.
dimensionSet transform(const dimensionSet &)
const labelListList & globalCoPointSlaves() const