53 label nFacesRemaining = srcAddr.size();
63 seedFaces[srcFacei] = tgtFacei;
66 boolList mapFlag(nFacesRemaining,
true);
75 bool faceProcessed = processSourceFace
89 mapFlag[srcFacei] =
false;
95 nonOverlapFaces.
append(srcFacei);
99 if (nFacesRemaining > 0)
111 }
while (nFacesRemaining > 0);
113 this->srcNonOverlap_.transfer(nonOverlapFaces);
119 const label srcFacei,
120 const label tgtStartFacei,
134 if (tgtStartFacei == -1)
140 visitedFaces.
clear();
143 nbrFaces.
append(tgtStartFacei);
152 const scalar srcArea = this->srcMagSf_[srcFacei];
154 bool faceProcessed =
false;
160 visitedFaces.
append(tgtFacei);
161 const scalar tgtArea = this->tgtMagSf_[tgtFacei];
164 const scalar area = interArea(srcFacei, tgtFacei);
167 if (area/srcArea > minWeight())
169 srcAddr[srcFacei].append(tgtFacei);
170 srcWght[srcFacei].append(area/srcArea);
172 tgtAddr[tgtFacei].append(srcFacei);
173 tgtWght[tgtFacei].append(area/tgtArea);
183 faceProcessed =
true;
186 }
while (nbrFaces.
size() > 0);
188 return faceProcessed;
203 const labelList& srcNbrFaces = this->srcPatch_.faceFaces()[srcFacei];
209 bool valuesSet =
false;
212 label faceS = srcNbrFaces[i];
214 if (mapFlag[faceS] && seedFaces[faceS] == -1)
218 label faceT = visitedFaces[j];
219 scalar area = interArea(faceS, faceT);
220 scalar areaTotal = this->srcMagSf_[srcFacei];
223 if (area/areaTotal > minWeight())
227 seedFaces[faceS] = faceT;
248 bool foundNextSeed =
false;
249 for (
label facei = startSeedI; facei < mapFlag.
size(); facei++)
256 foundNextSeed =
true;
259 if (seedFaces[facei] != -1)
262 tgtFacei = seedFaces[facei];
272 Pout<<
"Advancing front stalled: searching for new " 273 <<
"target face" <<
endl;
276 foundNextSeed =
false;
277 for (
label facei = startSeedI; facei < mapFlag.
size(); facei++)
283 startSeedI = facei + 1;
284 foundNextSeed =
true;
288 tgtFacei = this->findTargetFace(srcFacei);
308 const label srcFacei,
314 const pointField& srcPoints = this->srcPatch_.points();
315 const pointField& tgtPoints = this->tgtPatch_.points();
318 const face& src = this->srcPatch_[srcFacei];
319 const face& tgt = this->tgtPatch_[tgtFacei];
323 const scalar tgtMag = tgt.
mag(tgtPoints);
324 if ((this->srcMagSf_[srcFacei] < rootVSmall) || (tgtMag < rootVSmall))
333 vector n(-this->srcPatch_.faceNormals()[srcFacei]);
334 if (this->reverseTarget_)
336 n -= this->tgtPatch_.faceNormals()[tgtFacei];
340 n += this->tgtPatch_.faceNormals()[tgtFacei];
342 scalar magN =
mag(
n);
344 if (magN > rootVSmall)
346 area = inter.
calc(src, tgt,
n/magN, this->triMode_);
351 <<
"Invalid normal for source face " << srcFacei
353 <<
" target face " << tgtFacei
359 if ((debug > 1) && (area > 0))
361 this->writeIntersectionOBJ(area, src, tgt, srcPoints, tgtPoints);
382 const scalar
s =
sum(srcWght[srcFacei]);
386 lowWeightFaces.
insert(srcFacei);
392 Pout<<
"faceAreaWeightAMI: restarting search on " 393 << lowWeightFaces.
size() <<
" faces since sum of weights < 0.5" 397 if (lowWeightFaces.
size() > 0)
407 okSrcWeights.
clear();
412 if (!lowWeightFaces.
found(srcFaces[i]))
414 okSrcFaces.
append(srcFaces[i]);
415 okSrcWeights.
append(srcWeights[i]);
418 if (okSrcFaces.
size() < srcFaces.
size())
438 label srcFacei = iter.key();
439 label tgtFacei = this->findTargetFace(srcFacei);
479 const bool reverseTarget,
480 const bool requireMatch,
481 const bool restartUncoveredSourceFace
494 restartUncoveredSourceFace_(restartUncoveredSourceFace)
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.
static scalar & tolerance()
Fraction of local length scale to use as intersection tolerance.
A face is a list of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
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.
Macros for easy insertion into run-time selection tables.
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.
A list of faces which address into the list of points.
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))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
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.
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.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
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.
faceAreaWeightAMI(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const scalarField &srcMagSf, const scalarField &tgtMagSf, const faceAreaIntersect::triangulationMode &triMode, const bool reverseTarget=false, const bool requireMatch=true, const bool restartUncoveredSourceFace=true)
Construct from components.
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.