33 void Foam::cellMapper::calcAddressing()
const
38 || interpolationAddrPtr_
40 || insertedCellLabelsPtr_
44 <<
"Addressing already calculated."
59 labelList& insertedCells = *insertedCellLabelsPtr_;
61 label nInsertedCells = 0;
65 if (directAddr[celli] < 0)
68 directAddr[celli] = 0;
69 insertedCells[nInsertedCells] = celli;
74 insertedCells.setSize(nInsertedCells);
91 const labelList& mo = cfp[cfpI].masterObjects();
93 label celli = cfp[cfpI].index();
95 if (addr[celli].size())
98 <<
"Master cell " << celli
99 <<
" mapped from point cells " << mo
105 w[celli] =
scalarList(mo.size(), 1.0/mo.size());
113 const labelList& mo = cfe[cfeI].masterObjects();
115 label celli = cfe[cfeI].index();
117 if (addr[celli].size())
120 <<
"Master cell " << celli
121 <<
" mapped from edge cells " << mo
127 w[celli] =
scalarList(mo.size(), 1.0/mo.size());
135 const labelList& mo = cff[cffI].masterObjects();
137 label celli = cff[cffI].index();
139 if (addr[celli].size())
142 <<
"Master cell " << celli
143 <<
" mapped from face cells " << mo
149 w[celli] =
scalarList(mo.size(), 1.0/mo.size());
159 const labelList& mo = cfc[cfcI].masterObjects();
161 label celli = cfc[cfcI].index();
163 if (addr[celli].size())
166 <<
"Master cell " << celli
167 <<
" mapped from cell cells " << mo
168 <<
" already destination of mapping."
185 <<
"cellVolumes size " << V.size()
187 <<
". Are your cellVolumes already mapped?"
188 <<
" (new number of cells " << mpm_.
cellMap().
size() <<
")"
194 const labelList& mo = cfc[cfcI].masterObjects();
196 label celli = cfc[cfcI].index();
198 w[celli].setSize(mo.size());
205 w[celli][ci] = V[mo[ci]];
212 w[celli][ci] /= sumV;
218 w[celli] =
scalarList(mo.size(), 1.0/mo.size());
229 const labelList& mo = cfc[cfcI].masterObjects();
231 label celli = cfc[cfcI].index();
233 w[celli] =
scalarList(mo.size(), 1.0/mo.size());
245 if (cm[celli] > -1 && addr[celli].empty())
256 labelList& insertedCells = *insertedCellLabelsPtr_;
258 label nInsertedCells = 0;
262 if (addr[celli].empty())
268 insertedCells[nInsertedCells] = celli;
273 insertedCells.setSize(nInsertedCells);
278 void Foam::cellMapper::clearOut()
293 insertedCells_(true),
295 directAddrPtr_(nullptr),
296 interpolationAddrPtr_(nullptr),
297 weightsPtr_(nullptr),
298 insertedCellLabelsPtr_(nullptr)
319 insertedCells_ =
false;
334 cm[cfp[cfpI].index()] = 0;
341 cm[cfe[cfeI].index()] = 0;
348 cm[cff[cffI].index()] = 0;
355 cm[cfc[cfcI].index()] = 0;
360 insertedCells_ =
true;
378 return mpm_.nOldCells();
387 <<
"Requested direct addressing for an interpolative mapper."
391 if (!insertedObjects())
394 return mpm_.cellMap();
403 return *directAddrPtr_;
413 <<
"Requested interpolative addressing for a direct mapper."
417 if (!interpolationAddrPtr_)
422 return *interpolationAddrPtr_;
431 <<
"Requested interpolative weights for a direct mapper."
446 if (!insertedCellLabelsPtr_)
448 if (!insertedObjects())
451 insertedCellLabelsPtr_ =
new labelList(0);
459 return *insertedCellLabelsPtr_;
#define forAll(list, i)
Loop across all elements in list.
void size(const label)
Override size to be inconsistent with allocated storage.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
cellMapper(const polyTopoChangeMap &mpm)
Construct from polyTopoChangeMap.
virtual ~cellMapper()
Destructor.
virtual const labelListList & addressing() const
Return interpolated addressing.
virtual const scalarListList & weights() const
Return interpolation weights.
virtual const labelUList & directAddressing() const
Return direct addressing.
virtual const labelList & insertedObjectLabels() const
Return list of inserted cells.
virtual label sizeBeforeMapping() const
Return size before mapping.
virtual bool direct() const
Is the mapping direct.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const List< objectMap > & cellsFromEdgesMap() const
Cells inflated from edges.
const List< objectMap > & cellsFromPointsMap() const
Cells inflated from points.
const labelList & cellMap() const
Old cell map.
const scalarField & oldCellVolumes() const
const List< objectMap > & cellsFromCellsMap() const
Cells originating from cells.
bool hasOldCellVolumes() const
const List< objectMap > & cellsFromFacesMap() const
Cells inflated from faces.
Template functions to aid in the implementation of demand driven data.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< scalarList > scalarListList
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManip< error > abort(error &err)
List< scalar > scalarList
A List of scalars.
void deleteDemandDrivenData(DataPtr &dataPtr)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< labelList > labelListList
A List of labelList.