54 if (flipMap_.
size() == addressing_.
size())
79 const label initialCapacity,
98 const auto& zones =
mesh.faceZones();
99 const auto* zonePtr = zones.cfindZone(
name);
106 <<
"Zone named " <<
name <<
" not found. "
107 <<
"List of available zone names: " << zones.names() <<
nl
113 const auto& zn = *zonePtr;
114 addressing_ = zn.addressing();
115 flipMap_ = zn.flipMap();
125 const polyMesh&
mesh,
131 faceZoneSet(
mesh,
name, label(0), wOpt)
137 addressing_ = zonePtr->addressing();
138 flipMap_ = zonePtr->flipMap();
143 addressing_ =
set.sortedToc();
157 for (label
id = 0;
id < maxLen; ++id)
166 addressing_.resize_nocopy(
n);
167 flipMap_.resize_nocopy(
n);
170 for (label
id = 0;
id < maxLen; ++id)
183void Foam::faceZoneSet::subset
199 const label facei = setAddressing[i];
201 const auto iter = faceToIndex.cfind(facei);
205 const label index = iter.val();
207 if (setFlipMap.size() && (setFlipMap[i] != flipMap_[index]))
211 newAddressing.append(facei);
212 newFlipMap.append(flipMap_[index]);
219 <<
"subset : there are " << nConflict
220 <<
" faces with different orientation in faceZoneSets "
221 <<
name() <<
" and " << setName <<
endl;
224 addressing_.transfer(newAddressing);
225 flipMap_.transfer(newFlipMap);
230void Foam::faceZoneSet::subset(
const topoSet& set)
236 subset(zonePtr->name(), zonePtr->addressing(), zonePtr->flipMap());
251void Foam::faceZoneSet::subset(
const labelUList& elems)
257void Foam::faceZoneSet::addSet
273 const label facei = setAddressing[i];
274 const auto iter = faceToIndex.cfind(facei);
278 const label index = iter.val();
280 if (setFlipMap.size() && (setFlipMap[i] != flipMap_[index]))
287 newAddressing.append(facei);
288 newFlipMap.append(setFlipMap.size() ? setFlipMap[i] :
false);
295 <<
"addSet : there are " << nConflict
296 <<
" faces with different orientation in faceZonesSets "
297 <<
name() <<
" and " << setName <<
endl;
300 addressing_.transfer(newAddressing);
301 flipMap_.transfer(newFlipMap);
306void Foam::faceZoneSet::addSet(
const topoSet& set)
312 addSet(zonePtr->name(), zonePtr->addressing(), zonePtr->flipMap());
327void Foam::faceZoneSet::addSet(
const labelUList& elems)
333void Foam::faceZoneSet::subtractSet
349 const label facei = addressing_[i];
351 const auto iter = faceToIndex.cfind(facei);
355 const label index = iter.val();
357 if (setFlipMap.size() && (setFlipMap[index] != flipMap_[i]))
365 newAddressing.append(facei);
366 newFlipMap.append(setFlipMap.size() ? setFlipMap[i] :
false);
373 <<
"subtractSet : there are " << nConflict
374 <<
" faces with different orientation in faceZonesSets "
375 <<
name() <<
" and " << setName <<
endl;
378 addressing_.transfer(newAddressing);
379 flipMap_.transfer(newFlipMap);
384void Foam::faceZoneSet::subtractSet(
const topoSet& set)
390 subtractSet(zonePtr->name(), zonePtr->addressing(), zonePtr->flipMap());
405void Foam::faceZoneSet::subtractSet(
const labelUList& elems)
425 const label UNFLIPPED = 1;
426 const label FLIPPED = -1;
431 const label facei = addressing_[i];
445 mesh.nBoundaryFaces(),
446 mesh.nInternalFaces()
460 DynamicList<label> newAddressing(set.size());
461 DynamicList<bool> newFlipMap(set.size());
463 for (
const label facei : set)
466 if (facei <
mesh.nInternalFaces())
468 newAddressing.append(facei);
469 newFlipMap.append(myZoneFace[facei] == FLIPPED);
473 const label myStat = myZoneFace[facei];
480 if (neiStat == UNFLIPPED)
483 newAddressing.append(facei);
484 newFlipMap.append(
true);
486 else if (neiStat == FLIPPED)
488 newAddressing.append(facei);
489 newFlipMap.append(
false);
494 newAddressing.append(facei);
495 newFlipMap.append(!isMasterFace[facei]);
500 if (myStat == neiStat)
503 newAddressing.append(facei);
504 if (isMasterFace[facei])
506 newFlipMap.append(myStat == FLIPPED);
510 newFlipMap.append(neiStat == UNFLIPPED);
515 newAddressing.append(facei);
516 newFlipMap.append(myStat == FLIPPED);
522 addressing_.transfer(newAddressing);
523 flipMap_.transfer(newFlipMap);
530 return mesh.nFaces();
537 const bool writeOnProc
542 const_cast<word&
>(
type()) = faceSet::typeName;
544 const_cast<word&
>(
type()) = oldTypeName;
547 auto& zones =
const_cast<polyMesh&
>(mesh_).faceZones();
548 auto* zonePtr = zones.findZone(
name());
552 zonePtr->resetAddressing(addressing_, flipMap_);
567 return ok && zones.write(writeOnProc);
578 label facei = addressing_[i];
587 addressing_.
transfer(newAddressing);
588 flipMap_.transfer(newFlipMap);
Various functions to operate on Lists.
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
void push_back(const T &val)
Copy append an element to the end of this list.
void reserve(label numEntries)
Reserve space for at least the specified number of elements (not the number of buckets) and regenerat...
void clearStorage()
Remove all entries from table and the table itself.
label size() const noexcept
The number of elements in table.
bool isAnyRead() const noexcept
True if any reading may be required (ie, != NO_READ).
static bool isReadRequired(readOption opt) noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
readOption
Enumeration defining read preferences.
writeOption
Enumeration defining write preferences.
static bool isAnyRead(readOption opt) noexcept
True if any reading may be required (ie, != NO_READ).
A simple container for options an IOstream can normally have.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
static const List< bool > & null() noexcept
A HashTable to objects of type <T> with a label key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A non-owning sub-view of a List (allocated or unallocated storage).
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
faceSet(const IOobject &io)
Construct from IOobject. No checking.
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Write maxLen items with label and coordinates.
Like faceSet but -reads data from faceZone -updates faceZone when writing.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write faceZone using stream options.
virtual void invert(const label maxLen)
Invert contents.
faceZoneSet(const polyMesh &mesh, const word &name, IOobjectOption::readOption rOpt=IOobjectOption::MUST_READ, IOobjectOption::writeOption wOpt=IOobjectOption::NO_WRITE)
Construct from objectRegistry and name.
virtual label maxSize(const polyMesh &mesh) const
Return max index+1.
virtual void sync(const polyMesh &mesh)
Sync faceZoneSet across coupled patches.
virtual void writeDebug(Ostream &os, const primitiveMesh &, const label maxLen) const
Write maxLen items with label and coordinates.
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels.
void updateSet()
Sort addressing and make faceSet part consistent with addressing.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseFaceMap() const noexcept
Reverse face map.
Mesh consisting of general polyhedral cells.
void clearAddressing(const bool isMeshUpdate=false)
Clear addressing.
Cell-face mesh analysis engine.
label nInternalFaces() const noexcept
Number of internal faces.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
General set of labels of mesh quantity (points, cells, faces).
virtual bool contains(const label id) const
Has the given index?
virtual bool set(const label id)
Set an index.
virtual void check(const label maxSize)
Check limits on addressable range.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
#define defineTypeName(Type)
Define the typeName.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Map< label > invertToMap(const labelUList &values)
Create inverse mapping, which is a lookup table into the given list.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
UIndirectList< label > labelUIndList
UIndirectList of labels.
List< T > subset(const BoolListType &select, const UList< T > &input, const bool invert=false)
Extract elements of the input list when select is true.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
void sort(UList< T > &list)
Sort the list.
UIndirectList< bool > boolUIndList
UIndirectList of bools.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.