50 partialFaceAreaWeightAMI,
113 label nFacesRemaining = srcAddr.size();
122 labelList seedFaces(nFacesRemaining, -1);
123 seedFaces[srcFacei] = tgtFacei;
126 bitSet mapFlag(nFacesRemaining,
true);
129 label startSeedi = 0;
134 bool continueWalk =
true;
139 visitedFaces.
clear();
157 mapFlag.
unset(srcFacei);
161 nonOverlapFaces.
append(srcFacei);
176 }
while (continueWalk);
184 const label srcFacei,
185 const label tgtStartFacei,
200 addProfiling(ami,
"faceAreaWeightAMI::processSourceFace");
202 if (tgtStartFacei == -1)
207 const auto& tgtPatch = this->tgtPatch();
210 nbrFaces.
append(tgtStartFacei);
211 appendNbrFaces(tgtStartFacei, tgtPatch, visitedFaces, nbrFaces);
213 bool faceProcessed =
false;
215 label maxNeighbourFaces = nbrFaces.
size();
220 label tgtFacei = nbrFaces.
remove();
221 visitedFaces.
append(tgtFacei);
223 scalar interArea = 0;
225 calcInterArea(srcFacei, tgtFacei, interArea, interCentroid);
230 srcAddr[srcFacei].append(tgtFacei);
231 srcWght[srcFacei].append(interArea);
232 srcCtr[srcFacei].append(interCentroid);
234 tgtAddr[tgtFacei].append(srcFacei);
235 tgtWght[tgtFacei].append(interArea);
237 appendNbrFaces(tgtFacei, tgtPatch, visitedFaces, nbrFaces);
239 faceProcessed =
true;
241 maxNeighbourFaces =
max(maxNeighbourFaces, nbrFaces.
size());
244 }
while (nbrFaces.
size() > 0);
251 return faceProcessed;
263 const bool errorOnNotFound
268 if (mapFlag.
count() == 0)
274 const labelList& srcNbrFaces = this->srcPatch().faceFaces()[srcFacei];
280 bool valuesSet =
false;
281 for (label faceS: srcNbrFaces)
283 if (mapFlag.
test(faceS) && seedFaces[faceS] == -1)
285 for (label faceT : visitedFaces)
287 const scalar threshold =
291 if (overlaps(faceS, faceT, threshold))
293 seedFaces[faceS] = faceT;
313 label facei = startSeedi;
314 if (!mapFlag.
test(startSeedi))
318 const label startSeedi0 = facei;
320 bool foundNextSeed =
false;
326 foundNextSeed =
true;
329 if (seedFaces[facei] != -1)
332 tgtFacei = seedFaces[facei];
343 Pout<<
"Advancing front stalled: searching for new "
344 <<
"target face" <<
endl;
351 tgtFacei = findTargetFace(srcFacei, visitedFaces);
364 <<
"Unable to set target face for source face " << srcFacei
374 const label srcFacei,
375 const label tgtFacei,
383 if (!isCandidate(srcFacei, tgtFacei))
388 const auto& srcPatch = this->srcPatch();
389 const auto& tgtPatch = this->tgtPatch();
391 const pointField& srcPoints = srcPatch.points();
392 const pointField& tgtPoints = tgtPatch.points();
406 vector n(-srcPatch.faceNormals()[srcFacei]);
409 n -= tgtPatch.faceNormals()[tgtFacei];
413 n += tgtPatch.faceNormals()[tgtFacei];
415 scalar magN =
mag(
n);
417 const face& src = srcPatch[srcFacei];
418 const face& tgt = tgtPatch[tgtFacei];
420 if (magN > ROOTVSMALL)
422 inter.
calc(src, tgt,
n/magN, area, centroid);
427 <<
"Invalid normal for source face " << srcFacei
429 <<
" target face " << tgtFacei
436 static OBJstream tris(
"intersectionTris.obj");
438 for (
const auto& tp : triPts)
444 if ((debug > 1) && (area > 0))
446 writeIntersectionOBJ(area, src, tgt, srcPoints, tgtPoints);
453 const label srcFacei,
454 const label tgtFacei,
455 const scalar threshold
459 if (!isCandidate(srcFacei, tgtFacei))
464 const auto& srcPatch = this->srcPatch();
465 const auto& tgtPatch = this->tgtPatch();
467 const pointField& srcPoints = srcPatch.points();
468 const pointField& tgtPoints = tgtPatch.points();
481 vector n(-srcPatch.faceNormals()[srcFacei]);
484 n -= tgtPatch.faceNormals()[tgtFacei];
488 n += tgtPatch.faceNormals()[tgtFacei];
490 scalar magN =
mag(
n);
492 const face& src = srcPatch[srcFacei];
493 const face& tgt = tgtPatch[tgtFacei];
495 if (magN > ROOTVSMALL)
497 return inter.
overlaps(src, tgt,
n/magN, threshold);
502 <<
"Invalid normal for source face " << srcFacei
504 <<
" target face " << tgtFacei
522 addProfiling(ami,
"faceAreaWeightAMI::restartUncoveredSourceFace");
526 label nBelowMinWeight = 0;
527 const scalar minWeight = 0.95;
535 const auto& srcPatch = this->srcPatch();
539 const scalar
s =
sum(srcWght[srcFacei]);
540 const scalar t =
s/srcMagSf_[srcFacei];
546 const face&
f = srcPatch[srcFacei];
550 const label tgtFacei =
551 findTargetFace(srcFacei, srcAddr[srcFacei], fpi);
556 visitedFaces = srcAddr[srcFacei];
558 (void)processSourceFace
577 if (debug && nBelowMinWeight)
580 <<
"Restarted search on " << nBelowMinWeight
581 <<
" faces since sum of weights < " << minWeight
592 const bool reverseTarget
596 restartUncoveredSourceFace_
598 dict.getOrDefault(
"restartUncoveredSourceFace", true)
605 const bool requireMatch,
606 const bool reverseTarget,
607 const scalar lowWeightCorrection,
609 const bool restartUncoveredSourceFace
619 restartUncoveredSourceFace_(restartUncoveredSourceFace)
626 restartUncoveredSourceFace_(ami.restartUncoveredSourceFace_)
646 advancingFrontAMI::calculate(srcPatch, tgtPatch, surfPtr);
651 bool ok = initialiseWalk(srcFacei, tgtFacei);
653 srcCentroids_.setSize(srcAddress_.size());
655 const auto& src = this->srcPatch();
656 const auto& tgt = this->tgtPatch();
678 if (debug && !srcNonOverlap_.empty())
680 Pout<<
" AMI: " << srcNonOverlap_.size()
681 <<
" non-overlap faces identified"
686 if (restartUncoveredSourceFace_)
688 restartUncoveredSourceFace
702 srcAddress_[i].transfer(srcAddr[i]);
703 srcWeights_[i].transfer(srcWght[i]);
704 srcCentroids_[i].transfer(srcCtr[i]);
709 tgtAddress_[i].transfer(tgtAddr[i]);
710 tgtWeights_[i].transfer(tgtWght[i]);
722 for (
labelList& addressing : srcAddress_)
724 for (label& addr : addressing)
726 addr = extendedTgtFaceIDs_[addr];
730 for (
labelList& addressing : tgtAddress_)
738 mapDistributeBase::distribute
743 extendedTgtMapPtr_->constructMap(),
745 extendedTgtMapPtr_->subMap(),
753 mapDistributeBase::distribute
758 extendedTgtMapPtr_->constructMap(),
760 extendedTgtMapPtr_->subMap(),
769 extendedTgtMapPtr_->reverseDistribute(tgtPatch0.size(), tgtMagSf_);
786 normaliseWeights(requireMatch_,
true);
788 nonConformalCorrection();
800 if (restartUncoveredSourceFace_)
804 "restartUncoveredSourceFace",
805 restartUncoveredSourceFace_
Macros for easy insertion into run-time selection tables.
#define addAliasToRunTimeSelectionTable(baseType, thisType, argNames, lookup, other, ver)
Add lookup alias for runTime selection.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
bool mustMatchFaces() const
Return true if requireMatch and lowWeightCorrectionin active.
static bool cacheIntersections_
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
T remove()
Remove and return the last element. Fatal on an empty list.
void append(const T &val)
Copy append an element to the end of this list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
OFstream that keeps track of vertices.
virtual Ostream & write(const char c)
Write character.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
int overlaps
Flag to control which overlap calculations are performed.
A list of faces which address into the list of points.
A List with indirect addressing. Like IndirectList but does not store addressing.
void size(const label n)
Older name for setAddressableSize.
@ nonBlocking
"nonBlocking"
Base class for Arbitrary Mesh Interface (AMI) methods.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
unsigned int count(const bool on=true) const
Count number of bits set.
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
bitSet & unset(const bitSet &other)
label find_next(label pos) const
Locate the next bit set, starting one beyond the specified position.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
void calc(const face &faceA, const face &faceB, const vector &n, scalar &area, vector ¢roid) const
bool overlaps(const face &faceA, const face &faceB, const vector &n, const scalar threshold) const
Return area of intersection of faceA with faceB.
const DynamicList< triPoints > triangles() const
Const access to the triangulation.
static scalar & tolerance()
Fraction of local length scale to use as intersection tolerance.
Face area weighted Arbitrary Mesh Interface (AMI) method.
virtual void calcAddressing(List< DynamicList< label > > &srcAddress, List< DynamicList< scalar > > &srcWeights, List< DynamicList< point > > &srcCentroids, List< DynamicList< label > > &tgtAddress, List< DynamicList< scalar > > &tgtWeights, label srcFacei, label tgtFacei)
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< point > > &srcCtr, List< DynamicList< label > > &tgtAddr, List< DynamicList< scalar > > &tgtWght)
Determine overlap contributions for source face srcFacei.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
virtual bool setNextFaces(label &startSeedi, label &srcFacei, label &tgtFacei, const bitSet &mapFlag, labelList &seedFaces, const DynamicList< label > &visitedFaces, const bool errorOnNotFound=true) const
Set the source and target seed faces.
virtual void restartUncoveredSourceFace(List< DynamicList< label > > &srcAddr, List< DynamicList< scalar > > &srcWght, List< DynamicList< point > > &srcCtr, List< DynamicList< label > > &tgtAddr, List< DynamicList< scalar > > &tgtWght)
Attempt to re-evaluate source faces that have not been included.
virtual void calcInterArea(const label srcFacei, const label tgtFacei, scalar &area, vector ¢roid) const
Area of intersection between source and target faces.
A face is a list of labels corresponding to mesh vertices.
virtual bool write()
Write the output fields.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
void inplaceToGlobal(labelUList &labels) const
From local to global index (inplace)
Class containing processor-to-processor mapping information.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugVar(var)
Report a variable name and value.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
triangle< point, const point & > triPointRef
A triangle using referred points.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
#define forAll(list, i)
Loop across all elements in list.
List helper to append y elements onto the end of x.
Functor to negate primitives. Dummy for most other types.