30 template<
class SourcePatch,
class TargetPatch>
33 const SourcePatch& srcPatch,
34 const TargetPatch& tgtPatch,
35 const label& srcFacei,
42 const vector srcP = srcCf[srcFacei];
44 DynamicList<label> tgtFaces(10);
45 tgtFaces.append(tgtFacei);
47 DynamicList<label> visitedFaces(10);
53 label tgtI = tgtFaces.remove();
54 visitedFaces.append(tgtI);
56 scalar dTest =
magSqr(tgtCf[tgtI] - srcP);
71 }
while (tgtFaces.size() > 0);
75 template<
class SourcePatch,
class TargetPatch>
84 const labelList& srcNbr = this->srcPatch_.faceFaces()[srcFacei];
90 label facei = srcNbr[i];
94 startSeedI = facei + 1;
105 tgtFacei = this->findTargetFace(facei);
109 const vectorField& srcCf = this->srcPatch_.faceCentres();
112 <<
"Unable to find target face for source face " 113 << srcFacei <<
" with face centre " << srcCf[srcFacei]
123 template<
class SourcePatch,
class TargetPatch>
126 const label tgtFacei,
127 const List<DynamicList<label>>& tgtToSrc
130 DynamicList<label> testFaces(10);
131 DynamicList<label> visitedFaces(10);
133 testFaces.append(tgtFacei);
138 label tgtI = testFaces.remove();
142 visitedFaces.append(tgtI);
144 if (tgtToSrc[tgtI].size())
146 return tgtToSrc[tgtI][0];
150 const labelList& nbrFaces = this->tgtPatch_.faceFaces()[tgtI];
154 if (
findIndex(visitedFaces, nbrFaces[i]) == -1)
156 testFaces.append(nbrFaces[i]);
161 }
while (testFaces.size());
170 template<
class SourcePatch,
class TargetPatch>
173 const SourcePatch& srcPatch,
174 const TargetPatch& tgtPatch,
178 const bool reverseTarget,
179 const bool requireMatch
197 template<
class SourcePatch,
class TargetPatch>
204 template<
class SourcePatch,
class TargetPatch>
241 boolList mapFlag(srcAddr.size(),
true);
244 label startSeedI = 0;
249 findNearestFace(this->srcPatch_, this->tgtPatch_, srcFacei, tgtFacei);
251 srcAddr[srcFacei].append(tgtFacei);
252 tgtAddr[tgtFacei].append(srcFacei);
254 mapFlag[srcFacei] =
false;
264 }
while (srcFacei >= 0);
269 const vectorField& srcCf = this->srcPatch_.faceCentres();
270 const vectorField& tgtCf = this->tgtPatch_.faceCentres();
272 forAll(tgtAddr, targetFacei)
274 if (tgtAddr[targetFacei].size() > 1)
276 const vector& tgtC = tgtCf[tgtFacei];
280 label srcFacei = srcFaces[0];
281 scalar d =
magSqr(tgtC - srcCf[srcFacei]);
283 for (
label i = 1; i < srcFaces.
size(); i++)
285 label srcI = srcFaces[i];
286 scalar dNew =
magSqr(tgtC - srcCf[srcI]);
295 srcFaces.
append(srcFacei);
303 if (tgtAddr[tgtFacei].empty())
305 label srcFacei = findMappedSrcFace(tgtFacei, tgtAddr);
318 tgtAddr[tgtFacei].append(srcFacei);
327 scalar magSf = this->srcMagSf_[i];
333 scalar magSf = this->tgtMagSf_[i];
Nearest-mapping Arbitrary Mesh Interface (AMI) method.
#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.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void size(const label)
Override size to be inconsistent with allocated storage.
volVectorField vectorField(fieldObject, mesh)
Vector< scalar > vector
A scalar version of the templated Vector.
virtual ~mapNearestAMI()
Destructor.
virtual void calculate(labelListList &srcAddress, scalarListList &srcWeights, labelListList &tgtAddress, scalarListList &tgtWeights, label srcFacei=-1, label tgtFacei=-1)
Update addressing and weights.
List< bool > boolList
Bool container classes.
List< scalar > scalarList
A List of scalars.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
List< label > labelList
A List of labels.
errorManip< error > abort(error &err)
Base class for Arbitrary Mesh Interface (AMI) methods.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
void clear()
Clear the addressed list, i.e. set the size to zero.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.