cellModel.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 Copyright (C) 2017-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::cellModel
29
30Description
31 Maps a geometry to a set of cell primitives.
32
33 This enables geometric cell data to be calculated without access
34 to the primitive geometric level. This means mapping a 3D
35 geometry to a set of pyramids which are each described by a cell
36 face and the cell centre point.
37
38 Also includes a static collection of cell models (normally loaded from
39 etc/cellModels), and a means of looking them up.
40
41SourceFiles
42 cellModelI.H
43 cellModel.C
44 cellModels.C
45 cellModelIO.C
46
47\*---------------------------------------------------------------------------*/
48
49#ifndef cellModel_H
50#define cellModel_H
51
52#include "pointField.H"
53#include "edgeList.H"
54#include "faceList.H"
55#include "InfoProxy.H"
56#include "autoPtr.H"
57#include "PtrList.H"
58#include "Enum.H"
59
60// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61
62namespace Foam
63{
64
65// Forward Declarations
66class cellModel;
67Ostream& operator<<(Ostream& os, const cellModel& cm);
68
69/*---------------------------------------------------------------------------*\
70 Class cellModel Declaration
71\*---------------------------------------------------------------------------*/
73class cellModel
74{
75public:
76
77 //- Enumeration of commonly used cellModel types.
78 // The indices must match those in "etc/cellModels"
79 enum modelType
80 {
81 UNKNOWN = 0,
82 HEX = 3,
83 WEDGE = 4,
84 PRISM = 5,
85 PYR = 6,
86 TET = 7,
88 TETWEDGE = 9,
89 };
90
91 //- Names of commonly used cellModels corresponding to modelType.
92 // The names must match those in "etc/cellModels"
93 static const Enum<modelType> modelNames;
94
95
96 // Lookup Methods
97
98 //- Look up pointer to cellModel by enumeration, or nullptr on failure.
99 static const cellModel* ptr(const modelType model);
100
101 //- Look up pointer to cellModel by name, or nullptr on failure.
102 static const cellModel* ptr(const word& modelName);
103
104 //- Look up pointer to cellModel by index, or nullptr on failure
105 static const cellModel* ptr(const label modelIndex);
106
107
108 //- Look up reference to cellModel by enumeration. Fatal on failure
109 static const cellModel& ref(const modelType model);
110
111 //- Look up reference to cellModel by name. Fatal on failure
112 static const cellModel& ref(const word& modelName);
113
114 //- Look up reference to cellModel by index. Fatal on failure
115 static const cellModel& ref(const label modelIndex);
116
117
118private:
119
120 // Private Static Data
121
122 //- PtrList of predefined models
123 static PtrList<cellModel> models_;
124
125 //- Lookup of model pointers (in models_) by index
126 static List<const cellModel*> modelPtrs_;
127
128
129 // Private Data
130
131 //- (Unique) model name
132 word name_;
133
134 //- Index in the model list
135 label index_;
136
137 //- Number of points in the model which determines the geometry
138 label nPoints_;
139
140 //- Faces of the model
141 faceList faces_;
142
143 //- Edges of the model
144 edgeList edges_;
145
146
147 // Private Member Functions
148
149 //- Construct from central "etc/cellModels" file.
150 static void constructModels();
151
152
153public:
154
155 // Constructors
156
157 //- Construct from Istream
158 explicit cellModel(Istream& is);
159
160 //- Return a new cellModel created from Istream
161 static autoPtr<cellModel> New(Istream& is)
162 {
163 return autoPtr<cellModel>::New(is);
164 }
165
166 //- Return clone
168 {
169 return autoPtr<cellModel>::New(*this);
170 }
171
172
173 // Member Functions
174
175 //- Return model name
176 inline const word& name() const noexcept;
177
178 //- Return index of model in the model list
179 inline label index() const noexcept;
180
181 //- Return number of points
182 inline label nPoints() const noexcept;
183
184 //- Return number of edges
185 inline label nEdges() const noexcept;
186
187 //- Return number of faces
188 inline label nFaces() const noexcept;
189
190 //- Return a raw list of model edges
191 inline const edgeList& modelEdges() const noexcept;
192
193 //- Return a raw list of model faces
194 inline const faceList& modelFaces() const noexcept;
195
196 //- Return list of cell edges
197 inline edgeList edges(const labelUList& pointLabels) const;
198
199 //- Return list of cell faces
200 inline faceList faces(const labelUList& pointLabels) const;
201
202 //- Return the cell edge for specified model edge
203 inline Foam::edge edge
204 (
205 const label modelEdgei,
207 ) const;
208
209 //- Return the cell face for specified model face
210 inline Foam::face face
211 (
212 const label modelFacei,
214 ) const;
215
216
217 //- Centroid of the cell
219 (
220 const labelList& pointLabels,
221 const UList<point>& points
222 ) const;
223
224 //- Cell volume
225 scalar mag
226 (
227 const labelList& pointLabels,
228 const UList<point>& points
229 ) const;
230
231 //- Return info proxy.
232 // Used to print information to a stream
233 InfoProxy<cellModel> info() const
234 {
235 return *this;
236 }
237
238 //- The writeData member function required by regIOobject
239 bool writeData(Ostream& os) const
240 {
241 os << *this;
242 return os.good();
243 }
244
245
246 // Ostream Operator
248 friend Ostream& operator<<(Ostream& os, const cellModel& cm);
249};
250
251
252// Ostream Operators
253
254template<>
256
257
258// Global Operators
259
260//- Equality: true when model pointers are identical
261inline bool operator==(const cellModel& lhs, const cellModel& rhs) noexcept;
262
263//- Inequality: true when model pointers are not identical
264inline bool operator!=(const cellModel& lhs, const cellModel& rhs) noexcept;
265
266
267// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268
269} // End namespace Foam
270
271// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272
273#include "cellModelI.H"
274
275// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276
277#endif
278
279// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:233
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:52
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Maps a geometry to a set of cell primitives.
Definition: cellModel.H:73
const word & name() const noexcept
Return model name.
Definition: cellModelI.H:31
friend Ostream & operator<<(Ostream &os, const cellModel &cm)
edgeList edges(const labelUList &pointLabels) const
Return list of cell edges.
Definition: cellModelI.H:74
autoPtr< cellModel > clone() const
Return clone.
Definition: cellModel.H:166
label nEdges() const noexcept
Return number of edges.
Definition: cellModelI.H:49
InfoProxy< cellModel > info() const
Return info proxy.
Definition: cellModel.H:232
vector centre(const labelList &pointLabels, const UList< point > &points) const
Centroid of the cell.
Definition: cellModel.C:35
static autoPtr< cellModel > New(Istream &is)
Return a new cellModel created from Istream.
Definition: cellModel.H:160
const faceList & modelFaces() const noexcept
Return a raw list of model faces.
Definition: cellModelI.H:67
bool writeData(Ostream &os) const
The writeData member function required by regIOobject.
Definition: cellModel.H:238
modelType
Enumeration of commonly used cellModel types.
Definition: cellModel.H:79
@ TETWEDGE
tetWedge
Definition: cellModel.H:87
@ WEDGE
wedge
Definition: cellModel.H:82
@ PRISM
prism
Definition: cellModel.H:83
@ UNKNOWN
unknown
Definition: cellModel.H:80
@ SPLITHEX
splitHex
Definition: cellModel.H:86
label index() const noexcept
Return index of model in the model list.
Definition: cellModelI.H:37
label nPoints() const noexcept
Return number of points.
Definition: cellModelI.H:43
label nFaces() const noexcept
Return number of faces.
Definition: cellModelI.H:55
scalar mag(const labelList &pointLabels, const UList< point > &points) const
Cell volume.
Definition: cellModel.C:78
static const cellModel * ptr(const modelType model)
Look up pointer to cellModel by enumeration, or nullptr on failure.
Definition: cellModels.C:120
faceList faces(const labelUList &pointLabels) const
Return list of cell faces.
Definition: cellModelI.H:102
static const Enum< modelType > modelNames
Names of commonly used cellModels corresponding to modelType.
Definition: cellModel.H:92
const edgeList & modelEdges() const noexcept
Return a raw list of model edges.
Definition: cellModelI.H:61
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
A class for handling words, derived from Foam::string.
Definition: word.H:68
rDeltaT ref()
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for OpenFOAM.
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:239
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
const direction noexcept
Definition: Scalar.H:223
labelList pointLabels(nPoints, -1)