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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::cellShape
29 
30 Description
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 
36 SourceFiles
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 
55 namespace Foam
56 {
57 
58 // Forward Declarations
59 class cell;
60 class cellShape;
61 bool operator==(const cellShape& a, const cellShape& b);
62 Istream& operator>>(Istream& is, cellShape& s);
63 Ostream& operator<<(Ostream& os, const cellShape& s);
64 
65 
66 /*---------------------------------------------------------------------------*\
67  Class cellShape Declaration
68 \*---------------------------------------------------------------------------*/
69 
70 class cellShape
71 :
72  public labelList
73 {
74  // Private Data
75 
76  //- Access to the cellShape's model
77  const cellModel *m;
78 
79 
80 public:
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
207 
208  friend bool operator==(const cellShape& a, const cellShape& b);
209 
210 
211  // IOstream operators
212 
213  friend Istream& operator>>(Istream& is, cellShape& s);
214  friend Ostream& operator<<(Ostream& os, const cellShape& s);
215 };
216 
217 
218 template<>
219 Ostream& operator<<(Ostream& os, const InfoProxy<cellShape>& ip);
220 
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 } // End namespace Foam
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 #include "cellShapeI.H"
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #endif
233 
234 // ************************************************************************* //
Foam::cellShape::collapse
void collapse()
Collapse shape to correct one after removing duplicate vertices.
Definition: cellShape.C:33
Foam::cellShape::operator<<
friend Ostream & operator<<(Ostream &os, const cellShape &s)
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::InfoProxy
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:47
s
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))
Definition: gmvOutputSpray.H:25
cellShapeI.H
Foam::cellShape::centre
point centre(const UList< point > &points) const
Centroid of the cell.
Definition: cellShapeI.H:287
Foam::cellShape::cellShape
constexpr cellShape() noexcept
Default construct. Empty shape, no cell model.
Definition: cellShapeI.H:36
InfoProxy.H
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
Foam::cellShape::meshFaces
labelList meshFaces(const faceList &allFaces, const cell &cFaces) const
Mesh face labels of this cell (in order of model)
Definition: cellShapeI.H:160
Foam::cellShape::face
Foam::face face(const label modelFacei) const
The face for the specified model face.
Definition: cellShapeI.H:221
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::cellShape::faces
faceList faces() const
Faces of this cell.
Definition: cellShapeI.H:227
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::cellShape::meshEdges
labelList meshEdges(const edgeList &allEdges, const labelList &cEdges) const
Mesh edge labels of this cell (in order of model)
Definition: cellShapeI.H:191
Foam::cellShape::points
pointField points(const UList< point > &meshPoints) const
The points corresponding to this shape.
Definition: cellShapeI.H:151
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
labelList.H
Foam::Field< vector >
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::cellShape::edges
edgeList edges() const
Edges of this shape.
Definition: cellShapeI.H:281
cellModel.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::cellShape::edge
Foam::edge edge(const label modelEdgei) const
The edge for the specified model edge.
Definition: cellShapeI.H:275
Foam::cellShape::clone
autoPtr< cellShape > clone() const
Clone.
Definition: cellShapeI.H:118
Foam::cellShape::operator>>
friend Istream & operator>>(Istream &is, cellShape &s)
Foam::cellShape::operator==
friend bool operator==(const cellShape &a, const cellShape &b)
os
OBJstream os(runTime.globalPath()/outputName)
Foam::cellShape
An analytical geometric cellShape.
Definition: cellShape.H:69
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cellShape::mag
scalar mag(const UList< point > &points) const
Scalar magnitude.
Definition: cellShapeI.H:293
Foam::cellShape::reset
void reset(const cellModel &model, const labelUList &labels, const bool doCollapse=false)
Reset from components.
Definition: cellShapeI.H:300
pointField.H
Foam::cellShape::nFaces
label nFaces() const
Number of faces.
Definition: cellShapeI.H:144
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::cellShape::nEdges
label nEdges() const
Number of edges.
Definition: cellShapeI.H:138
Foam::cellShape::info
Foam::InfoProxy< cellShape > info() const
Return info proxy, to print information to a stream.
Definition: cellShape.H:199
Foam::Vector< scalar >
Foam::List< label >
Foam::FixedList
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:104
Foam::UList< label >
Foam::cellShape::collapsedFaces
faceList collapsedFaces() const
Collapsed faces of this cell.
Definition: cellShapeI.H:233
Foam::cellShape::nPoints
label nPoints() const noexcept
Number of points.
Definition: cellShapeI.H:132
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::cellModel
Maps a geometry to a set of cell primitives.
Definition: cellModel.H:72
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:54
Foam::cellShape::model
const cellModel & model() const
Model reference.
Definition: cellShapeI.H:126
autoPtr.H