Go to the documentation of this file.
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;
132 const bool mustMatch = mustMatchFaces();
134 bool continueWalk =
true;
139 visitedFaces.
clear();
142 bool faceProcessed = processSourceFace
157 mapFlag.
unset(srcFacei);
161 nonOverlapFaces.
append(srcFacei);
165 continueWalk = setNextFaces
176 }
while (continueWalk);
178 srcNonOverlap_.transfer(nonOverlapFaces);
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);
228 if (interArea/srcMagSf_[srcFacei] > faceAreaIntersect::tolerance())
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)
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 =
288 srcMagSf_[faceS]*faceAreaIntersect::tolerance();
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,
385 (srcMagSf_[srcFacei] < ROOTVSMALL)
386 || (tgtMagSf_[tgtFacei] < ROOTVSMALL)
392 const auto& srcPatch = this->srcPatch();
393 const auto& tgtPatch = this->tgtPatch();
406 AMIInterpolation::cacheIntersections_
419 scalar magN =
mag(
n);
421 const face& src = srcPatch[srcFacei];
422 const face& tgt = tgtPatch[tgtFacei];
424 if (magN > ROOTVSMALL)
426 inter.
calc(src, tgt,
n/magN,
area, centroid);
431 <<
"Invalid normal for source face " << srcFacei
433 <<
" target face " << tgtFacei
438 if (AMIInterpolation::cacheIntersections_ &&
debug)
440 static OBJstream tris(
"intersectionTris.obj");
442 for (
const auto& tp : triPts)
450 writeIntersectionOBJ(
area, src, tgt, srcPoints, tgtPoints);
457 const label srcFacei,
458 const label tgtFacei,
459 const scalar threshold
465 (srcMagSf_[srcFacei] < ROOTVSMALL)
466 || (tgtMagSf_[tgtFacei] < ROOTVSMALL)
472 const auto& srcPatch = this->srcPatch();
473 const auto& tgtPatch = this->tgtPatch();
485 AMIInterpolation::cacheIntersections_
498 scalar magN =
mag(
n);
500 const face& src = srcPatch[srcFacei];
501 const face& tgt = tgtPatch[tgtFacei];
503 if (magN > ROOTVSMALL)
505 return inter.
overlaps(src, tgt,
n/magN, threshold);
510 <<
"Invalid normal for source face " << srcFacei
512 <<
" target face " << tgtFacei
530 addProfiling(ami,
"faceAreaWeightAMI::restartUncoveredSourceFace");
534 label nBelowMinWeight = 0;
535 const scalar minWeight = 0.95;
543 const auto& srcPatch = this->srcPatch();
547 const scalar
s =
sum(srcWght[srcFacei]);
548 const scalar t =
s/srcMagSf_[srcFacei];
554 const face&
f = srcPatch[srcFacei];
558 const label tgtFacei =
559 findTargetFace(srcFacei, srcAddr[srcFacei], fpi);
564 visitedFaces = srcAddr[srcFacei];
566 (void)processSourceFace
585 if (
debug && nBelowMinWeight)
588 <<
"Restarted search on " << nBelowMinWeight
589 <<
" faces since sum of weights < " << minWeight
600 const bool reverseTarget
604 restartUncoveredSourceFace_
606 dict.getOrDefault(
"restartUncoveredSourceFace",
true)
613 const bool requireMatch,
614 const bool reverseTarget,
615 const scalar lowWeightCorrection,
617 const bool restartUncoveredSourceFace
627 restartUncoveredSourceFace_(restartUncoveredSourceFace)
634 restartUncoveredSourceFace_(ami.restartUncoveredSourceFace_)
659 bool ok = initialiseWalk(srcFacei, tgtFacei);
661 srcCentroids_.setSize(srcAddress_.size());
663 const auto& src = this->srcPatch();
664 const auto& tgt = this->tgtPatch();
686 if (
debug && !srcNonOverlap_.empty())
688 Pout<<
" AMI: " << srcNonOverlap_.size()
689 <<
" non-overlap faces identified"
694 if (restartUncoveredSourceFace_)
696 restartUncoveredSourceFace
710 srcAddress_[i].transfer(srcAddr[i]);
711 srcWeights_[i].transfer(srcWght[i]);
712 srcCentroids_[i].transfer(srcCtr[i]);
717 tgtAddress_[i].transfer(tgtAddr[i]);
718 tgtWeights_[i].transfer(tgtWght[i]);
730 for (
labelList& addressing : srcAddress_)
732 for (label& addr : addressing)
734 addr = extendedTgtFaceIDs_[addr];
738 for (
labelList& addressing : tgtAddress_)
751 extendedTgtMapPtr_->constructMap(),
753 extendedTgtMapPtr_->subMap(),
766 extendedTgtMapPtr_->constructMap(),
768 extendedTgtMapPtr_->subMap(),
777 extendedTgtMapPtr_->reverseDistribute(tgtPatch0.size(), tgtMagSf_);
794 normaliseWeights(requireMatch_,
true);
796 nonConformalCorrection();
808 if (restartUncoveredSourceFace_)
812 "restartUncoveredSourceFace",
813 restartUncoveredSourceFace_
int debug
Static debugging option.
const Field< point_type > & points() const noexcept
Return reference to global points.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
List< label > labelList
A List of labels.
virtual void write(Ostream &os) const
Write.
List< scalar > scalarList
A List of scalars.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
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 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.
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))
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
OFstream that keeps track of vertices.
static constexpr const zero Zero
Global zero (0)
bitSet & unset(const bitSet &other)
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void inplaceToGlobal(labelList &labels) const
From local to global index (inplace)
void calc(const face &faceA, const face &faceB, const vector &n, scalar &area, vector ¢roid) const
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
virtual Ostream & write(const char c)
Write character.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
unsigned int count(const bool on=true) const
Count number of bits set.
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 calcInterArea(const label srcFacei, const label tgtFacei, scalar &area, vector ¢roid) const
Area of intersection between source and target faces.
#define forAll(list, i)
Loop across all elements in list.
Face area weighted Arbitrary Mesh Interface (AMI) method.
faceAreaWeightAMI(const dictionary &dict, const bool reverseTarget=false)
Construct from dictionary.
static void distribute(const Pstream::commsTypes commsType, const List< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &, const negateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute data. Note:schedule only used for.
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Class containing processor-to-processor mapping information.
virtual bool calculate(const primitivePatch &srcPatch, const primitivePatch &tgtPatch, const autoPtr< searchableSurface > &surfPtr=nullptr)
Update addressing, weights and (optional) centroids.
virtual void write(Ostream &os) const
Write.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
label find_next(label pos) const
Locate the next bit set, starting one beyond the specified position.
OBJstream os(runTime.globalPath()/outputName)
Macros for easy insertion into run-time selection tables.
bool overlaps(const face &faceA, const face &faceB, const vector &n, const scalar threshold) const
Return area of intersection of faceA with faceB.
errorManip< error > abort(error &err)
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
addAliasToRunTimeSelectionTable(AMIInterpolation, faceAreaWeightAMI, dict, faceAreaWeightAMI, partialFaceAreaWeightAMI, 2012)
List helper to append y elements onto the end of x.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
#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...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Base class for Arbitrary Mesh Interface (AMI) methods.
T remove()
Remove and return the last element. Fatal on an empty list.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
const wordList area
Standard area field types (scalar, vector, tensor, etc)
A List with indirect addressing.
A face is a list of labels corresponding to mesh vertices.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const labelListList & faceFaces() const
Return face-face addressing.
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)
#define DebugVar(var)
Report a variable name and value.
defineTypeNameAndDebug(combustionModel, 0)
const DynamicList< triPoints > triangles() const
Const access to the triangulation.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual bool overlaps(const label srcFacei, const label tgtFacei, const scalar threshold) const
Return true if faces overlap.
triangle< point, const point & > triPointRef
A triangle using referred points.
A list of faces which address into the list of points.
Functor to negate primitives. Dummy for most other types.