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 bool faceProcessed =
false;
150 visitedFaces.
append(tgtFaceI);
151 scalar area = interArea(srcFaceI, tgtFaceI);
154 if (area/this->srcMagSf_[srcFaceI] > faceAreaIntersect::tolerance())
156 srcAddr[srcFaceI].append(tgtFaceI);
157 srcWght[srcFaceI].append(area);
159 tgtAddr[tgtFaceI].append(srcFaceI);
160 tgtWght[tgtFaceI].append(area);
170 faceProcessed =
true;
173 }
while (nbrFaces.
size() > 0);
175 return faceProcessed;
179 template<
class SourcePatch,
class TargetPatch>
191 const labelList& srcNbrFaces = this->srcPatch_.faceFaces()[srcFaceI];
197 bool valuesSet =
false;
200 label faceS = srcNbrFaces[i];
202 if (mapFlag[faceS] && seedFaces[faceS] == -1)
206 label faceT = visitedFaces[j];
207 scalar area = interArea(faceS, faceT);
208 scalar areaTotal = this->srcMagSf_[srcFaceI];
211 if (area/areaTotal > faceAreaIntersect::tolerance())
215 seedFaces[faceS] = faceT;
236 bool foundNextSeed =
false;
237 for (
label faceI = startSeedI; faceI < mapFlag.
size(); faceI++)
244 foundNextSeed =
true;
247 if (seedFaces[faceI] != -1)
250 tgtFaceI = seedFaces[faceI];
260 Pout<<
"Advancing front stalled: searching for new " 261 <<
"target face" <<
endl;
264 foundNextSeed =
false;
265 for (
label faceI = startSeedI; faceI < mapFlag.
size(); faceI++)
271 startSeedI = faceI + 1;
272 foundNextSeed =
true;
276 tgtFaceI = this->findTargetFace(srcFaceI);
289 "void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::" 297 "const DynamicList<label>&, " 306 template<
class SourcePatch,
class TargetPatch>
309 const label srcFaceI,
315 const pointField& srcPoints = this->srcPatch_.points();
316 const pointField& tgtPoints = this->tgtPatch_.points();
319 const face& src = this->srcPatch_[srcFaceI];
320 const face& tgt = this->tgtPatch_[tgtFaceI];
324 const scalar tgtMag = tgt.
mag(tgtPoints);
325 if ((this->srcMagSf_[srcFaceI] < ROOTVSMALL) || (tgtMag < ROOTVSMALL))
334 vector n(-this->srcPatch_.faceNormals()[srcFaceI]);
335 if (this->reverseTarget_)
337 n -= this->tgtPatch_.faceNormals()[tgtFaceI];
341 n += this->tgtPatch_.faceNormals()[tgtFaceI];
343 scalar magN =
mag(
n);
345 if (magN > ROOTVSMALL)
347 area = inter.
calc(src, tgt,
n/magN, this->triMode_);
353 "void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::" 359 ) <<
"Invalid normal for source face " << srcFaceI
361 <<
" target face " << tgtFaceI
367 if ((debug > 1) && (area > 0))
369 this->writeIntersectionOBJ(area, src, tgt, srcPoints, tgtPoints);
376 template<
class SourcePatch,
class TargetPatch>
392 scalar
s =
sum(srcWght[srcFaceI]);
393 scalar t = s/this->srcMagSf_[srcFaceI];
397 lowWeightFaces.
insert(srcFaceI);
403 Pout<<
"faceAreaWeightAMI: restarting search on " 404 << lowWeightFaces.
size() <<
" faces since sum of weights < 0.5" 408 if (lowWeightFaces.
size() > 0)
418 okSrcWeights.
clear();
423 if (!lowWeightFaces.
found(srcFaces[i]))
425 okSrcFaces.
append(srcFaces[i]);
426 okSrcWeights.
append(srcWeights[i]);
429 if (okSrcFaces.
size() < srcFaces.
size())
449 label srcFaceI = iter.key();
450 label tgtFaceI = this->findTargetFace(srcFaceI);
476 template<
class SourcePatch,
class TargetPatch>
479 const SourcePatch& srcPatch,
480 const TargetPatch& tgtPatch,
484 const bool reverseTarget,
485 const bool requireMatch,
486 const bool restartUncoveredSourceFace
499 restartUncoveredSourceFace_(restartUncoveredSourceFace)
505 template<
class SourcePatch,
class TargetPatch>
512 template<
class SourcePatch,
class TargetPatch>
555 if (debug && !this->srcNonOverlap_.empty())
557 Pout<<
" AMI: " << this->srcNonOverlap_.size()
558 <<
" non-overlap faces identified" 564 if (restartUncoveredSourceFace_)
566 restartUncoveredSourceFace
void transfer(List< T > &)
Transfer contents of the argument List into this.
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 ))
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
dimensioned< scalar > mag(const dimensioned< Type > &)
Base class for Arbitrary Mesh Interface (AMI) methods.
virtual void calculate(labelListList &srcAddress, scalarListList &srcWeights, labelListList &tgtAddress, scalarListList &tgtWeights, label srcFaceI=-1, label tgtFaceI=-1)
Update addressing and weights.
scalar mag(const pointField &) const
Magnitude of face area.
void clear()
Clear the addressed list, i.e. set the size to zero.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
virtual scalar interArea(const label srcFaceI, const label tgtFaceI) const
Area of intersection between source and target faces.
T remove()
Remove and return the top element.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A face is a list of labels corresponding to mesh vertices.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
A List with indirect addressing.
faceAreaWeightAMI(const faceAreaWeightAMI &)
Disallow default bitwise copy construct.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
label size() const
Return number of elements in table.
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.
errorManip< error > abort(error &err)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
virtual ~faceAreaWeightAMI()
Destructor.
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.
scalar calc(const face &faceA, const face &faceB, const vector &n, const triangulationMode &triMode)
Return area of intersection of faceA with faceB.
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.
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.
bool found(const Key &) const
Return true if hashedEntry is found in table.
prefixOSstream Pout(cout,"Pout")
bool insert(const Key &key)
Insert a new entry.