35 void 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());
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;
255 directMap.cbegin(mapperLen_),
256 [](label i) {
return (i < 0); }
264 bitSet unmapped(mapperLen_,
true);
266 unmapped.
unset(directMap);
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_;
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.
virtual const labelListList & addressing() const
Return interpolated addressing.
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...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual label sizeBeforeMapping() const
Return size before mapping.
const labelList & insertedObjectLabels() const
Return list of inserted points.
virtual ~pointMapper()
Destructor.
SubList< label > subList
Declare type of subList.
An objectMap is a pair of labels defining the mapping of an object from another object, e.g. a cell mapped from a point.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Mesh representing a set of points created from polyMesh.
#define forAll(list, i)
Loop across all elements in list.
virtual const scalarListList & weights() const
Return interpolation weights.
virtual const labelUList & directAddressing() const
Return direct addressing.
virtual label size() const
The mapper size.
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
const labelList & pointMap() const noexcept
Old point map.
virtual bool direct() const
Is the mapping direct.
errorManip< error > abort(error &err)
const List< objectMap > & pointsFromPointsMap() const noexcept
Points originating from points.
pointMapper(const pointMapper &)=delete
No copy construct.
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.
List< label > labelList
A List of labels.
static const List< label > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.