cellShape.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-2016 OpenFOAM Foundation
9 Copyright (C) 2020-2021 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::cellShape
29
30Description
31 An analytical geometric cellShape.
32
33 The optional collapse functionality changes the cellModel to the
34 correct type after removing any duplicate points.
35
36SourceFiles
37 cellShapeI.H
38 cellShape.C
39 cellShapeIO.C
40 cellShapeEqual.C
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef cellShape_H
45#define cellShape_H
46
47#include "pointField.H"
48#include "labelList.H"
49#include "cellModel.H"
50#include "autoPtr.H"
51#include "InfoProxy.H"
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54
55namespace Foam
56{
57
58// Forward Declarations
59class cell;
60class cellShape;
61bool operator==(const cellShape& a, const cellShape& b);
62Istream& operator>>(Istream& is, cellShape& s);
63Ostream& operator<<(Ostream& os, const cellShape& s);
64
65
66/*---------------------------------------------------------------------------*\
67 Class cellShape Declaration
68\*---------------------------------------------------------------------------*/
70class cellShape
71:
72 public labelList
73{
74 // Private Data
75
76 //- Access to the cellShape's model
77 const cellModel *m;
78
79
80public:
81
82 // Constructors
83
84 //- Default construct. Empty shape, no cell model.
85 inline constexpr cellShape() noexcept;
86
87 //- Copy construct from components
88 inline cellShape
89 (
90 const cellModel& model,
91 const labelUList& labels,
92 const bool doCollapse = false
93 );
94
95 //- Copy construct from components
96 template<unsigned N>
97 inline cellShape
98 (
99 const cellModel& model,
100 const FixedList<label, N>& labels,
101 const bool doCollapse = false
102 );
103
104 //- Move construct from components
105 inline cellShape
106 (
107 const cellModel& model,
108 labelList&& labels,
109 const bool doCollapse = false
110 );
111
112 //- Copy construct from components, lookup cellModel by name
113 inline cellShape
114 (
115 const word& modelName,
116 const labelUList& labels,
117 const bool doCollapse = false
118 );
119
120 //- Construct from Istream
121 inline explicit cellShape(Istream& is);
122
123 //- Clone
124 inline autoPtr<cellShape> clone() const;
125
126
127 // Member Functions
128
129 //- Model reference
130 inline const cellModel& model() const;
131
132 //- Number of points
133 inline label nPoints() const noexcept;
134
135 //- Number of edges
136 inline label nEdges() const;
137
138 //- Number of faces
139 inline label nFaces() const;
140
141 //- The points corresponding to this shape
142 inline pointField points(const UList<point>& meshPoints) const;
143
144 //- Mesh face labels of this cell (in order of model)
145 inline labelList meshFaces
146 (
147 const faceList& allFaces,
148 const cell& cFaces
149 ) const;
150
151 //- Mesh edge labels of this cell (in order of model)
152 inline labelList meshEdges
153 (
154 const edgeList& allEdges,
155 const labelList& cEdges
156 ) const;
157
158 //- The face for the specified model face
159 inline Foam::face face(const label modelFacei) const;
160
161 //- Faces of this cell
162 inline faceList faces() const;
163
164 //- Collapsed faces of this cell
165 inline faceList collapsedFaces() const;
166
167 //- The edge for the specified model edge
168 inline Foam::edge edge(const label modelEdgei) const;
169
170 //- Edges of this shape
171 inline edgeList edges() const;
172
173 //- Centroid of the cell
174 inline point centre(const UList<point>& points) const;
175
176 //- Scalar magnitude
177 inline scalar mag(const UList<point>& points) const;
178
179 //- Reset from components
180 inline void reset
181 (
182 const cellModel& model,
183 const labelUList& labels,
184 const bool doCollapse = false
185 );
186
187 //- Reset from components
188 template<unsigned N>
189 inline void reset
190 (
191 const cellModel& model,
192 const FixedList<label, N>& labels,
193 const bool doCollapse = false
194 );
195
196 //- Collapse shape to correct one after removing duplicate vertices
197 void collapse();
198
199 //- Return info proxy, to print information to a stream
201 {
202 return *this;
203 }
204
205
206 // Friend Operators
208 friend bool operator==(const cellShape& a, const cellShape& b);
209
210
211 // IOstream operators
214 friend Ostream& operator<<(Ostream& os, const cellShape& s);
215};
216
217
218template<>
220
221
222// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223
224} // End namespace Foam
225
226// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227
228#include "cellShapeI.H"
229
230// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231
232#endif
233
234// ************************************************************************* //
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
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
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
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
An analytical geometric cellShape.
Definition: cellShape.H:72
const cellModel & model() const
Model reference.
Definition: cellShapeI.H:126
labelList meshEdges(const edgeList &allEdges, const labelList &cEdges) const
Mesh edge labels of this cell (in order of model)
Definition: cellShapeI.H:191
friend bool operator==(const cellShape &a, const cellShape &b)
scalar mag(const UList< point > &points) const
Scalar magnitude.
Definition: cellShapeI.H:293
void reset(const cellModel &model, const labelUList &labels, const bool doCollapse=false)
Reset from components.
Definition: cellShapeI.H:300
autoPtr< cellShape > clone() const
Clone.
Definition: cellShapeI.H:118
void collapse()
Collapse shape to correct one after removing duplicate vertices.
Definition: cellShape.C:33
Foam::InfoProxy< cellShape > info() const
Return info proxy, to print information to a stream.
Definition: cellShape.H:199
labelList meshFaces(const faceList &allFaces, const cell &cFaces) const
Mesh face labels of this cell (in order of model)
Definition: cellShapeI.H:160
point centre(const UList< point > &points) const
Centroid of the cell.
Definition: cellShapeI.H:287
friend Ostream & operator<<(Ostream &os, const cellShape &s)
label nPoints() const noexcept
Number of points.
Definition: cellShapeI.H:132
faceList faces() const
Faces of this cell.
Definition: cellShapeI.H:227
constexpr cellShape() noexcept
Default construct. Empty shape, no cell model.
Definition: cellShapeI.H:36
edgeList edges() const
Edges of this shape.
Definition: cellShapeI.H:281
faceList collapsedFaces() const
Collapsed faces of this cell.
Definition: cellShapeI.H:233
label nEdges() const
Number of edges.
Definition: cellShapeI.H:138
friend Istream & operator>>(Istream &is, cellShape &s)
label nFaces() const
Number of faces.
Definition: cellShapeI.H:144
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:57
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
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
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 > &)
Istream & operator>>(Istream &, directionInfo &)
volScalarField & b
Definition: createFields.H:27