Loading...
Searching...
No Matches
cellTable Class Reference

The cellTable persistent data saved as a Map<dictionary>. More...

#include <cellTable.H>

Inheritance diagram for cellTable:
Collaboration diagram for cellTable:

Public Member Functions

 cellTable (const cellTable &)=delete
 No copy construct.
 cellTable () noexcept=default
 Default construct.
 cellTable (const objectRegistry &obr, const word &name="cellTable", const fileName &instance="constant")
 Read construct from registry, name, instance.
 ~cellTable ()=default
 Destructor.
label push_back (const dictionary &dict)
 Add to the end, return index.
label maxIndex () const
 The max table index, -1 if empty.
label findIndex (const word &name) const
 The index corresponding to entry with 'Label' of given name, or -1 if not found.
word name (const label id) const
 The 'Label' name corresponding to id, or cellTable_ID if not otherwise defined.
Map< wordnames () const
 Return the extracted Map of (id => name).
Map< wordnames (const wordRes &patterns) const
 Return the extracted Map of (id => names) selected by patterns.
Map< wordselectType (const word &materialType) const
 Return the extracted Map of (id => name) for materialType (fluid | solid | shell).
Map< wordfluids () const
 Return a Map of (id => name) for fluids.
Map< wordshells () const
 Return a Map of (id => name) for shells.
Map< wordsolids () const
 Return a Map of (id => name) for solids.
Map< wordmaterialTypes () const
 Return a Map of (id => fluid|solid|shell).
void setMaterial (const label, const word &)
 Assign material Type.
void setName (const label, const word &)
 Assign name.
void setName (const label)
 Assign default name if not already set.
void readDict (const objectRegistry &, const word &name="cellTable", const fileName &instance="constant")
 Read constant/cellTable.
void writeDict (const objectRegistry &, const word &name="cellTable", const fileName &instance="constant") const
 Write constant/cellTable for later reuse.
void operator= (const cellTable &)
 Assignment.
void operator= (const Map< dictionary > &)
 Assign from Map<dictionary>.
void operator= (const polyMesh &)
 Assign from cellZones.
void addCellZones (polyMesh &, const labelList &tableIds) const
 Classify tableIds into cellZones according to the cellTable.
void combine (const dictionary &mapDict, labelList &tableIds)
 Combine tableIds together.
label append (const dictionary &dict)
 Add to the end, return index.
Public Member Functions inherited from Map< dictionary >
void operator= (const this_type &rhs)
 Copy assign.
void operator= (std::initializer_list< std::pair< label, dictionary > > rhs)
 Copy assign from an initializer list.
void operator= (this_type &&rhs)
 Move assign.
constexpr Map () noexcept=default
 Default construct: empty without allocation (capacity=0).
Public Member Functions inherited from HashTable< dictionary, label, Hash< label > >
Foam::List< label > sortedToc (const Compare &comp) const
Foam::List< label > tocKeys (const UnaryPredicate &pred, const bool invert) const
Foam::List< label > tocValues (const UnaryPredicate &pred, const bool invert) const
Foam::List< label > tocEntries (const BinaryPredicate &pred, const bool invert) const
Foam::label countKeys (const UnaryPredicate &pred, const bool invert) const
Foam::label countValues (const UnaryPredicate &pred, const bool invert) const
Foam::label countEntries (const BinaryPredicate &pred, const bool invert) const
Foam::label erase (InputIter first, InputIter last)
Foam::label erase (const FixedList< label, N > &keys)
Foam::label erase (const HashTable< AnyType, label, AnyHash > &other)
Foam::label retain (const HashTable< AnyType, label, AnyHash > &other)
Foam::label filterKeys (const UnaryPredicate &pred, const bool pruning)
Foam::label filterValues (const UnaryPredicate &pred, const bool pruning)
Foam::label filterEntries (const BinaryPredicate &pred, const bool pruning)
constexpr HashTable () noexcept
 Default construct: empty without allocation (capacity=0).
 ~HashTable ()
 Destructor.
bool empty () const noexcept
 True if the hash table is empty.
label size () const noexcept
 The number of elements in table.
