42 cellVolumeWeightMethod,
53 const label startSeedI,
62 for (label i = startSeedI; i < srcCellIDs.
size(); ++i)
64 const label srcI = srcCellIDs[i];
100 const label srcSeedI,
101 const label tgtSeedI,
107 label srcCelli = srcSeedI;
108 label tgtCelli = tgtSeedI;
110 List<DynamicList<label>> srcToTgtAddr(src_.nCells());
111 List<DynamicList<scalar>> srcToTgtWght(src_.nCells());
113 List<DynamicList<label>> tgtToSrcAddr(tgt_.nCells());
114 List<DynamicList<scalar>> tgtToSrcWght(tgt_.nCells());
117 DynamicList<label> queuedCells(10);
120 DynamicList<label> visitedCells(10);
124 seedCells[srcCelli] = tgtCelli;
131 visitedCells.clear();
134 queuedCells.push_back(tgtCelli);
135 appendNbrCells(tgtCelli, tgt_, visitedCells, queuedCells);
137 while (!queuedCells.empty())
140 tgtCelli = queuedCells.back();
141 queuedCells.pop_back();
142 visitedCells.push_back(tgtCelli);
144 scalar vol = interVol(srcCelli, tgtCelli);
147 if (vol/srcVol[srcCelli] > tolerance_)
150 srcToTgtAddr[srcCelli].append(tgtCelli);
151 srcToTgtWght[srcCelli].append(vol);
153 tgtToSrcAddr[tgtCelli].append(srcCelli);
154 tgtToSrcWght[tgtCelli].append(vol);
156 appendNbrCells(tgtCelli, tgt_, visitedCells, queuedCells);
163 mapFlag[srcCelli] =
false;
177 while (srcCelli != -1);
180 forAll(srcToTgtCellAddr, i)
182 srcToTgtCellAddr[i].
transfer(srcToTgtAddr[i]);
183 srcToTgtCellWght[i].transfer(srcToTgtWght[i]);
186 forAll(tgtToSrcCellAddr, i)
188 tgtToSrcCellAddr[i].transfer(tgtToSrcAddr[i]);
189 tgtToSrcCellWght[i].transfer(tgtToSrcWght[i]);
197 forAll(srcToTgtCellAddr, cellI)
199 scalar srcVol = src_.cellVolumes()[cellI];
200 scalar tgtVol =
sum(srcToTgtCellWght[cellI]);
202 if (
mag(srcVol) > ROOTVSMALL &&
mag((tgtVol-srcVol)/srcVol) > 1
e-6)
205 <<
"At cell " << cellI <<
" cc:"
206 << src_.cellCentres()[cellI]
208 <<
" total overlap volume:" << tgtVol
213 forAll(tgtToSrcCellAddr, cellI)
215 scalar tgtVol = tgt_.cellVolumes()[cellI];
216 scalar srcVol =
sum(tgtToSrcCellWght[cellI]);
218 if (
mag(tgtVol) > ROOTVSMALL &&
mag((srcVol-tgtVol)/tgtVol) > 1
e-6)
221 <<
"At cell " << cellI <<
" cc:"
222 << tgt_.cellCentres()[cellI]
224 <<
" total overlap volume:" << srcVol
243 const labelList& srcNbrCells = src_.cellCells()[srcCelli];
247 bool valuesSet =
false;
250 label cellS = srcNbrCells[i];
252 if (mapFlag[cellS] && seedCells[cellS] == -1)
256 label cellT = visitedCells[j];
258 if (intersect(cellS, cellT))
260 seedCells[cellS] = cellT;
281 bool foundNextSeed =
false;
282 for (label i = startSeedI; i < srcCellIDs.size(); i++)
284 label cellS = srcCellIDs[i];
291 foundNextSeed =
true;
294 if (seedCells[cellS] != -1)
297 tgtCelli = seedCells[cellS];
307 Pout<<
"Advancing front stalled: searching for new "
308 <<
"target cell" <<
endl;
336Foam::cellVolumeWeightMethod::cellVolumeWeightMethod
342 meshToMeshMethod(
src,
tgt)
381 boolList mapFlag(src_.nCells(),
false);
387 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.
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
void push_back(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)
Transfer the contents of the argument List into this list and annul the argument list.
void append(const T &val)
Append an element at the end of the list.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
T & back()
Access last element of the list, position [size()-1].
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.
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.
void setNextCells(label &startSeedI, label &srcCelli, label &tgtCelli, const labelList &srcCellIDs, const boolList &mapFlag, const labelUList &visitedCells, labelList &seedCells) const
Set the next cells in the advancing front algorithm.
Base class for mesh-to-mesh calculation methods.
const polyMesh & tgt_
Reference to the target mesh.
const polyMesh & src() const
Return const access to the source mesh.
const polyMesh & src_
Reference to the source mesh.
static scalar tolerance_
Tolerance used in volume overlap calculations.
virtual scalar interVol(const label srcCelli, const label tgtCelli) const
Return the intersection volume between two cells.
const polyMesh & tgt() const
Return const access to the target mesh.
labelList maskCells() const
Return src cell IDs for the overlap region.
scalar V_
Cell total volume in overlap region [m3].
virtual bool intersect(const label srcCelli, const label tgtCelli) const
Return the true if cells intersect.
virtual bool initialise(labelListList &srcToTgtAddr, scalarListList &srcToTgtWght, labelListList &tgtToTgtAddr, scalarListList &tgtToTgtWght) const
virtual void appendNbrCells(const label tgtCelli, const polyMesh &mesh, const labelUList &visitedTgtCells, DynamicList< label > &nbrTgtCellIDs) const
Append target cell neighbour cells to cellIDs list.
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.
Namespace for handling debugging switches.
List< scalarList > scalarListList
List of scalarList.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
List< face > faceList
List of faces.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< cell > cellList
List of cell.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
vector point
Point is a vector.
List< bool > boolList
A List of bools.
UIndirectList< bool > boolUIndList
UIndirectList of bools.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
List< pointList > pointListList
List of pointList.
#define forAll(list, i)
Loop across all elements in list.