FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/polyMesh.H>
64 #include <OpenFOAM/Map.H>
65 #include <OpenFOAM/dictionary.H>
66 #include <OpenFOAM/labelList.H>
67 #include <OpenFOAM/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 List<wordRe>& patterns) const;
142 
143  //- Return a Map of (id => name) for materialType (fluid | solid | shell)
144  Map<word> selectType(const word& materialType) const;
145 
146  //- Return a Map of (id => name) for fluids
147  Map<word> fluids() const;
148 
149  //- Return a Map of (id => name) for shells
150  Map<word> shells() const;
151 
152  //- Return a Map of (id => name) for solids
153  Map<word> solids() const;
154 
155  //- Return a Map of (id => fluid|solid|shell)
156  Map<word> materialTypes() const;
157 
158  //- Assign material Type
159  void setMaterial(const label&, const word&);
160 
161  //- Assign name
162  void setName(const label&, const word&);
163 
164  //- Assign default name if not already set
165  void setName(const label&);
166 
167  //- Read constant/cellTable
168  void readDict
169  (
170  const objectRegistry&,
171  const word& name = "cellTable",
172  const fileName& instance = "constant"
173  );
174 
175  //- write constant/cellTable for later reuse
176  void writeDict
177  (
178  const objectRegistry&,
179  const word& name = "cellTable",
180  const fileName& instance = "constant"
181  ) const;
182 
183 
184  // Member Operators
185 
186  //- Assignment
187  void operator=(const cellTable&);
188 
189  //- Assign from Map<dictionary>
190  void operator=(const Map<dictionary>&);
191 
192  //- Assign from cellZones
193  void operator=(const polyMesh&);
194 
195 
196  // Friend Functions
197 
198  //- Classify tableIds into cellZones according to the cellTable
199  void addCellZones(polyMesh&, const labelList& tableIds) const;
200 
201  //- Combine tableIds together
202  // each dictionary entry is a wordList
203  void combine(const dictionary&, labelList& tableIds);
204 };
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #endif
213 
214 // ************************ vim: set sw=4 sts=4 et: ************************ //