label capacity () const noexcept
 The size of the underlying table (the number of buckets).
dictionaryat (const label &key)
 Find and return a hashed entry. FatalError if it does not exist.
bool contains (const label &key) const
 True if hashed key is contained (found) in table.
iterator find (const label &key)
 Find and return an iterator set at the hashed entry.
const_iterator cfind (const label &key) const
 Find and return an const_iterator set at the hashed entry.
const dictionarylookup (const label &key, const dictionary &deflt) const
 Return hashed entry if it exists, or return the given default.
List< label > toc () const
 The table of contents (the keys) in unsorted order.
UPtrList< const node_typecsorted () const
 Const access to the hash-table contents in sorted order (sorted by keys).
UPtrList< node_typesorted ()
 Non-const access to the hash-table contents in sorted order (sorted by keys).
bool emplace (const label &key, Args &&... args)
 Emplace insert a new entry, not overwriting existing entries.
bool emplace_set (const label &key, Args &&... args)
 Emplace set an entry, overwriting any existing entries.
bool insert (const label &key, const dictionary &obj)
 Copy insert a new entry, not overwriting existing entries.
bool set (const label &key, const dictionary &obj)
 Copy assign a new entry, overwriting existing entries.
void clear ()
 Remove all entries from table.
void clearStorage ()
 Remove all entries from table and the table itself.
void setCapacity (label newCapacity)
 Change the hash table capacity (number of buckets).
void resize (label newCapacity)
 Rehash the hash table with new number of buckets. Currently identical to setCapacity().
void reserve (label numEntries)
 Reserve space for at least the specified number of elements (not the number of buckets) and regenerates the hash table.
void swap (HashTable< dictionary, label, Hash > &rhs) noexcept
 Swap contents into this table.
void transfer (HashTable< dictionary, label, Hash > &rhs)
 Transfer contents into this table.
void merge (HashTable< dictionary, label, Hash > &source)
 Attempts to extract entries from source parameter and insert them into this, does not overwrite existing entries. The source will contains any items that could not be merged.
dictionaryoperator[] (const label &key)
 Find and return a hashed entry. FatalError if it does not exist.
dictionaryoperator() (const label &key)
 Return existing entry or create a new entry.
void operator= (const this_type &rhs)
 Copy assign.
bool operator== (const this_type &rhs) const
 Equality. Tables are equal if all keys and values are equal, independent of order or underlying storage size.
bool operator!= (const this_type &rhs) const
 The opposite of the equality operation.
this_typeoperator+= (const this_type &rhs)
 Add entries into this HashTable.
const_iterator_pair< const_key_iterator, this_typekeys () const
 A const iterator begin/end pair for iterating over keys.
iterator begin ()
 iterator set to the beginning of the HashTable
const_iterator cbegin () const
 const_iterator set to the beginning of the HashTable
iterator end () noexcept
 iterator to signal the end (for any HashTable)
constexpr const_iterator cend () const noexcept
 const_iterator to signal the end (for any HashTable)
OstreamprintInfo (Ostream &os) const
 Print information.
OstreamwriteKeys (Ostream &os, const label shortLen=0) const
 Write unordered keys (list), with line-breaks when length exceeds shortLen.
bool found (const label &key) const
 Same as contains().
Public Member Functions inherited from HashTableCore
 ClassName ("HashTable")
 Declare type-name (with debug switch).
constexpr HashTableCore () noexcept=default
 Default construct.

Additional Inherited Members

Public Types inherited from Map< dictionary >
typedef Map< dictionarythis_type
 The template instance used for this Map.
typedef HashTable< dictionary, label, Hash< label > > parent_type
 The template instance used for the parent HashTable.
using iterator
using const_iterator
Public Types inherited from HashTable< dictionary, label, Hash< label > >
typedef HashTable< dictionary, label, Hashthis_type
 The template instance used for this HashTable.
using node_type
 A table entry (node) that encapsulates the key/val tuple with an additional linked-list entry for hash collisions.
typedef label key_type
 The second template parameter, type of keys used.
typedef dictionary mapped_type
 The first template parameter, type of objects contained.
