35void Foam::pointMapper::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 pointi = map.index();
126 const labelList& mo = map.masterObjects();
127 if (mo.empty())
continue;
129 if (addr[pointi].
size())
132 <<
"Master point " << pointi
133 <<
" already mapped, cannot apply "
140 wght[pointi] =
scalarList(mo.size(), 1.0/mo.size());
147 setAddrWeights(mpm_.pointsFromPointsMap(),
"point points");
156 for (label pointi = 0; pointi < mapperLen_; ++pointi)
158 const label mappedi = map[pointi];
160 if (mappedi >= 0 && addr[pointi].empty())
163 addr[pointi].resize(1, mappedi);
164 wght[pointi].resize(1, 1.0);
171 insertedObjectsPtr_ = std::make_unique<labelList>();
172 auto& inserted = *insertedObjectsPtr_;
175 if (nInsertedObjects_)
177 inserted.resize(nInsertedObjects_);
185 addr[i].resize(1, 0);
186 wght[i].resize(1, 1.0);
188 inserted[nInserted] = i;
193 if (nInsertedObjects_ < nInserted)
196 <<
"Unexpected insert of more than "
197 << nInsertedObjects_ <<
" items\n"
205 if (nInserted < nInsertedObjects_)
208 <<
"Found " << nInserted <<
" instead of "
209 << nInsertedObjects_ <<
" items to insert\n";
213 inserted.resize(nInserted);
233 mapperLen_(pMesh.
size()),
234 nInsertedObjects_(0),
238 mpm.pointsFromPointsMap().empty()
241 const auto& directMap = mpm_.pointMap();
247 nInsertedObjects_ = 0;
252 nInsertedObjects_ = std::count_if
255 directMap.cbegin(mapperLen_),
256 [](label i) { return (i < 0); }
264 bitSet unmapped(mapperLen_,
true);
266 unmapped.
unset(directMap);
268 for (
const objectMap& map : mpm_.pointsFromPointsMap())
270 if (!map.empty()) unmapped.
unset(map.index());
273 nInsertedObjects_ = label(unmapped.
count());
289 return mpm_.pointMap().size();
295 return mpm_.nOldPoints();
304 <<
"Requested direct addressing for an interpolative mapper."
308 if (!insertedObjects())
311 return mpm_.pointMap();
320 return *directAddrPtr_;
330 <<
"Requested interpolative addressing for a direct mapper."
339 return *interpAddrPtr_;
348 <<
"Requested interpolative weights for a direct mapper."
363 if (!insertedObjectsPtr_)
365 if (!nInsertedObjects_)
374 return *insertedObjectsPtr_;
static const List< label > & null() noexcept
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
unsigned int count(const bool on=true) const
Count number of bits set.
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
An objectMap is a pair of labels defining the mapping of an object from another object,...
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 label size() const
The mapper size.
const labelList & insertedObjectLabels() const
Return list of inserted points.
virtual ~pointMapper()
Destructor.
virtual label sizeBeforeMapping() const
Return size before mapping.
pointMapper(const pointMapper &)=delete
No copy construct.
bool insertedObjects() const noexcept
Are there any inserted points.
virtual bool direct() const
Is the mapping direct.
Mesh representing a set of points created from polyMesh.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
List< scalarList > scalarListList
List of scalarList.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
List< scalar > scalarList
List of scalar.
#define forAll(list, i)
Loop across all elements in list.