cellTable.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::cellTable
28 
29 Description
30  The cellTable persistent data saved as a Map<dictionary>.
31 
32  The meshReader supports cellTable information.
33 
34  The <tt>constant/cellTable</tt> file is an \c IOMap<dictionary> that is
35  used to save the information persistently. It contains the cellTable
36  information of the following form:
37 
38  \verbatim
39  (
40  ID
41  {
42  Label WORD;
43  MaterialType WORD;
44  MaterialId INT;
45  PorosityId INT;
46  ColorIdx INT;
47  ...
48  }
49  ...
50  )
51  \endverbatim
52 
53  If the \a Label is missing, a value <tt>cellTable_{ID}</tt> will be
54  inferred. If the \a MaterialType is missing, the value \a fluid will
55  be inferred.
56 
57 SourceFiles
58  cellTable.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef Foam_cellTable_H
63 #define Foam_cellTable_H
64 
65 #include "Map.H"
66 #include "dictionary.H"
67 #include "wordRes.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 
74 // Forward Declarations
75 class polyMesh;
76 class objectRegistry;
77 
78 /*---------------------------------------------------------------------------*\
79  Class cellTable Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 class cellTable
83 :
84  public Map<dictionary>
85 {
86  // Private Member Functions
87 
88  //- Add required entries - MaterialType
89  void addDefaults();
90 
91  void setEntry(const label id, const word& key, const word& value);
92 
93 
94 public:
95 
96  //- No copy construct
97  cellTable(const cellTable&) = delete;
98 
99 
100  // Constructors
101 
102  //- Default construct
103  cellTable() noexcept = default;
104 
105  //- Read construct from registry, name, instance
106  explicit cellTable
107  (
108  const objectRegistry& obr,
109  const word& name = "cellTable",
110  const fileName& instance = "constant"
111  );
112 
113 
114  //- Destructor
115  ~cellTable() = default;
116 
117 
118  // Member Functions
119 
120  //- Add to the end, return index
121  label push_back(const dictionary& dict);
122 
123  //- The max table index, -1 if empty
124  label maxIndex() const;
125 
126  //- The index corresponding to entry with 'Label' of given name,
127  //- or -1 if not found
128  label findIndex(const word& name) const;
129 
130  //- The 'Label' name corresponding to id,
131  //- or cellTable_ID if not otherwise defined
132  word name(const label id) const;
133 
134  //- Return the extracted Map of (id => name)
135  Map<word> names() const;
136 
137  //- Return the extracted Map of (id => names) selected by patterns
138  Map<word> names(const wordRes& patterns) const;
139 
140  //- Return the extracted Map of (id => name) for materialType
141  //- (fluid | solid | shell)
142  Map<word> selectType(const word& materialType) const;
143 
144  //- Return a Map of (id => name) for fluids
145  Map<word> fluids() const;
146 
147  //- Return a Map of (id => name) for shells
148  Map<word> shells() const;
149 
150  //- Return a Map of (id => name) for solids
151  Map<word> solids() const;
152 
153  //- Return a Map of (id => fluid|solid|shell)
154  Map<word> materialTypes() const;
155 
156  //- Assign material Type
157  void setMaterial(const label, const word&);
158 
159  //- Assign name
160  void setName(const label, const word&);
161 
162  //- Assign default name if not already set
163  void setName(const label);
164 
165  //- Read constant/cellTable
166  void readDict
167  (
168  const objectRegistry&,
169  const word& name = "cellTable",
170  const fileName& instance = "constant"
171  );
172 
173  //- Write constant/cellTable for later reuse
174  void writeDict
175  (
176  const objectRegistry&,
177  const word& name = "cellTable",
178  const fileName& instance = "constant"
179  ) const;
180 
181 
182  // Member Operators
183 
184  //- Assignment
185  void operator=(const cellTable&);
186 
187  //- Assign from Map<dictionary>
188  void operator=(const Map<dictionary>&);
189 
190  //- Assign from cellZones
191  void operator=(const polyMesh&);
192 
193 
194  // Friend Functions
195 
196  //- Classify tableIds into cellZones according to the cellTable
197  void addCellZones(polyMesh&, const labelList& tableIds) const;
198 
199  //- Combine tableIds together
200  // each dictionary entry is a wordList
201  void combine(const dictionary& mapDict, labelList& tableIds);
202 
203 
204  // Housekeeping
205 
206  //- Add to the end, return index
207  label append(const dictionary& dict) { return push_back(dict); }
208 };
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 } // End namespace Foam
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 #endif
218 
219 // ************************************************************************* //
dictionary dict
~cellTable()=default
Destructor.
A class for handling file names.
Definition: fileName.H:72
Map< word > shells() const
Return a Map of (id => name) for shells.
Definition: cellTable.C:258
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void setName(const label, const word &)
Assign name.
Definition: cellTable.C:270
Map< word > solids() const
Return a Map of (id => name) for solids.
Definition: cellTable.C:252
label append(const dictionary &dict)
Add to the end, return index.
Definition: cellTable.H:257
void setMaterial(const label, const word &)
Assign material Type.
Definition: cellTable.C:264
void operator=(const cellTable &)
Assignment.
Definition: cellTable.C:359
void writeDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant") const
Write constant/cellTable for later reuse.
Definition: cellTable.C:323
void readDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant")
Read constant/cellTable.
Definition: cellTable.C:288
A class for handling words, derived from Foam::string.
Definition: word.H:63
Map< word > names() const
Return the extracted Map of (id => name)
Definition: cellTable.C:144
Map< word > materialTypes() const
Return a Map of (id => fluid|solid|shell)
Definition: cellTable.C:197
label maxIndex() const
The max table index, -1 if empty.
Definition: cellTable.C:120
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
Map< word > fluids() const
Return a Map of (id => name) for fluids.
Definition: cellTable.C:246
The cellTable persistent data saved as a Map<dictionary>.
Definition: cellTable.H:77
label push_back(const dictionary &dict)
Add to the end, return index.
Definition: cellTable.C:135
const direction noexcept
Definition: Scalar.H:258
word name(const label id) const
The &#39;Label&#39; name corresponding to id, or cellTable_ID if not otherwise defined.
Definition: cellTable.C:156
cellTable() noexcept=default
Default construct.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
void combine(const dictionary &mapDict, labelList &tableIds)
Combine tableIds together.
Definition: cellTable.C:507
void addCellZones(polyMesh &, const labelList &tableIds) const
Classify tableIds into cellZones according to the cellTable.
Definition: cellTable.C:419
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
Registry of regIOobjects.
label findIndex(const word &name) const
The index corresponding to entry with &#39;Label&#39; of given name, or -1 if not found.
Definition: cellTable.C:175
Map< word > selectType(const word &materialType) const
Return the extracted Map of (id => name) for materialType (fluid | solid | shell) ...
Definition: cellTable.C:217
Namespace for OpenFOAM.
A HashTable to objects of type <T> with a label key.