35 const char*
const Foam::cellTable::defaultMaterial_ =
"fluid";
47 lookup.insert(iter.key(), zonei++);
56 Map<word> lookup =
names();
62 list[zonei++] = *iter;
69 void Foam::cellTable::addDefaults()
73 if (!iter().
found(
"MaterialType"))
75 iter().add(
"MaterialType", defaultMaterial_);
81 void Foam::cellTable::setEntry
91 iterator iter =
find(
id);
120 readDict(registry,
name, instance);
131 if (maxId < iter.key())
151 iter().getOrDefault<word>
165 const wordRes& patterns
172 const word lookupName = iter().getOrDefault<word>
178 if (patterns.match(lookupName))
180 lookup.insert(iter.key(), lookupName);
192 const_iterator iter = cfind(
id);
195 iter().readIfPresent(
"Label", theName);
230 iter().getOrDefault<word>(
"MaterialType", defaultMaterial_)
244 const label index = iter.key();
245 const dictionary&
dict = iter.val();
271 return selectType(
"fluid");
277 return selectType(
"solid");
283 return selectType(
"shell");
290 setEntry(
id,
"MaterialType", matlType);
296 setEntry(
id,
"Label",
name);
302 iterator iter =
find(
id);
304 if (!iter.good() || !iter().found(
"Label"))
313 const objectRegistry& registry,
315 const fileName& instance
321 IOMap<dictionary> ioObj
334 if (ioObj.headerOk())
341 Info<<
"no constant/cellTable information available" <<
endl;
348 const objectRegistry& registry,
350 const fileName& instance
354 IOMap<dictionary> ioObj
368 "persistent data for thirdParty mesh <-> OpenFOAM translation";
370 Info<<
"Writing " << ioObj.name() <<
" to " << ioObj.objectPath() <<
endl;
372 OFstream
os(ioObj.objectPath());
373 ioObj.writeHeader(
os);
399 label nZoneCells = 0;
402 label unZonedType = zoneNames.
size() + 1;
408 nZoneCells += cZone.
size();
411 dict.
add(
"Label", zoneNames[zoneI]);
428 dictionary(IStringStream(
"Label cells;")())
450 const auto iter = typeToZone.
cfind(tableIds[celli]);
453 zoneCells[*iter].append(celli);
464 zoneCells[zoneI].shrink();
465 if (zoneCells[zoneI].size())
467 zoneUsed[nZone++] = zoneI;
470 zoneUsed.setSize(nZone);
477 Info<<
"cellZones not used" <<
endl;
480 czMesh.setSize(nZone);
484 const label origZoneI = zoneUsed[zoneI];
486 Info<<
"cellZone " << zoneI
487 <<
" (size: " << zoneCells[origZoneI].size()
488 <<
") name: " << zoneNames[origZoneI] <<
endl;
495 zoneNames[origZoneI],
496 zoneCells[origZoneI],
513 Map<word> origNames(
names());
519 wordRes patterns(iter().stream());
525 if (patterns.
match(namesIter()))
527 matches.insert(namesIter.key(), namesIter());
533 label targetId = this->
findIndex(iter().keyword());
535 Info<<
"combine cellTable: " << iter().keyword();
539 targetId =
min(matches.toc());
540 operator[](targetId).set(
"Label", iter().keyword());
551 matches.erase(targetId);
552 origNames.erase(targetId);
555 this->
erase(matches);
556 origNames.erase(matches);
560 mapping[matchIter.key()] = targetId;
561 Info<<
" " << matchIter();
label find(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as ListOps::find_if.
label append(const dictionary &)
Append to the end, return index.
void size(const label n)
Older name for setAddressableSize.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
A class for handling file names.
void clear()
Clear the zones.
Map< word > shells() const
Return a Map of (id => name) for shells.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
srcOptions insert("case", fileName(rootDirSource/caseDirSource))
void setName(const label, const word &)
Assign name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Map< word > solids() const
Return a Map of (id => name) for solids.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Ignore writing from objectRegistry::writeObject()
Lookup type of boundary radiation properties.
void setMaterial(const label, const word &)
Assign material Type.
void operator=(const cellTable &)
Assignment.
#define forAll(list, i)
Loop across all elements in list.
void writeDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant") const
Write constant/cellTable for later reuse.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
void readDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant")
Read constant/cellTable.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
A class for handling words, derived from Foam::string.
void clear()
Clear all entries from table.
Map< word > names() const
Return a Map of (id => name)
Map< word > materialTypes() const
Return a Map of (id => fluid|solid|shell)
Reading is optional [identical to LAZY_READ].
#define forAllIters(container, iter)
Iterate across all elements in the container object.
static const word null
An empty word.
Map< word > fluids() const
Return a Map of (id => name) for fluids.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
The cellTable persistent data saved as a Map<dictionary>.
word name(const label id) const
Return the name corresponding to id.
OBJstream os(runTime.globalPath()/outputName)
List< word > wordList
List of word.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
const T & lookup(const Key &key, const T &deflt) const
Return hashed entry if it exists, or return the given default.
label nCells() const noexcept
Number of mesh cells.
bool match(const std::string &text, bool literal=false) const
Smart match as literal or regex, stopping on the first match.
Automatically write from objectRegistry::writeObject()
void combine(const dictionary &mapDict, labelList &tableIds)
Combine tableIds together.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
wordList names() const
A list of the zone names.
messageStream Info
Information stream (stdout output on master, null elsewhere)
void addCellZones(polyMesh &, const labelList &tableIds) const
Classify tableIds into cellZones according to the cellTable.
Mesh consisting of general polyhedral cells.
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.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
List< label > labelList
A List of labels.
Registry of regIOobjects.
label findIndex(const word &name) const
Return index corresponding to name.
void operator=(const this_type &rhs)
Copy assignment.
Map< word > selectType(const word &materialType) const
Return a Map of (id => name) for materialType.
cellTable()
Construct null.
Do not request registration (bool: false)
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with the type cellZone.
forAllConstIters(mixture.phases(), phase)
A HashTable to objects of type <T> with a label key.