cellShape.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
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::cellShape
26 
27 Description
28  An analytical geometric cellShape.
29 
30  The optional collapse functionality changes the cellModel to the
31  correct type after removing any duplicate points.
32 
33 SourceFiles
34  cellShapeI.H
35  cellShape.C
36  cellShapeIO.C
37  cellShapeEqual.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef cellShape_H
42 #define cellShape_H
43 
44 #include "pointField.H"
45 #include "labelList.H"
46 #include "cellModel.H"
47 #include "autoPtr.H"
48 #include "InfoProxy.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declaration of classes
56 class cell;
57 
58 // Forward declaration of friend functions and operators
59 
60 class cellShape;
61 bool operator==(const cellShape&, const cellShape&);
62 Istream& operator>>(Istream&, cellShape&);
63 Ostream& operator<<(Ostream&, const cellShape&);
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  //- Construct null
85  inline cellShape();
86 
87  //- Construct from components
88  inline cellShape
89  (
90  const cellModel&,
91  const labelList&,
92  const bool doCollapse = false
93  );
94 
95  //- Construct from components
96  inline cellShape
97  (
98  const word& model,
99  const labelList&,
100  const bool doCollapse = false
101  );
102 
103  //- Construct from Istream
104  inline cellShape(Istream& is);
105 
106  //- Clone
107  inline autoPtr<cellShape> clone() const;
108 
109 
110  // Member Functions
111 
112  //- Return the points corresponding to this cellShape
113  inline pointField points(const pointField& meshPoints) const;
114 
115  //- Model reference
116  inline const cellModel& model() const;
117 
118  //- Mesh face labels of this cell (in order of model)
119  inline labelList meshFaces(const faceList& allFaces, const cell&) const;
120 
121  //- Mesh edge labels of this cell (in order of model)
122  inline labelList meshEdges
123  (
124  const edgeList& allEdges,
125  const labelList&
126  ) const;
127 
128  //- Faces of this cell
129  inline faceList faces() const;
130 
131  //- Collapsed faces of this cell
132  inline faceList collapsedFaces() const;
133 
134  //- Number of faces
135  inline label nFaces() const;
136 
137  //- Edges of this cellShape
138  inline edgeList edges() const;
139 
140  //- Number of edges
141  inline label nEdges() const;
142 
143  //- Number of points
144  inline label nPoints() const;
145 
146  //- Centroid of the cell
147  inline point centre(const pointField&) const;
148 
149  //- Return info proxy.
150  // Used to print token information to a stream
152  {
153  return *this;
154  }
155 
156  //- Scalar magnitude
157  inline scalar mag(const pointField&) const;
158 
159  //- Collapse shape to correct one after removing duplicate vertices
160  void collapse();
161 
162 
163  // Friend Operators
164 
165  friend bool operator==(const cellShape&, const cellShape&);
166 
167 
168  // IOstream Operators
169 
171  friend Ostream& operator<<(Ostream&, const cellShape&);
172 };
173 
174 
175 template<>
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #include "cellShapeI.H"
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #endif
190 
191 // ************************************************************************* //
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:50
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
Definition: cellModel.H:65
An analytical geometric cellShape.
Definition: cellShape.H:72
const cellModel & model() const
Model reference.
Definition: cellShapeI.H:106
friend bool operator==(const cellShape &, const cellShape &)
labelList meshFaces(const faceList &allFaces, const cell &) const
Mesh face labels of this cell (in order of model)
Definition: cellShapeI.H:113
scalar mag(const pointField &) const
Scalar magnitude.
Definition: cellShapeI.H:265
autoPtr< cellShape > clone() const
Clone.
Definition: cellShapeI.H:78
void collapse()
Collapse shape to correct one after removing duplicate vertices.
Definition: cellShape.C:31
point centre(const pointField &) const
Centroid of the cell.
Definition: cellShapeI.H:259
faceList faces() const
Faces of this cell.
Definition: cellShapeI.H:180
friend Istream & operator>>(Istream &, cellShape &)
cellShape()
Construct null.
Definition: cellShapeI.H:32
friend Ostream & operator<<(Ostream &, const cellShape &)
edgeList edges() const
Edges of this cellShape.
Definition: cellShapeI.H:241
pointField points(const pointField &meshPoints) const
Return the points corresponding to this cellShape.
Definition: cellShapeI.H:87
label nPoints() const
Number of points.
Definition: cellShapeI.H:253
labelList meshEdges(const edgeList &allEdges, const labelList &) const
Mesh edge labels of this cell (in order of model)
Definition: cellShapeI.H:147
faceList collapsedFaces() const
Collapsed faces of this cell.
Definition: cellShapeI.H:186
label nEdges() const
Number of edges.
Definition: cellShapeI.H:247
label nFaces() const
Number of faces.
Definition: cellShapeI.H:235
Foam::InfoProxy< cellShape > info() const
Return info proxy.
Definition: cellShape.H:150
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:60
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Istream & operator>>(Istream &, pistonPointEdgeData &)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)