46template<
class MatchPredicate>
50 const MatchPredicate& nameMatcher
61 lookupName =
"cellTable_" +
Foam::name(iter.key());
64 if (nameMatcher(lookupName))
66 output.
emplace(iter.key(), std::move(lookupName));
78void Foam::cellTable::addDefaults()
82 if (!iter().
found(
"MaterialType"))
90void Foam::cellTable::setEntry
116 const objectRegistry& obr,
118 const fileName& instance
132 if (maxId < iter.key())
167 const auto iter = cfind(
id);
170 iter.val().readIfPresent(
"Label", lookupName);
173 if (lookupName.empty() &&
id >= 0)
191 const auto&
dict = iter.val();
217 output.emplace(iter.key(), std::move(lookupType));
240 if (
dict.readIfPresent(
"Label", lookupName))
242 lookupName =
"cellTable_" +
Foam::name(iter.key());
245 output.emplace(iter.key(), std::move(lookupName));
273 setEntry(
id,
"MaterialType", matlType);
279 setEntry(
id,
"Label",
name);
287 if (!iter.good() || !iter().
found(
"Label"))
296 const objectRegistry& obr,
298 const fileName& instance
304 IOMap<dictionary> ioObj
317 if (ioObj.headerOk())
324 Info<<
"no constant/cellTable information available" <<
endl;
331 const objectRegistry& obr,
333 const fileName& instance
337 IOMap<dictionary> ioObj
351 "persistent data for third-party mesh <-> OpenFOAM translation";
353 Info<<
"Writing " << ioObj.name() <<
" to "
354 << ioObj.objectRelPath() <<
endl;
356 OFstream
os(ioObj.objectPath());
357 ioObj.writeHeader(
os);
385 label nZoneCells = 0;
388 label unZonedType = zoneNames.
size() + 1;
394 nZoneCells += cZone.
size();
397 dict.add(
"Label", zoneNames[zoneI]);
446 for (
const label
id : namesLookup.
sortedToc())
448 typeToZone(
id) = zonei;
449 zoneNames[zonei] = namesLookup[id];
459 label zonei = typeToZone.
lookup(tableIds[celli], -1);
462 zoneCells[zonei].push_back(celli);
471 zoneCells[zonei].shrink();
472 if (!zoneCells[zonei].empty())
474 zoneUsed.push_back(zonei);
478 const label nZonesUsed = zoneUsed.size();
485 Info<<
"cellZones not used" <<
endl;
488 czMesh.resize(nZonesUsed);
492 const label origZonei = zoneUsed[zonei];
494 Info<<
"cellZone " << zonei
495 <<
" (size: " << zoneCells[origZonei].size()
496 <<
") name: " << zoneNames[origZonei] <<
endl;
503 zoneNames[origZonei],
504 zoneCells[origZonei],
525 for (
const entry& dEntry : mapDict)
527 wordRes patterns(dEntry.stream());
533 if (patterns.match(namesIter()))
535 matches.insert(namesIter.key(), namesIter());
541 label targetId = this->
findIndex(dEntry.keyword());
543 Info<<
"combine cellTable: " << dEntry.keyword();
547 targetId =
min(matches.toc());
548 operator[](targetId).set(
"Label", dEntry.keyword());
559 matches.erase(targetId);
560 origNames.erase(targetId);
563 this->
erase(matches);
564 origNames.erase(matches);
568 mapping[matchIter.key()] = targetId;
569 Info<<
" " << matchIter();
Various functions to operate on Lists.
propsDict readIfPresent("fields", acceptFields)
static const char *const defaultMaterial_
bool empty() const noexcept
True if the list is empty.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void push_back(const T &val)
Copy append an element to the end of this list.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
bool empty() const noexcept
const T & lookup(const Key &key, const T &deflt) const
Return hashed entry if it exists, or return the given default.
const_iterator cfind(const label &key) const
void reserve(label numEntries)
Reserve space for at least the specified number of elements (not the number of buckets) and regenerat...
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
iterator find(const label &key)
label size() const noexcept
The number of elements in table.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
bool emplace(const Key &key, Args &&... args)
Emplace insert a new entry, not overwriting existing entries.
void clear()
Remove all entries from table.
dictionary & operator[](const label &key)
A Map of objects of type <T> with automated input and output. Is a global object; i....
@ NO_REGISTER
Do not request registration (bool: false).
writeOption writeOpt() const noexcept
Get the write option.
@ NO_READ
Nothing to be read.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
@ AUTO_WRITE
Automatically write from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const word & name() const noexcept
Return the object name.
static Ostream & writeEndDivider(Ostream &os)
Write the standard end file divider.
fileName objectRelPath() const
The object path relative to the case.
const string & note() const noexcept
Return the optional note.
fileName objectPath() const
The complete path + object name.
bool writeHeader(Ostream &os) const
Write header with current type().
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
void push_back(const T &val)
Append an element at the end of the list.
void resize(const label len)
Adjust allocated size of list.
A HashTable to objects of type <T> with a label key.
constexpr Map() noexcept=default
void operator=(const this_type &rhs)
Copy assignment.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
void resize(const label newLen)
Adjust size of PtrList.
void size(const label n)
Older name for setAddressableSize.
void clear()
Clear the zones.
Map< word > solids() const
Return a Map of (id => name) for solids.
void setMaterial(const label, const word &)
Assign material Type.
label findIndex(const word &name) const
The index corresponding to entry with 'Label' of given name, or -1 if not found.
void readDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant")
Read constant/cellTable.
Map< word > shells() const
Return a Map of (id => name) for shells.
label maxIndex() const
The max table index, -1 if empty.
word name(const label id) const
The 'Label' name corresponding to id, or cellTable_ID if not otherwise defined.
Map< word > fluids() const
Return a Map of (id => name) for fluids.
void setName(const label, const word &)
Assign name.
Map< word > selectType(const word &materialType) const
Return the extracted Map of (id => name) for materialType (fluid | solid | shell).
void operator=(const cellTable &)
Assignment.
cellTable(const cellTable &)=delete
No copy construct.
void addCellZones(polyMesh &, const labelList &tableIds) const
Classify tableIds into cellZones according to the cellTable.
Map< word > names() const
Return the extracted Map of (id => name).
Map< word > materialTypes() const
Return a Map of (id => fluid|solid|shell).
void writeDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant") const
Write constant/cellTable for later reuse.
cellTable() noexcept=default
Default construct.
label push_back(const dictionary &dict)
Add to the end, return index.
void combine(const dictionary &mapDict, labelList &tableIds)
Combine tableIds together.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
A keyword and a list of tokens is an 'entry'.
A class for handling file names.
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
label nCells() const noexcept
Number of mesh cells.
bool headerOk()
Read and check header info. Does not check the headerClassName.
A List of wordRe with additional matching capabilities.
static bool match(const UList< wordRe > &selectors, const std::string &text, bool literal=false)
Test for a match of any selectors against the text.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as ListOps::find_if.
List< word > wordList
List of word.
label findIndex(const ListType &input, typename ListType::const_reference val, const label start=0)
Deprecated(2017-10) search for first occurrence of the given element.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values within a list.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
static Map< word > names_impl(const Map< dictionary > &input, const MatchPredicate &nameMatcher)
Ostream & endl(Ostream &os)
Add newline and flush stream.
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with cellZone content on a polyMesh.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
nonInt insert("surfaceSum(((S|magSf)*S)")
#define forAll(list, i)
Loop across all elements in list.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Unary and binary predicates that always return true, useful for templating.