typedef dictionary value_type
 Same as mapped_type for OpenFOAM HashTables.
typedef Hash hasher
 The third template parameter, the hash index method.
typedef dictionarypointer
 Pointer type for storing into value_type objects.
typedef dictionaryreference
 Reference to the stored value_type.
typedef const dictionaryconst_pointer
 Const pointer type for the stored value_type.
typedef const dictionaryconst_reference
 Const reference to the stored value_type.
typedef label difference_type
 The type to represent the difference between two iterators.
typedef label size_type
 The type that can represent the size of a HashTable.
using key_iterator
 Forward iterator returning the key.
using const_key_iterator
 Forward const iterator returning the key.
Static Public Member Functions inherited from HashTableCore
static label canonicalSize (const label size) noexcept
 Return a canonical (power-of-two) of the requested size.
Static Public Attributes inherited from HashTableCore
static constexpr int32_t maxTableSize = (1 << (32-3))
 Maximum allowable internal table size (must be a power of two!).

Detailed Description

The cellTable persistent data saved as a Map<dictionary>.

The meshReader supports cellTable information.

The constant/cellTable file is an IOMap<dictionary> that is used to save the information persistently. It contains the cellTable information of the following form:

    (
        ID
        {
            Label           WORD;
            MaterialType    WORD;
            MaterialId      INT;
            PorosityId      INT;
            ColorIdx        INT;
            ...
        }
    ...
    )

If the Label is missing, a value cellTable_{ID} will be inferred. If the MaterialType is missing, the value fluid will be inferred.

Source files

Definition at line 77 of file cellTable.H.

Constructor & Destructor Documentation

◆ cellTable() [1/3]

cellTable ( const cellTable & )
delete

No copy construct.

References cellTable().

Referenced by cellTable(), cellTable(), operator=(), and ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cellTable() [2/3]

cellTable ( )
defaultnoexcept

Default construct.

References cellTable(), name(), and Foam::noexcept.

Here is the call graph for this function:

◆ cellTable() [3/3]

cellTable ( const objectRegistry & obr,
const word & name = "cellTable",
const fileName & instance = "constant" )
explicit

Read construct from registry, name, instance.

Definition at line 107 of file cellTable.C.

References name(), and readDict().

Here is the call graph for this function:

◆ ~cellTable()

Member Function Documentation

◆ push_back()

Foam::label push_back ( const dictionary & dict)

Add to the end, return index.

Definition at line 135 of file cellTable.C.

References dict, insert(), and maxIndex().

Referenced by append(), and ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ maxIndex()

Foam::label maxIndex ( ) const

The max table index, -1 if empty.

Definition at line 120 of file cellTable.C.

References forAllConstIters.

Referenced by combine(), push_back(), and ~cellTable().

Here is the caller graph for this function:

◆ findIndex()

Foam::label findIndex ( const word & name) const

The index corresponding to entry with 'Label' of given name, or -1 if not found.

Definition at line 175 of file cellTable.C.

References dict, forAllConstIters, and name().

Referenced by ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ name()

Foam::word name ( const label id) const

The 'Label' name corresponding to id, or cellTable_ID if not otherwise defined.

Definition at line 156 of file cellTable.C.

References HashTable< dictionary, label, Hash< label > >::cfind(), and Foam::name().

Referenced by cellTable(), cellTable(), findIndex(), readDict(), setName(), writeDict(), and ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ names() [1/2]

Foam::Map< Foam::word > names ( ) const

Return the extracted Map of (id => name).

Definition at line 144 of file cellTable.C.

References Foam::names_impl().

Referenced by ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ names() [2/2]

Foam::Map< Foam::word > names ( const wordRes & patterns) const

Return the extracted Map of (id => names) selected by patterns.

Definition at line 150 of file cellTable.C.

References Foam::names_impl().

Here is the call graph for this function:

◆ selectType()

Foam::Map< Foam::word > selectType ( const word & materialType) const

Return the extracted Map of (id => name) for materialType (fluid | solid | shell).

Definition at line 217 of file cellTable.C.

