35 void Foam::cellMapper::calcAddressing()
const 40 || interpolationAddrPtr_
42 || insertedCellLabelsPtr_
46 <<
"Addressing already calculated." 61 labelList& insertedCells = *insertedCellLabelsPtr_;
63 label nInsertedCells = 0;
67 if (directAddr[celli] < 0)
70 directAddr[celli] = 0;
71 insertedCells[nInsertedCells] = celli;
76 insertedCells.setSize(nInsertedCells);
93 const labelList& mo = cfp[cfpI].masterObjects();
95 label celli = cfp[cfpI].index();
97 if (addr[celli].
size())
100 <<
"Master cell " << celli
101 <<
" mapped from point cells " << mo
107 w[celli] =
scalarList(mo.size(), 1.0/mo.size());
115 const labelList& mo = cfe[cfeI].masterObjects();
117 label celli = cfe[cfeI].index();
119 if (addr[celli].
size())
122 <<
"Master cell " << celli
123 <<
" mapped from edge cells " << mo
129 w[celli] =
scalarList(mo.size(), 1.0/mo.size());
137 const labelList& mo = cff[cffI].masterObjects();
139 label celli = cff[cffI].index();
141 if (addr[celli].
size())
144 <<
"Master cell " << celli
145 <<
" mapped from face cells " << mo
151 w[celli] =
scalarList(mo.size(), 1.0/mo.size());
161 const labelList& mo = cfc[cfcI].masterObjects();
163 label celli = cfc[cfcI].index();
165 if (addr[celli].
size())
168 <<
"Master cell " << celli
169 <<
" mapped from cell cells " << mo
170 <<
" already destination of mapping." 187 <<
"cellVolumes size " << V.size()
189 <<
". Are your cellVolumes already mapped?" 190 <<
" (new number of cells " <<
size() <<
")" 196 const labelList& mo = cfc[cfcI].masterObjects();
198 label celli = cfc[cfcI].index();
207 w[celli][ci] = V[mo[ci]];
214 w[celli][ci] /= sumV;
220 w[celli] =
scalarList(mo.size(), 1.0/mo.size());
231 const labelList& mo = cfc[cfcI].masterObjects();
233 label celli = cfc[cfcI].index();
235 w[celli] =
scalarList(mo.size(), 1.0/mo.size());
247 if (cm[celli] > -1 && addr[celli].empty())
258 labelList& insertedCells = *insertedCellLabelsPtr_;
260 label nInsertedCells = 0;
264 if (addr[celli].empty())
270 insertedCells[nInsertedCells] = celli;
275 insertedCells.setSize(nInsertedCells);
280 void Foam::cellMapper::clearOut()
291 Foam::cellMapper::cellMapper(
const mapPolyMesh& mpm)
295 insertedCells_(true),
297 directAddrPtr_(nullptr),
298 interpolationAddrPtr_(nullptr),
299 weightsPtr_(nullptr),
300 insertedCellLabelsPtr_(nullptr)
321 insertedCells_ =
false;
336 cm[cfp[cfpI].index()] = 0;
343 cm[cfe[cfeI].index()] = 0;
350 cm[cff[cffI].index()] = 0;
357 cm[cfc[cfcI].index()] = 0;
362 insertedCells_ =
true;
380 return mpm_.cellMap().size();
386 return mpm_.nOldCells();
395 <<
"Requested direct addressing for an interpolative mapper." 399 if (!insertedObjects())
402 return mpm_.cellMap();
411 return *directAddrPtr_;
421 <<
"Requested interpolative addressing for a direct mapper." 425 if (!interpolationAddrPtr_)
430 return *interpolationAddrPtr_;
439 <<
"Requested interpolative weights for a direct mapper." 454 if (!insertedCellLabelsPtr_)
456 if (!insertedObjects())
459 insertedCellLabelsPtr_ =
new labelList(0);
467 return *insertedCellLabelsPtr_;
List< labelList > labelListList
A List of labelList.
const labelList & cellMap() const
Old cell map.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
virtual label sizeBeforeMapping() const
Return size before mapping.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const scalarListList & weights() const
Return interpolaion weights.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
const List< objectMap > & cellsFromCellsMap() const
Cells originating from cells.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
bool hasOldCellVolumes() const
#define forAll(list, i)
Loop across all elements in list.
void setSize(const label n)
Alias for resize()
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual const labelListList & addressing() const
Return interpolated addressing.
List< scalar > scalarList
A List of scalars.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
virtual const labelUList & directAddressing() const
Return direct addressing.
Template functions to aid in the implementation of demand driven data.
List< scalarList > scalarListList
A List of scalarList.
const List< objectMap > & cellsFromFacesMap() const
Cells inflated from faces.
const scalarField & oldCellVolumes() const
label nCells() const noexcept
Number of mesh cells.
List< label > labelList
A List of labels.
virtual label size() const
Return size.
const List< objectMap > & cellsFromEdgesMap() const
Cells inflated from edges.
virtual const labelList & insertedObjectLabels() const
Return list of inserted cells.
const List< objectMap > & cellsFromPointsMap() const
Cells inflated from points.
void deleteDemandDrivenData(DataPtr &dataPtr)
virtual ~cellMapper()
Destructor.
virtual bool direct() const
Is the mapping direct.
static constexpr const zero Zero
Global zero (0)