Go to the documentation of this file.
100 label nFacesRemaining = srcAddr.size();
109 labelList seedFaces(nFacesRemaining, -1);
110 seedFaces[srcFacei] = tgtFacei;
113 bitSet mapFlag(nFacesRemaining,
true);
116 label startSeedi = 0;
118 bool continueWalk =
true;
123 visitedFaces.
clear();
126 bool faceProcessed = processSourceFace
141 mapFlag.
unset(srcFacei);
145 nonOverlapFaces.
append(srcFacei);
149 continueWalk = setNextFaces
157 requireMatch_ && (lowWeightCorrection_ < 0)
160 }
while (continueWalk);
162 srcNonOverlap_.transfer(nonOverlapFaces);
168 const label srcFacei,
169 const label tgtStartFacei,
184 addProfiling(ami,
"faceAreaWeightAMI::processSourceFace");
186 if (tgtStartFacei == -1)
191 const auto& tgtPatch = this->tgtPatch();
194 nbrFaces.
append(tgtStartFacei);
195 appendNbrFaces(tgtStartFacei, tgtPatch, visitedFaces, nbrFaces);
197 bool faceProcessed =
false;
199 label maxNeighbourFaces = nbrFaces.size();
204 label tgtFacei = nbrFaces.
remove();
205 visitedFaces.
append(tgtFacei);
207 scalar interArea = 0;
209 calcInterArea(srcFacei, tgtFacei, interArea, interCentroid);
212 if (interArea/srcMagSf_[srcFacei] > faceAreaIntersect::tolerance())
214 srcAddr[srcFacei].append(tgtFacei);
215 srcWght[srcFacei].append(interArea);
216 srcCtr[srcFacei].append(interCentroid);
218 tgtAddr[tgtFacei].append(srcFacei);
219 tgtWght[tgtFacei].append(interArea);
221 appendNbrFaces(tgtFacei, tgtPatch, visitedFaces, nbrFaces);
223 faceProcessed =
true;
225 maxNeighbourFaces =
max(maxNeighbourFaces, nbrFaces.size());
228 }
while (nbrFaces.size() > 0);
235 return faceProcessed;
247 const bool errorOnNotFound
252 if (mapFlag.
count() == 0)
264 bool valuesSet =
false;
265 for (label faceS: srcNbrFaces)
267 if (mapFlag.
test(faceS) && seedFaces[faceS] == -1)
269 for (label faceT : visitedFaces)
271 const scalar threshold =
272 srcMagSf_[faceS]*faceAreaIntersect::tolerance();
275 if (overlaps(faceS, faceT, threshold))
277 seedFaces[faceS] = faceT;
297 label facei = startSeedi;
298 if (!mapFlag.
test(startSeedi))
302 const label startSeedi0 = facei;
304 bool foundNextSeed =
false;
310 foundNextSeed =
true;
313 if (seedFaces[facei] != -1)
316 tgtFacei = seedFaces[facei];
327 Pout<<
"Advancing front stalled: searching for new "
328 <<
"target face" <<
endl;
335 tgtFacei = findTargetFace(srcFacei, visitedFaces);
348 <<
"Unable to set target face for source face " << srcFacei
358 const label srcFacei,
359 const label tgtFacei,
369 (srcMagSf_[srcFacei] < ROOTVSMALL)
370 || (tgtMagSf_[tgtFacei] < ROOTVSMALL)
376 const auto& srcPatch = this->srcPatch();
377 const auto& tgtPatch = this->tgtPatch();
390 AMIInterpolation::cacheIntersections_
403 scalar magN =
mag(
n);
405 const face& src = srcPatch[srcFacei];
406 const face& tgt = tgtPatch[tgtFacei];
408 if (magN > ROOTVSMALL)
410 inter.
calc(src, tgt,
n/magN,
area, centroid);
415 <<
"Invalid normal for source face " << srcFacei
417 <<
" target face " << tgtFacei
422 if (AMIInterpolation::cacheIntersections_ &&
debug)
424 static OBJstream tris(
"intersectionTris.obj");
426 for (
const auto& tp : triPts)
434 writeIntersectionOBJ(
area, src, tgt, srcPoints, tgtPoints);
441 const label srcFacei,
442 const label tgtFacei,
443 const scalar threshold
449 (srcMagSf_[srcFacei] < ROOTVSMALL)
450 || (tgtMagSf_[tgtFacei] < ROOTVSMALL)
456 const auto& srcPatch = this->srcPatch();
457 const auto& tgtPatch = this->tgtPatch();
469 AMIInterpolation::cacheIntersections_
482 scalar magN =
mag(
n);
484 const face& src = srcPatch[srcFacei];
485 const face& tgt = tgtPatch[tgtFacei];
487 if (magN > ROOTVSMALL)
489 return inter.
overlaps(src, tgt,
n/magN, threshold);
494 <<
"Invalid normal for source face " << srcFacei
496 <<
" target face " << tgtFacei
514 addProfiling(ami,
"faceAreaWeightAMI::restartUncoveredSourceFace");
518 label nBelowMinWeight = 0;
519 const scalar minWeight = 0.95;
527 const auto& srcPatch = this->srcPatch();
531 const scalar
s =
sum(srcWght[srcFacei]);
532 const scalar t =
s/srcMagSf_[srcFacei];
538 const face&
f = srcPatch[srcFacei];
542 const label tgtFacei =
543 findTargetFace(srcFacei, srcAddr[srcFacei], fpi);
548 visitedFaces = srcAddr[srcFacei];
550 (void)processSourceFace
569 if (
debug && nBelowMinWeight)
572 <<
"Restarted search on " << nBelowMinWeight
573 <<
" faces since sum of weights < " << minWeight
584 const bool reverseTarget
588 restartUncoveredSourceFace_
590 dict.getOrDefault(
"restartUncoveredSourceFace",
true)
597 const bool requireMatch,
598 const bool reverseTarget,
599 const scalar lowWeightCorrection,
601 const bool restartUncoveredSourceFace
611 restartUncoveredSourceFace_(restartUncoveredSourceFace)
618 restartUncoveredSourceFace_(ami.restartUncoveredSourceFace_)
643 bool ok = initialiseWalk(srcFacei, tgtFacei);
645 srcCentroids_.setSize(srcAddress_.size());
647 const auto& src = this->srcPatch();
648 const auto& tgt = this->tgtPatch();
670 if (
debug && !srcNonOverlap_.empty())
672 Pout<<
" AMI: " << srcNonOverlap_.size()
673 <<
" non-overlap faces identified"
678 if (restartUncoveredSourceFace_)
680 restartUncoveredSourceFace
694 srcAddress_[i].transfer(srcAddr[i]);
695 srcWeights_[i].transfer(srcWght[i]);
696 srcCentroids_[i].transfer(srcCtr[i]);
701 tgtAddress_[i].transfer(tgtAddr[i]);
702 tgtWeights_[i].transfer(tgtWght[i]);
714 for (
labelList& addressing : srcAddress_)
716 for (label& addr : addressing)
718 addr = extendedTgtFaceIDs_[addr];
722 for (
labelList& addressing : tgtAddress_)
735 extendedTgtMapPtr_->constructMap(),
737 extendedTgtMapPtr_->subMap(),
750 extendedTgtMapPtr_->constructMap(),
752 extendedTgtMapPtr_->subMap(),
761 extendedTgtMapPtr_->reverseDistribute(tgtPatch0.size(), tgtMagSf_);
778 normaliseWeights(conformal(),
true);
790 if (restartUncoveredSourceFace_)
794 "restartUncoveredSourceFace",
795 restartUncoveredSourceFace_
int debug
Static debugging option.
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)
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())
Distribute data. Note:schedule only used for.
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
An Ostream wrapper for parallel output to std::cout.
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
virtual Ostream & write(const char c)
Write character.
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.
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Class containing processor-to-processor mapping information.
void clear()
Clear the addressed list, i.e. set the size to zero.
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.
const Field< point_type > & points() const
Return reference to global points.
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...
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 list of faces which address into the list of points.
Functor to negate primitives. Dummy for most other types.