References defaultMaterial_, dict, HashTable< T, Key, Hash >::emplace(), forAllConstIters, Map< dictionary >::Map(), Foam::name(), HashTable< T, Key, Hash >::reserve(), and HashTable< dictionary, label, Hash< label > >::size().

Referenced by fluids(), shells(), solids(), and ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fluids()

Foam::Map< Foam::word > fluids ( ) const

Return a Map of (id => name) for fluids.

Definition at line 246 of file cellTable.C.

References selectType().

Referenced by ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shells()

Foam::Map< Foam::word > shells ( ) const

Return a Map of (id => name) for shells.

Definition at line 258 of file cellTable.C.

References selectType().

Referenced by ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ solids()

Foam::Map< Foam::word > solids ( ) const

Return a Map of (id => name) for solids.

Definition at line 252 of file cellTable.C.

References selectType().

Referenced by ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ materialTypes()

Foam::Map< Foam::word > materialTypes ( ) const

Return a Map of (id => fluid|solid|shell).

Definition at line 197 of file cellTable.C.

References defaultMaterial_, HashTable< T, Key, Hash >::emplace(), forAllConstIters, Map< dictionary >::Map(), readIfPresent(), HashTable< T, Key, Hash >::reserve(), and HashTable< dictionary, label, Hash< label > >::size().

Referenced by ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMaterial()

void setMaterial ( const label id,
const word & matlType )

Assign material Type.

Definition at line 264 of file cellTable.C.

Referenced by ~cellTable().

Here is the caller graph for this function:

◆ setName() [1/2]

void setName ( const label id,
const word & name )

Assign name.

Definition at line 270 of file cellTable.C.

References name().

Referenced by setName(), and ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setName() [2/2]

void setName ( const label id)

Assign default name if not already set.

Definition at line 276 of file cellTable.C.

References HashTable< dictionary, label, Hash< label > >::find(), found, Foam::name(), and setName().

Here is the call graph for this function:

◆ readDict()

void readDict ( const objectRegistry & obr,
const word & name = "cellTable",
const fileName & instance = "constant" )

Read constant/cellTable.

Definition at line 287 of file cellTable.C.

References clear(), Foam::endl(), regIOobject::headerOk(), Foam::Info, name(), IOobjectOption::NO_REGISTER, IOobjectOption::NO_WRITE, and IOobjectOption::READ_IF_PRESENT.

Referenced by cellTable(), and ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeDict()

void writeDict ( const objectRegistry & obr,
const word & name = "cellTable",
const fileName & instance = "constant" ) const

Write constant/cellTable for later reuse.

Definition at line 322 of file cellTable.C.

References Foam::endl(), Foam::Info, name(), IOobject::name(), IOobjectOption::NO_READ, IOobjectOption::NO_REGISTER, IOobjectOption::NO_WRITE, IOobject::note(), IOobject::objectPath(), IOobject::objectRelPath(), os(), IOobject::writeEndDivider(), and IOobject::writeHeader().

Referenced by ~cellTable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/3]

void operator= ( const cellTable & rhs)

Assignment.

Definition at line 359 of file cellTable.C.

References cellTable(), Map< T >::operator=(), and Foam::rhs().

Here is the call graph for this function:

◆ operator=() [2/3]

void operator= ( const Map< dictionary > & rhs)

Assign from Map<dictionary>.

Definition at line 366 of file cellTable.C.

References Map< dictionary >::Map(), Map< T >::operator=(), and Foam::rhs().

Here is the call graph for this function:

◆ operator=() [3/3]

void operator= ( const polyMesh & mesh)

Assign from cellZones.

Definition at line 373 of file cellTable.C.

References HashTable< T, Key, Hash >::clear(), dict, dictionary, forAll, HashTable< T, Key, Hash >::insert(), Map< dictionary >::Map(), mesh, Map< T >::operator=(), and UList< T >::size().

Here is the call graph for this function:

◆ addCellZones()

◆ combine()

◆ append()

label append ( const dictionary & dict)
inline

Add to the end, return index.

Definition at line 257 of file cellTable.H.

References append(), dict, and push_back().

Referenced by append().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: