35 void Foam::cellMapper::calcAddressing()
const 42 || insertedObjectsPtr_
46 <<
"Addressing already calculated." 54 directAddrPtr_ = std::make_unique<labelList>
59 auto& directAddr = *directAddrPtr_;
61 insertedObjectsPtr_ = std::make_unique<labelList>();
62 auto& inserted = *insertedObjectsPtr_;
65 if (nInsertedObjects_)
67 inserted.resize(nInsertedObjects_);
72 if (directAddr[i] < 0)
76 inserted[nInserted] = i;
81 if (nInsertedObjects_ < nInserted)
84 <<
"Unexpected insert of more than " 85 << nInsertedObjects_ <<
" items\n" 93 if (nInserted < nInsertedObjects_)
96 <<
"Found " << nInserted <<
" instead of " 97 << nInsertedObjects_ <<
" items to insert\n";
101 inserted.resize(nInserted);
108 interpAddrPtr_ = std::make_unique<labelListList>(mapperLen_);
109 auto& addr = *interpAddrPtr_;
111 weightsPtr_ = std::make_unique<scalarListList>(mapperLen_);
112 auto& wght = *weightsPtr_;
116 const auto setAddrWeights = [&]
118 const List<objectMap>& maps,
119 const char *
const nameOfMap
122 for (
const objectMap& map : maps)
125 const label celli = map.index();
126 const labelList& mo = map.masterObjects();
127 if (mo.empty())
continue;
129 if (addr[celli].
size())
132 <<
"Master cell " << celli
133 <<
" already mapped, cannot apply " 140 wght[celli] =
scalarList(mo.size(), 1.0/mo.size());
152 setAddrWeights(cellsFromCells,
"cell cells");
163 <<
"cellVolumes size " << V.size()
165 <<
". Are your cellVolumes already mapped?" 166 <<
" (new number of cells " <<
size() <<
")" 170 for (
const auto& map : cellsFromCells)
173 const label celli = map.index();
174 const labelList& mo = map.masterObjects();
175 if (mo.empty())
continue;
178 auto& wght_cell = wght[celli];
183 wght_cell[ci] = V[mo[ci]];
188 for (
auto& w : wght_cell)
196 wght_cell = (1.0/mo.size());
209 for (label celli = 0; celli < mapperLen_; ++celli)
211 const label mappedi = map[celli];
213 if (mappedi >= 0 && addr[celli].empty())
216 addr[celli].
resize(1, mappedi);
217 wght[celli].resize(1, 1.0);
225 insertedObjectsPtr_ = std::make_unique<labelList>();
226 auto& inserted = *insertedObjectsPtr_;
229 if (nInsertedObjects_)
231 inserted.resize(nInsertedObjects_);
239 addr[i].resize(1, 0);
240 wght[i].resize(1, 1.0);
242 inserted[nInserted] = i;
247 if (nInsertedObjects_ < nInserted)
250 <<
"Unexpected insert of more than " 251 << nInsertedObjects_ <<
" items\n" 259 if (nInserted < nInsertedObjects_)
262 <<
"Found " << nInserted <<
" instead of " 263 << nInsertedObjects_ <<
" items to insert\n";
267 inserted.resize(nInserted);
287 mapperLen_(mpm.
mesh().nCells()),
288 nInsertedObjects_(0),
292 mpm.cellsFromPointsMap().empty()
293 && mpm.cellsFromEdgesMap().empty()
294 && mpm.cellsFromFacesMap().empty()
295 && mpm.cellsFromCellsMap().empty()
298 const auto& directMap = mpm_.
cellMap();
304 nInsertedObjects_ = 0;
312 directMap.cbegin(mapperLen_),
313 [](label i) {
return (i < 0); }
321 bitSet unmapped(mapperLen_,
true);
323 unmapped.
unset(directMap);
327 if (!map.empty()) unmapped.
unset(map.index());
332 if (!map.empty()) unmapped.
unset(map.index());
337 if (!map.empty()) unmapped.
unset(map.index());
342 if (!map.empty()) unmapped.
unset(map.index());
345 nInsertedObjects_ = label(unmapped.
count());
361 return mpm_.cellMap().size();
367 return mpm_.nOldCells();
376 <<
"Requested direct addressing for an interpolative mapper." 380 if (!insertedObjects())
383 return mpm_.cellMap();
392 return *directAddrPtr_;
402 <<
"Requested interpolative addressing for a direct mapper." 411 return *interpAddrPtr_;
420 <<
"Requested interpolative weights for a direct mapper." 435 if (!insertedObjectsPtr_)
437 if (!nInsertedObjects_)
446 return *insertedObjectsPtr_;
List< scalar > scalarList
List of scalar.
unsigned int count(const bool on=true) const
Count number of bits set.
label count_if(const ListType &input, const UnaryPredicate &pred, const label start=0)
Count the number of matching entries.
void resize(const label len)
Adjust allocated size of list.
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 hasOldCellVolumes() const noexcept
cellMapper(const cellMapper &)=delete
No copy construct.
SubList< label > subList
Declare type of subList.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
#define forAll(list, i)
Loop across all elements in list.
const List< objectMap > & cellsFromCellsMap() const noexcept
Cells originating from cells.
const labelList & cellMap() const noexcept
Old cell map.
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const List< objectMap > & cellsFromPointsMap() const noexcept
Cells inflated from points.
virtual const labelListList & addressing() const
Return interpolated addressing.
errorManip< error > abort(error &err)
virtual const labelUList & directAddressing() const
Return direct addressing.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
const scalarField & oldCellVolumes() const
const List< objectMap > & cellsFromEdgesMap() const noexcept
Cells inflated from edges.
const List< objectMap > & cellsFromFacesMap() const noexcept
Cells inflated from faces.
List< label > labelList
A List of labels.
virtual label size() const
The mapper size.
virtual const labelList & insertedObjectLabels() const
Return list of inserted cells.
virtual ~cellMapper()
Destructor.
static const List< label > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
virtual bool direct() const
Is the mapping direct.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.