35 void Foam::faceMapper::calcAddressing()
const 42 || insertedObjectsPtr_
46 <<
"Addressing already calculated." 55 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 facei = map.index();
126 const labelList& mo = map.masterObjects();
127 if (mo.empty())
continue;
129 if (addr[facei].
size())
132 <<
"Master face " << facei
133 <<
" already mapped, cannot apply " 140 wght[facei] =
scalarList(mo.size(), 1.0/mo.size());
157 for (label facei = 0; facei < mapperLen_; ++facei)
159 const label mappedi = map[facei];
161 if (mappedi >= 0 && addr[facei].empty())
164 addr[facei].
resize(1, mappedi);
165 wght[facei].resize(1, 1.0);
173 insertedObjectsPtr_ = std::make_unique<labelList>();
174 auto& inserted = *insertedObjectsPtr_;
177 if (nInsertedObjects_)
179 inserted.resize(nInsertedObjects_);
187 addr[i].resize(1, 0);
188 wght[i].resize(1, 1.0);
190 inserted[nInserted] = i;
195 if (nInsertedObjects_ < nInserted)
198 <<
"Unexpected insert of more than " 199 << nInsertedObjects_ <<
" items\n" 207 if (nInserted < nInsertedObjects_)
210 <<
"Found " << nInserted <<
" instead of " 211 << nInsertedObjects_ <<
" items to insert\n";
215 inserted.resize(nInserted);
235 mapperLen_(mpm.
mesh().nFaces()),
236 nInsertedObjects_(0),
240 mpm.facesFromPointsMap().empty()
241 && mpm.facesFromEdgesMap().empty()
242 && mpm.facesFromFacesMap().empty()
245 const auto& directMap = mpm_.
faceMap();
251 nInsertedObjects_ = 0;
259 directMap.cbegin(mapperLen_),
260 [](label i) {
return (i < 0); }
268 bitSet unmapped(mapperLen_,
true);
270 unmapped.
unset(directMap);
274 if (!map.empty()) unmapped.
unset(map.index());
279 if (!map.empty()) unmapped.
unset(map.index());
284 if (!map.empty()) unmapped.
unset(map.index());
287 nInsertedObjects_ = label(unmapped.
count());
308 return mpm_.nOldFaces();
314 return mpm_.nOldInternalFaces();
323 <<
"Requested direct addressing for an interpolative mapper." 327 if (!insertedObjects())
330 return mpm_.faceMap();
339 return *directAddrPtr_;
349 <<
"Requested interpolative addressing for a direct mapper." 358 return *interpAddrPtr_;
367 <<
"Requested interpolative weights for a direct mapper." 382 if (!insertedObjectsPtr_)
384 if (!nInsertedObjects_)
393 return *insertedObjectsPtr_;
399 return mpm_.flipFaceFlux();
405 return mpm_.nOldInternalFaces();
411 return mpm_.oldPatchStarts();
417 return mpm_.oldPatchSizes();
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 label internalSizeBeforeMapping() const
Return number of internal faces before mapping.
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 const labelList & insertedObjectLabels() const
Return list of inserted faces.
SubList< label > subList
Declare type of subList.
const List< objectMap > & facesFromPointsMap() const noexcept
Faces inflated from points.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
virtual label sizeBeforeMapping() const
Return size of field before mapping.
#define forAll(list, i)
Loop across all elements in list.
faceMapper(const faceMapper &)=delete
No copy construct.
virtual const labelListList & addressing() const
Return interpolated addressing.
virtual const labelHashSet & flipFaceFlux() const
Return flux flip map.
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
virtual const scalarListList & weights() const
Return interpolaion weights.
errorManip< error > abort(error &err)
const List< objectMap > & facesFromEdgesMap() const noexcept
Faces inflated from edges.
virtual bool direct() const
Is the mapping direct.
virtual ~faceMapper()
Destructor.
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.
virtual label size() const
The mapper size.
virtual const labelList & oldPatchStarts() const
Return old patch starts.
const labelList & faceMap() const noexcept
Old face map.
virtual label nOldInternalFaces() const
Return number of old internalFaces.
List< label > labelList
A List of labels.
const List< objectMap > & facesFromFacesMap() const noexcept
Faces originating from faces.
virtual const labelUList & directAddressing() const
Return direct addressing.
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.
virtual const labelList & oldPatchSizes() const
Return old patch sizes.