53 const label startSeedI,
62 for (label i = startSeedI; i < srcCellIDs.
size(); ++i)
64 const label srcI = srcCellIDs[i];
70 for (
const point& pt : pts)
87 Pout<<
"could not find starting seed" <<
endl;
100 const label srcSeedI,
101 const label tgtSeedI,
107 label srcCelli = srcSeedI;
108 label tgtCelli = tgtSeedI;
124 seedCells[srcCelli] = tgtCelli;
131 visitedTgtCells.
clear();
134 nbrTgtCells.
append(tgtCelli);
135 appendNbrCells(tgtCelli, tgt_, visitedTgtCells, nbrTgtCells);
139 tgtCelli = nbrTgtCells.
remove();
140 visitedTgtCells.
append(tgtCelli);
142 scalar vol = interVol(srcCelli, tgtCelli);
145 if (vol/srcVol[srcCelli] > tolerance_)
148 srcToTgtAddr[srcCelli].
append(tgtCelli);
149 srcToTgtWght[srcCelli].
append(vol);
151 tgtToSrcAddr[tgtCelli].
append(srcCelli);
152 tgtToSrcWght[tgtCelli].
append(vol);
154 appendNbrCells(tgtCelli, tgt_, visitedTgtCells, nbrTgtCells);
160 while (!nbrTgtCells.
empty());
162 mapFlag[srcCelli] =
false;
176 while (srcCelli != -1);
179 forAll(srcToTgtCellAddr, i)
181 srcToTgtCellAddr[i].
transfer(srcToTgtAddr[i]);
182 srcToTgtCellWght[i].
transfer(srcToTgtWght[i]);
185 forAll(tgtToSrcCellAddr, i)
187 tgtToSrcCellAddr[i].
transfer(tgtToSrcAddr[i]);
188 tgtToSrcCellWght[i].
transfer(tgtToSrcWght[i]);
196 forAll(srcToTgtCellAddr, cellI)
198 scalar srcVol = src_.cellVolumes()[cellI];
199 scalar tgtVol =
sum(srcToTgtCellWght[cellI]);
201 if (
mag(srcVol) > ROOTVSMALL &&
mag((tgtVol-srcVol)/srcVol) > 1
e-6)
204 <<
"At cell " << cellI <<
" cc:"
205 << src_.cellCentres()[cellI]
207 <<
" total overlap volume:" << tgtVol
212 forAll(tgtToSrcCellAddr, cellI)
214 scalar tgtVol = tgt_.cellVolumes()[cellI];
215 scalar srcVol =
sum(tgtToSrcCellWght[cellI]);
217 if (
mag(tgtVol) > ROOTVSMALL &&
mag((srcVol-tgtVol)/tgtVol) > 1
e-6)
220 <<
"At cell " << cellI <<
" cc:"
221 << tgt_.cellCentres()[cellI]
223 <<
" total overlap volume:" << srcVol
242 const labelList& srcNbrCells = src_.cellCells()[srcCelli];
246 bool valuesSet =
false;
249 label cellS = srcNbrCells[i];
251 if (mapFlag[cellS] && seedCells[cellS] == -1)
255 label cellT = visitedCells[j];
257 if (intersect(cellS, cellT))
259 seedCells[cellS] = cellT;
280 bool foundNextSeed =
false;
281 for (label i = startSeedI; i < srcCellIDs.
size(); i++)
283 label cellS = srcCellIDs[i];
290 foundNextSeed =
true;
293 if (seedCells[cellS] != -1)
296 tgtCelli = seedCells[cellS];
306 Pout<<
"Advancing front stalled: searching for new "
307 <<
"target cell" <<
endl;
380 boolList mapFlag(src_.nCells(),
false);
386 label startSeedI = 0;
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
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.
void transfer(List< T > &list)
void append(const T &val)
Append an element at the end of the list.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
Cell-volume-weighted mesh-to-mesh interpolation class.
bool findInitialSeeds(const labelList &srcCellIDs, const boolList &mapFlag, const label startSeedI, label &srcSeedI, label &tgtSeedI) const
Find indices of overlapping cells in src and tgt meshes - returns.
void setNextCells(label &startSeedI, label &srcCelli, label &tgtCelli, const labelList &srcCellIDs, const boolList &mapFlag, const DynamicList< label > &visitedCells, labelList &seedCells) const
Set the next cells in the advancing front algorithm.
virtual ~cellVolumeWeightMethod()
Destructor.
void calculateAddressing(labelListList &srcToTgtCellAddr, scalarListList &srcToTgtCellWght, labelListList &tgtToSrcCellAddr, scalarListList &tgtToSrcCellWght, const label srcSeedI, const label tgtSeedI, const labelList &srcCellIDs, boolList &mapFlag, label &startSeedI)
Calculate the mesh-to-mesh addressing and weights.
virtual void calculate(labelListList &srcToTgtAddr, scalarListList &srcToTgtWght, pointListList &srcToTgtVec, labelListList &tgtToSrcAddr, scalarListList &tgtToSrcWght, pointListList &tgtToSrcVec)
Calculate addressing and weights and optionally offset vectors.
Base class for mesh-to-mesh calculation methods.
const polyMesh & tgt_
Reference to the target mesh.
const polyMesh & src_
Reference to the source mesh.
virtual bool intersect(const label srcCelli, const label tgtCelli) const
Return the true if cells intersect.
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
const cellList & cells() const
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define WarningInFunction
Report a warning using Foam::Warning.
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)
UIndirectList< bool > boolUIndList
UIndirectList of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
#define forAll(list, i)
Loop across all elements in list.