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 | Copyright (C) 2011-2015 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 Istream
96  inline cellShape(Istream& is);
97 
98  //- Clone
99  inline autoPtr<cellShape> clone() const;
100 
101 
102  // Member Functions
103 
104  //- Return the points corresponding to this cellShape
105  inline pointField points(const pointField& meshPoints) const;
106 
107  //- Model reference
108  inline const cellModel& model() const;
109 
110  //- Mesh face labels of this cell (in order of model)
111  inline labelList meshFaces(const faceList& allFaces, const cell&) const;
112 
113  //- Mesh edge labels of this cell (in order of model)
114  inline labelList meshEdges
115  (
116  const edgeList& allEdges,
117  const labelList&
118  ) const;
119 
120  //- Faces of this cell
121  inline faceList faces() const;
122 
123  //- Collapsed faces of this cell
124  inline faceList collapsedFaces() const;
125 
126  //- Number of faces
127  inline label nFaces() const;
128 
129  //- Edges of this cellShape
130  inline edgeList edges() const;
131 
132  //- Number of edges
133  inline label nEdges() const;
134 
135  //- Number of points
136  inline label nPoints() const;
137 
138  //- Centroid of the cell
139  inline point centre(const pointField&) const;
140 
141  //- Return info proxy.
142  // Used to print token information to a stream
144  {
145  return *this;
146  }
147 
148  //- Scalar magnitude
149  inline scalar mag(const pointField&) const;
150 
151  //- Collapse shape to correct one after removing duplicate vertices
152  void collapse();
153 
154 
155  // Friend Operators
156 
157  friend bool operator==(const cellShape&, const cellShape&);
158 
159 
160  // IOstream operators
161 
162  friend Istream& operator>>(Istream&, cellShape&);
163  friend Ostream& operator<<(Ostream&, const cellShape&);
164 };
165 
166 
167 template<>
168 Ostream& operator<<(Ostream& os, const InfoProxy<cellShape>& ip);
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #include "cellShapeI.H"
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
cellShape()
Construct null.
Definition: cellShapeI.H:31
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
friend Istream & operator>>(Istream &, cellShape &)
labelList meshEdges(const edgeList &allEdges, const labelList &) const
Mesh edge labels of this cell (in order of model)
Definition: cellShapeI.H:129
point centre(const pointField &) const
Centroid of the cell.
Definition: cellShapeI.H:241
label nFaces() const
Number of faces.
Definition: cellShapeI.H:217
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:56
void collapse()
Collapse shape to correct one after removing duplicate vertices.
Definition: cellShape.C:32
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
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
faceList faces() const
Faces of this cell.
Definition: cellShapeI.H:162
friend bool operator==(const cellShape &, const cellShape &)
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:133
pointField points(const pointField &meshPoints) const
Return the points corresponding to this cellShape.
Definition: cellShapeI.H:69
edgeList edges() const
Edges of this cellShape.
Definition: cellShapeI.H:223
Namespace for OpenFOAM.
faceList collapsedFaces() const
Collapsed faces of this cell.
Definition: cellShapeI.H:168
label nPoints() const
Number of points.
Definition: cellShapeI.H:235
label nEdges() const
Number of edges.
Definition: cellShapeI.H:229
An analytical geometric cellShape.
Definition: cellShape.H:69
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:45
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
Definition: cellModel.H:64
const cellModel & model() const
Model reference.
Definition: cellShapeI.H:88
Foam::InfoProxy< cellShape > info() const
Return info proxy.
Definition: cellShape.H:142
friend Ostream & operator<<(Ostream &, const cellShape &)
labelList meshFaces(const faceList &allFaces, const cell &) const
Mesh face labels of this cell (in order of model)
Definition: cellShapeI.H:95
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:144
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
scalar mag(const pointField &) const
Scalar magnitude.
Definition: cellShapeI.H:247
autoPtr< cellShape > clone() const
Clone.
Definition: cellShapeI.H:60
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117