34 void Foam::meshToMesh0::calculateInverseDistanceWeights()
const 37 <<
"Calculating inverse distance weighting factors" <<
nl;
39 if (inverseDistanceWeightsPtr_)
42 <<
"weighting factors already calculated" 50 auto& invDistCoeffs = *inverseDistanceWeightsPtr_;
57 forAll(cellAddressing_, celli)
59 if (cellAddressing_[celli] != -1)
61 const vector& target = centreTo[celli];
62 scalar m =
mag(target - centreFrom[cellAddressing_[celli]]);
64 const labelList& neighbours = cc[cellAddressing_[celli]];
68 label directCelli = -1;
69 if (m < directHitTol || neighbours.empty())
77 scalar nm =
mag(target - centreFrom[neighbours[ni]]);
78 if (nm < directHitTol)
80 directCelli = neighbours[ni];
87 if (directCelli != -1)
90 invDistCoeffs[directCelli].setSize(1);
91 invDistCoeffs[directCelli][0] = 1.0;
92 V_ += fromMesh_.
V()[cellAddressing_[directCelli]];
96 invDistCoeffs[celli].setSize(neighbours.size() + 1);
100 scalar invDist = 1.0/m;
101 invDistCoeffs[celli][0] = invDist;
102 scalar sumInvDist = invDist;
107 invDist = 1.0/
mag(target - centreFrom[neighbours[ni]]);
108 invDistCoeffs[celli][ni + 1] = invDist;
109 sumInvDist += invDist;
113 forAll(invDistCoeffs[celli], i)
115 invDistCoeffs[celli][i] /= sumInvDist;
120 invDistCoeffs[celli][0]
121 *fromMesh_.
V()[cellAddressing_[celli]];
122 for (label i = 1; i < invDistCoeffs[celli].size(); i++)
125 invDistCoeffs[celli][i]*fromMesh_.
V()[neighbours[i-1]];
133 void Foam::meshToMesh0::calculateInverseVolumeWeights()
const 136 <<
"Calculating inverse volume weighting factors" <<
endl;
138 if (inverseVolumeWeightsPtr_)
141 <<
"weighting factors already calculated" 148 inverseVolumeWeightsPtr_.reset(
new scalarListList(toMesh_.nCells()));
149 auto& invVolCoeffs = *inverseVolumeWeightsPtr_;
153 tetOverlapVolume overlapEngine;
157 const labelList& overlapCells = cellToCell[celli];
159 if (overlapCells.size() > 0)
161 invVolCoeffs[celli].
setSize(overlapCells.size());
165 label cellFrom = overlapCells[j];
166 treeBoundBox bbFromMesh
171 fromMesh_.cellPoints()[cellFrom]
175 scalar v = overlapEngine.cellCellOverlapVolumeMinDecomp
184 invVolCoeffs[celli][j] = v/toMesh_.V()[celli];
193 void Foam::meshToMesh0::calculateCellToCellAddressing()
const 196 <<
"Calculating cell to cell addressing" <<
endl;
198 if (cellToCellAddressingPtr_)
201 <<
"addressing already calculated" 208 tetOverlapVolume overlapEngine;
210 cellToCellAddressingPtr_.reset(
new labelListList(toMesh_.nCells()));
211 auto& cellToCell = *cellToCellAddressingPtr_;
217 overlapEngine.overlappingCells(fromMesh_, toMesh_, iTo);
218 if (overLapCells.size() > 0)
220 cellToCell[iTo].
setSize(overLapCells.size());
223 cellToCell[iTo][j] = overLapCells[j];
224 V_ += fromMesh_.V()[overLapCells[j]];
234 if (!inverseDistanceWeightsPtr_)
236 calculateInverseDistanceWeights();
239 return *inverseDistanceWeightsPtr_;
245 if (!inverseVolumeWeightsPtr_)
247 calculateInverseVolumeWeights();
250 return *inverseVolumeWeightsPtr_;
256 if (!cellToCellAddressingPtr_)
258 calculateCellToCellAddressing();
261 return *cellToCellAddressingPtr_;
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
List< labelList > labelListList
List of labelList.
#define forAll(list, i)
Loop across all elements in list.
vectorField pointField
pointField is a vectorField.
void setSize(const label n)
Alias for resize()
List< scalarList > scalarListList
List of scalarList.
#define DebugInFunction
Report an information message using Foam::Info.
label nCells() const noexcept
Number of mesh cells.
Field< vector > vectorField
Specialisation of Field<T> for vector.
const volVectorField & C() const
Return cell centres as volVectorField.
List< label > labelList
A List of labels.
const labelListList & cellCells() const