30 template<
class SourcePatch,
class TargetPatch>
44 label nFacesRemaining = srcAddr.size();
54 seedFaces[srcFacei] = tgtFacei;
57 boolList mapFlag(nFacesRemaining,
true);
66 bool faceProcessed = processSourceFace
80 mapFlag[srcFacei] =
false;
86 nonOverlapFaces.
append(srcFacei);
90 if (nFacesRemaining > 0)
102 }
while (nFacesRemaining > 0);
104 this->srcNonOverlap_.transfer(nonOverlapFaces);
108 template<
class SourcePatch,
class TargetPatch>
111 const label srcFacei,
112 const label tgtStartFacei,
126 if (tgtStartFacei == -1)
132 visitedFaces.
clear();
135 nbrFaces.
append(tgtStartFacei);
144 const scalar srcArea = this->srcMagSf_[srcFacei];
146 bool faceProcessed =
false;
152 visitedFaces.
append(tgtFacei);
153 const scalar tgtArea = this->tgtMagSf_[tgtFacei];
156 const scalar area = interArea(srcFacei, tgtFacei);
159 if (area/srcArea > minWeight())
161 srcAddr[srcFacei].append(tgtFacei);
162 srcWght[srcFacei].append(area/srcArea);
164 tgtAddr[tgtFacei].append(srcFacei);
165 tgtWght[tgtFacei].append(area/tgtArea);
175 faceProcessed =
true;
178 }
while (nbrFaces.
size() > 0);
180 return faceProcessed;
184 template<
class SourcePatch,
class TargetPatch>
196 const labelList& srcNbrFaces = this->srcPatch_.faceFaces()[srcFacei];
202 bool valuesSet =
false;
205 label faceS = srcNbrFaces[i];
207 if (mapFlag[faceS] && seedFaces[faceS] == -1)
211 label faceT = visitedFaces[j];
212 scalar area = interArea(faceS, faceT);
213 scalar areaTotal = this->srcMagSf_[srcFacei];
216 if (area/areaTotal > minWeight())
220 seedFaces[faceS] = faceT;
241 bool foundNextSeed =
false;
242 for (
label facei = startSeedI; facei < mapFlag.
size(); facei++)
249 foundNextSeed =
true;
252 if (seedFaces[facei] != -1)
255 tgtFacei = seedFaces[facei];
265 Pout<<
"Advancing front stalled: searching for new " 266 <<
"target face" <<
endl;
269 foundNextSeed =
false;
270 for (
label facei = startSeedI; facei < mapFlag.
size(); facei++)
276 startSeedI = facei + 1;
277 foundNextSeed =
true;
281 tgtFacei = this->findTargetFace(srcFacei);
299 template<
class SourcePatch,
class TargetPatch>
302 const label srcFacei,
308 const pointField& srcPoints = this->srcPatch_.points();
309 const pointField& tgtPoints = this->tgtPatch_.points();
312 const face& src = this->srcPatch_[srcFacei];
313 const face& tgt = this->tgtPatch_[tgtFacei];
317 const scalar tgtMag = tgt.
mag(tgtPoints);
318 if ((this->srcMagSf_[srcFacei] < rootVSmall) || (tgtMag < rootVSmall))
327 vector n(-this->srcPatch_.faceNormals()[srcFacei]);
328 if (this->reverseTarget_)
330 n -= this->tgtPatch_.faceNormals()[tgtFacei];
334 n += this->tgtPatch_.faceNormals()[tgtFacei];
336 scalar magN =
mag(
n);
338 if (magN > rootVSmall)
340 area = inter.
calc(src, tgt,
n/magN, this->triMode_);
345 <<
"Invalid normal for source face " << srcFacei
347 <<
" target face " << tgtFacei
353 if ((debug > 1) && (area > 0))
355 this->writeIntersectionOBJ(area, src, tgt, srcPoints, tgtPoints);
362 template<
class SourcePatch,
class TargetPatch>
378 const scalar
s =
sum(srcWght[srcFacei]);
382 lowWeightFaces.
insert(srcFacei);
388 Pout<<
"faceAreaWeightAMI: restarting search on " 389 << lowWeightFaces.
size() <<
" faces since sum of weights < 0.5" 393 if (lowWeightFaces.
size() > 0)
403 okSrcWeights.
clear();
408 if (!lowWeightFaces.
found(srcFaces[i]))
410 okSrcFaces.
append(srcFaces[i]);
411 okSrcWeights.
append(srcWeights[i]);
414 if (okSrcFaces.
size() < srcFaces.
size())
434 label srcFacei = iter.key();
435 label tgtFacei = this->findTargetFace(srcFacei);
459 template<
class SourcePatch,
class TargetPatch>
463 return faceAreaIntersect::tolerance();
469 template<
class SourcePatch,
class TargetPatch>
472 const SourcePatch& srcPatch,
473 const TargetPatch& tgtPatch,
477 const bool reverseTarget,
478 const bool requireMatch,
479 const bool restartUncoveredSourceFace
492 restartUncoveredSourceFace_(restartUncoveredSourceFace)
498 template<
class SourcePatch,
class TargetPatch>
505 template<
class SourcePatch,
class TargetPatch>
548 if (debug && !this->srcNonOverlap_.empty())
550 Pout<<
" AMI: " << this->srcNonOverlap_.size()
551 <<
" non-overlap faces identified" 557 if (restartUncoveredSourceFace_)
559 restartUncoveredSourceFace
virtual void calcAddressing(List< DynamicList< label >> &srcAddress, List< DynamicList< scalar >> &srcWeights, List< DynamicList< label >> &tgtAddress, List< DynamicList< scalar >> &tgtWeights, label srcFacei, label tgtFacei)
Calculate addressing and weights using temporary storage.
virtual scalar interArea(const label srcFacei, const label tgtFacei) const
Area of intersection between source and target faces.
virtual bool processSourceFace(const label srcFacei, const label tgtStartFacei, DynamicList< label > &nbrFaces, DynamicList< label > &visitedFaces, List< DynamicList< label >> &srcAddr, List< DynamicList< scalar >> &srcWght, List< DynamicList< label >> &tgtAddr, List< DynamicList< scalar >> &tgtWght)
Determine overlap contributions for source face srcFacei.
#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.
A face is a list of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool insert(const Key &key)
Insert a new entry.
virtual ~faceAreaWeightAMI()
Destructor.
label size() const
Return number of elements in table.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
virtual void calculate(labelListList &srcAddress, scalarListList &srcWeights, labelListList &tgtAddress, scalarListList &tgtWeights, label srcFacei=-1, label tgtFacei=-1)
Update addressing and weights.
virtual scalar minWeight() const
The minimum weight below which connections are discarded.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
bool found(const Key &) const
Return true if hashedEntry is found in table.
scalar mag(const pointField &) const
Return scalar magnitude.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
scalar calc(const face &faceA, const face &faceB, const vector &n, const triangulationMode &triMode)
Return area of intersection of faceA with faceB.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
virtual void setNextFaces(label &startSeedI, label &srcFacei, label &tgtFacei, const boolList &mapFlag, labelList &seedFaces, const DynamicList< label > &visitedFaces, bool errorOnNotFound=true) const
Set the source and target seed faces.
Base class for Arbitrary Mesh Interface (AMI) methods.
T remove()
Remove and return the top element.
virtual void restartUncoveredSourceFace(List< DynamicList< label >> &srcAddr, List< DynamicList< scalar >> &srcWght, List< DynamicList< label >> &tgtAddr, List< DynamicList< scalar >> &tgtWght)
Attempt to re-evaluate source faces that have not been included.
#define WarningInFunction
Report a warning using Foam::Warning.
prefixOSstream Pout(cout, "Pout")
A List with indirect addressing.
dimensioned< scalar > mag(const dimensioned< Type > &)
void clear()
Clear the addressed list, i.e. set the size to zero.
void transfer(List< T > &)
Transfer contents of the argument List into this.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
faceAreaWeightAMI(const faceAreaWeightAMI &)
Disallow default bitwise copy construct.