42 cellVolumeWeightMethod,
53 const label startSeedI,
62 for (label i = startSeedI; i < srcCellIDs.
size(); ++i)
64 const label srcI = srcCellIDs[i];
87 Pout<<
"could not find starting seed" <<
endl;
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
239 const DynamicList<label>& visitedCells,
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;
336 Foam::cellVolumeWeightMethod::cellVolumeWeightMethod
381 boolList mapFlag(src_.nCells(),
false);
387 label startSeedI = 0;
void size(const label n)
Older name for setAddressableSize.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
const polyMesh & src_
Reference to the source mesh.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
virtual ~cellVolumeWeightMethod()
Destructor.
void append(const T &val)
Append an element at the end of the list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
const cellList & cells() const
List< labelList > labelListList
List of labelList.
Macros for easy insertion into run-time selection tables.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
const dimensionedScalar e
Elementary charge.
void clear()
Clear the list, i.e. set size to zero.
List< scalarList > scalarListList
List of scalarList.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual const faceList & faces() const
Return raw faces.
const polyMesh & tgt_
Reference to the target mesh.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
Base class for mesh-to-mesh calculation methods.
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.
const indexedOctree< treeDataCell > & cellTree() const
Return the cell search tree.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual void calculate(labelListList &srcToTgtAddr, scalarListList &srcToTgtWght, pointListList &srcToTgtVec, labelListList &tgtToSrcAddr, scalarListList &tgtToSrcWght, pointListList &tgtToSrcVec)
Calculate addressing and weights and optionally offset vectors.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
virtual bool intersect(const label srcCelli, const label tgtCelli) const
Return the true if cells intersect.
List< bool > boolList
A List of bools.
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.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
UIndirectList< bool > boolUIndList
UIndirectList of bools.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)