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