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 cellTable_H
63 #define cellTable_H
64 
65 #include "polyMesh.H"
66 #include "Map.H"
67 #include "dictionary.H"
68 #include "labelList.H"
69 #include "wordList.H"
70 #include "wordRes.H"
71 
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 
74 namespace Foam
75 {
76 
77 /*---------------------------------------------------------------------------*\
78  Class cellTable Declaration
79 \*---------------------------------------------------------------------------*/
80 
81 class cellTable
82 :
83  public Map<dictionary>
84 {
85  // Private data
86 
87  static const char* const defaultMaterial_;
88 
89 
90  // Private Member Functions
91 
92  //- Map from cellTable ID => zone number
93  Map<label> zoneMap() const;
94 
95  //- A contiguous list of cellTable names
96  wordList namesList() const;
97 
98  //- Add required entries - MaterialType
99  void addDefaults();
100 
101  void setEntry(const label id, const word& keyWord, const word& value);
102 
103  //- No copy construct
104  cellTable(const cellTable&) = delete;
105 
106 
107 public:
108 
109  // Constructors
110 
111  //- Construct null
112  cellTable();
113 
114  //- Construct read from registry, name. instance
115  cellTable
116  (
117  const objectRegistry&,
118  const word& name = "cellTable",
119  const fileName& instance = "constant"
120  );
121 
122 
123  //- Destructor
124  ~cellTable() = default;
125 
126 
127  // Member Functions
128 
129  //- Append to the end, return index
130  label append(const dictionary&);
131 
132  //- Return index corresponding to name
133  // returns -1 if not found
134  label findIndex(const word& name) const;
135 
136  //- Return the name corresponding to id
137  // returns cellTable_ID if not otherwise defined
138  word name(const label id) const;
139 
140  //- Return a Map of (id => name)
141  Map<word> names() const;
142 
143  //- Return a Map of (id => names) selected by patterns
144  Map<word> names(const wordRes& patterns) const;
145 
146  //- Return a Map of (id => name) for materialType
147  // (fluid | solid | shell)
148  Map<word> selectType(const word& materialType) const;
149 
150  //- Return a Map of (id => name) for fluids
151  Map<word> fluids() const;
152 
153  //- Return a Map of (id => name) for shells
154  Map<word> shells() const;
155 
156  //- Return a Map of (id => name) for solids
157  Map<word> solids() const;
158 
159  //- Return a Map of (id => fluid|solid|shell)
160  Map<word> materialTypes() const;
161 
162  //- Assign material Type
163  void setMaterial(const label, const word&);
164 
165  //- Assign name
166  void setName(const label, const word&);
167 
168  //- Assign default name if not already set
169  void setName(const label);
170 
171  //- Read constant/cellTable
172  void readDict
173  (
174  const objectRegistry&,
175  const word& name = "cellTable",
176  const fileName& instance = "constant"
177  );
178 
179  //- Write constant/cellTable for later reuse
180  void writeDict
181  (
182  const objectRegistry&,
183  const word& name = "cellTable",
184  const fileName& instance = "constant"
185  ) const;
186 
187 
188  // Member Operators
189 
190  //- Assignment
191  void operator=(const cellTable&);
192 
193  //- Assign from Map<dictionary>
194  void operator=(const Map<dictionary>&);
195 
196  //- Assign from cellZones
197  void operator=(const polyMesh&);
198 
199 
200  // Friend Functions
201 
202  //- Classify tableIds into cellZones according to the cellTable
203  void addCellZones(polyMesh&, const labelList& tableIds) const;
204 
205  //- Combine tableIds together
206  // each dictionary entry is a wordList
207  void combine(const dictionary& mapDict, labelList& tableIds);
208 };
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 } // End namespace Foam
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #endif
217 
218 // ************************************************************************* //
Foam::cellTable::setName
void setName(const label, const word &)
Assign name.
Definition: cellTable.C:294
wordRes.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::cellTable::selectType
Map< word > selectType(const word &materialType) const
Return a Map of (id => name) for materialType.
Definition: cellTable.C:238
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::cellTable::writeDict
void writeDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant") const
Write constant/cellTable for later reuse.
Definition: cellTable.C:347
Foam::cellTable::readDict
void readDict(const objectRegistry &, const word &name="cellTable", const fileName &instance="constant")
Read constant/cellTable.
Definition: cellTable.C:312
Foam::cellTable::operator=
void operator=(const cellTable &)
Assignment.
Definition: cellTable.C:380
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
Foam::cellTable::~cellTable
~cellTable()=default
Destructor.
Foam::cellTable::names
Map< word > names() const
Return a Map of (id => name)
Definition: cellTable.C:142
Foam::cellTable::materialTypes
Map< word > materialTypes() const
Return a Map of (id => fluid|solid|shell)
Definition: cellTable.C:221
Foam::cellTable::append
label append(const dictionary &)
Append to the end, return index.
Definition: cellTable.C:126
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
wordList.H
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Map.H
Foam::cellTable::fluids
Map< word > fluids() const
Return a Map of (id => name) for fluids.
Definition: cellTable.C:269
labelList.H
Foam::cellTable::name
word name(const label id) const
Return the name corresponding to id.
Definition: cellTable.C:188
Foam::cellTable
The cellTable persistent data saved as a Map<dictionary>.
Definition: cellTable.H:80
Foam::cellTable::solids
Map< word > solids() const
Return a Map of (id => name) for solids.
Definition: cellTable.C:275
Foam::cellTable::combine
void combine(const dictionary &mapDict, labelList &tableIds)
Combine tableIds together.
Definition: cellTable.C:506
Foam::cellTable::setMaterial
void setMaterial(const label, const word &)
Assign material Type.
Definition: cellTable.C:288
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cellTable::findIndex
label findIndex(const word &name) const
Return index corresponding to name.
Definition: cellTable.C:202
Foam::List< word >
dictionary.H
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::cellTable::cellTable
cellTable()
Construct null.
Definition: cellTable.C:105
Foam::cellTable::shells
Map< word > shells() const
Return a Map of (id => name) for shells.
Definition: cellTable.C:281
Foam::cellTable::addCellZones
void addCellZones(polyMesh &, const labelList &tableIds) const
Classify tableIds into cellZones according to the cellTable.
Definition: cellTable.C:440