Loading...
Searching...
No Matches
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-2025 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 Foam_cellModel_H
50#define Foam_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;
68
69template<>
71
73/*---------------------------------------------------------------------------*\
74 Class cellModel Declaration
75\*---------------------------------------------------------------------------*/
76
77class cellModel
78{
79public:
80
81 //- Enumeration of commonly used cellModel types.
82 // The indices must match those in "etc/cellModels"
84 {
85 UNKNOWN = 0,
86 HEX = 3,
87 WEDGE = 4,
88 PRISM = 5,
89 PYR = 6,
90 TET = 7,
91 SPLITHEX = 8,
92 TETWEDGE = 9,
93 };
94
95 //- Names of commonly used cellModels corresponding to modelType.
96 // The names must match those in "etc/cellModels"
97 static const Enum<modelType> modelNames;
99
100 // Lookup Methods
101
102 //- Look up pointer to cellModel by enumeration, or nullptr on failure.
103 static const cellModel* ptr(const modelType model);
104
105 //- Look up pointer to cellModel by name, or nullptr on failure.
106 static const cellModel* ptr(const word& modelName);
107
108 //- Look up pointer to cellModel by index, or nullptr on failure
109 static const cellModel* ptr(const label modelIndex);
110
111
112 //- Look up reference to cellModel by enumeration. Fatal on failure
113 static const cellModel& ref(const modelType model);
114
115 //- Look up reference to cellModel by name. Fatal on failure
116 static const cellModel& ref(const word& modelName);
117
118 //- Look up reference to cellModel by index. Fatal on failure
119 static const cellModel& ref(const label modelIndex);
120
121
122private:
123
124 // Private Static Data
125
126 //- PtrList of predefined models
127 static PtrList<cellModel> models_;
128
129 //- Lookup of model pointers (in models_) by index
130 static List<const cellModel*> modelPtrs_;
131
132
133 // Private Data
134
135 //- (Unique) model name
136 word name_;
137
138 //- Index in the model list
139 label index_;
140
141 //- Number of points in the model which determines the geometry
142 label nPoints_;
143
144 //- Faces of the model
145 faceList faces_;
146
147 //- Edges of the model
148 edgeList edges_;
149
150
151 // Private Member Functions
152
153 //- Construct from central "etc/cellModels" file.
154 static void constructModels();
155
156
157public:
158
159 // Constructors
160
161 //- Construct from Istream
162 explicit cellModel(Istream& is);
163
164 //- Return a new cellModel created from Istream
165 static autoPtr<cellModel> New(Istream& is)
166 {
167 return autoPtr<cellModel>::New(is);
168 }
169
170 //- Return clone
172 {
173 return autoPtr<cellModel>::New(*this);
174 }
175
176
177 // Member Functions
178
179 //- Return model name
180 inline const word& name() const noexcept;
181
182 //- Return index of model in the model list
183 inline label index() const noexcept;
184
185 //- Return number of points
186 inline label nPoints() const noexcept;
187
188 //- Return number of edges
189 inline label nEdges() const noexcept;
190
191 //- Return number of faces
192 inline label nFaces() const noexcept;
193
194 //- Return a raw list of model edges
195 inline const edgeList& modelEdges() const noexcept;
196
197 //- Return a raw list of model faces
198 inline const faceList& modelFaces() const noexcept;
199
200 //- Return list of cell edges
201 inline edgeList edges(const labelUList& pointLabels) const;
202
203 //- Return list of cell faces
204 inline faceList faces(const labelUList& pointLabels) const;
205
206 //- Return the cell edge for specified model edge
207 inline Foam::edge edge
208 (
209 const label modelEdgei,
211 ) const;
212
213 //- Return the cell face for specified model face
214 inline Foam::face face
215 (
216 const label modelFacei,
218 ) const;
219
220
221 //- Centroid of the cell
223 (
224 const labelUList& pointLabels,
225 const UList<point>& points
226 ) const;
227
228 //- Cell volume
229 scalar mag
230 (
231 const labelUList& pointLabels,
232 const UList<point>& points
233 ) const;
234
235
236 //- Return info proxy,
237 //- used to print information to a stream
238 InfoProxy<cellModel> info() const noexcept { return *this; }
239
240 //- The writeData member function required by regIOobject
241 bool writeData(Ostream& os) const
242 {
243 os << *this;
244 return os.good();
245 }
246
247
248 // Ostream Operator
249
250 friend Ostream& operator<<(Ostream& os, const cellModel& cm);
251};
252
253
254// Global Operators
255
256//- Equality: true when model pointers are identical
257inline bool operator==(const cellModel& lhs, const cellModel& rhs) noexcept;
258
259//- Inequality: true when model pointers are not identical
260inline bool operator!=(const cellModel& lhs, const cellModel& rhs) noexcept;
261
262
263// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264
265} // End namespace Foam
266
267// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268
269#include "cellModelI.H"
270
271// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272
273#endif
274
275// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
A helper class for outputting values to Ostream.
Definition InfoProxy.H:49
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
Maps a geometry to a set of cell primitives.
Definition cellModel.H:73
vector centre(const labelUList &pointLabels, const UList< point > &points) const
Centroid of the cell.
Definition cellModel.C:58
const word & name() const noexcept
Return model name.
Definition cellModelI.H:24
friend Ostream & operator<<(Ostream &os, const cellModel &cm)
cellModel(Istream &is)
Construct from Istream.
Definition cellModelIO.C:27
scalar mag(const labelUList &pointLabels, const UList< point > &points) const
Cell volume.
Definition cellModel.C:98
edgeList edges(const labelUList &pointLabels) const
Return list of cell edges.
Definition cellModelI.H:67
autoPtr< cellModel > clone() const
Return clone.
Definition cellModel.H:206
label nEdges() const noexcept
Return number of edges.
Definition cellModelI.H:42
static autoPtr< cellModel > New(Istream &is)
Return a new cellModel created from Istream.
Definition cellModel.H:198
const faceList & modelFaces() const noexcept
Return a raw list of model faces.
Definition cellModelI.H:60
bool writeData(Ostream &os) const
The writeData member function required by regIOobject.
Definition cellModel.H:306
InfoProxy< cellModel > info() const noexcept
Return info proxy, used to print information to a stream.
Definition cellModel.H:301
modelType
Enumeration of commonly used cellModel types.
Definition cellModel.H:82
@ TETWEDGE
tetWedge
Definition cellModel.H:90
@ UNKNOWN
unknown
Definition cellModel.H:83
@ SPLITHEX
splitHex
Definition cellModel.H:89
label index() const noexcept
Return index of model in the model list.
Definition cellModelI.H:30
Foam::edge edge(const label modelEdgei, const labelUList &pointLabels) const
Return the cell edge for specified model edge.
Definition cellModelI.H:84
label nFaces() const noexcept
Return number of faces.
Definition cellModelI.H:48
Foam::face face(const label modelFacei, const labelUList &pointLabels) const
Return the cell face for specified model face.
Definition cellModelI.H:112
static const cellModel * ptr(const modelType model)
Look up pointer to cellModel by enumeration, or nullptr on failure.
Definition cellModels.C:113
faceList faces(const labelUList &pointLabels) const
Return list of cell faces.
Definition cellModelI.H:95
static const Enum< modelType > modelNames
Names of commonly used cellModels corresponding to modelType.
Definition cellModel.H:98
const edgeList & modelEdges() const noexcept
Return a raw list of model edges.
Definition cellModelI.H:54
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Definition edge.H:62
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
A class for handling words, derived from Foam::string.
Definition word.H:66
rDeltaT ref()
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
label nPoints
Namespace for OpenFOAM.
List< edge > edgeList
List of edge.
Definition edgeList.H:32
bool operator!=(const eddy &a, const eddy &b)
Definition eddy.H:297
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
vector point
Point is a vector.
Definition point.H:37
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
const direction noexcept
Definition scalarImpl.H:265
Vector< scalar > vector
Definition vector.H:57
UList< label > labelUList
A UList of labels.
Definition UList.H:75
labelList pointLabels(nPoints, -1)