cellModel.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-2020 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::cellModel
26 
27 Description
28  Maps a geometry to a set of cell primitives, which enables
29  geometric cell data to be calculated without access to the primitive
30  geometric level. This means mapping a 3D geometry to a set of
31  pyramids which are each described by a cell face and the cell centre
32  point.
33 
34 SourceFiles
35  cellModelI.H
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef cellModel_H
40 #define cellModel_H
41 
42 #include "pointField.H"
43 #include "edgeList.H"
44 #include "faceList.H"
45 #include "InfoProxy.H"
46 #include "autoPtr.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of friend functions and operators
54 
55 class cellModel;
56 inline bool operator==(const cellModel&, const cellModel&);
57 inline bool operator!=(const cellModel&, const cellModel&);
58 Ostream& operator<<(Ostream&, const cellModel&);
59 
60 
61 /*---------------------------------------------------------------------------*\
62  Class cellModel Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class cellModel
66 {
67  // Private Data
68 
69  //- Name
70  word name_;
71 
72  //- Label in the model list
73  label index_;
74 
75  //- Number of points in the model which determines the geometry
76  label nPoints_;
77 
78  //- Faces of the model
79  faceList faces_;
80 
81  //- Edges of the model
82  edgeList edges_;
83 
84 
85 public:
86 
87  // Constructors
88 
89  //- Construct from Istream
91 
92  //- Return a new cellModel on free-store created from Istream
93  static autoPtr<cellModel> New(Istream& is)
94  {
95  return autoPtr<cellModel>(new cellModel(is));
96  }
97 
98  //- Return clone
100  {
101  return autoPtr<cellModel>(new cellModel(*this));
102  }
103 
104 
105  // Member Functions
106 
107  // Access
108 
109  //- Return model name
110  inline const word& name() const;
111 
112  //- Return index of model in the model list
113  inline label index() const;
114 
115  //- Return number of points
116  inline label nPoints() const;
117 
118  //- Return number of edges
119  inline label nEdges() const;
120 
121  //- Return number of faces
122  inline label nFaces() const;
123 
124  //- Return list of edges
125  inline edgeList edges(const labelList& pointLabels) const;
126 
127  //- Return a raw list of model faces
128  inline const faceList& modelFaces() const;
129 
130  //- Return list of faces
131  inline faceList faces(const labelList& pointLabels) const;
132 
133 
134  //- Vector centroid
135  vector centre
136  (
137  const labelList& pointLabels,
138  const pointField& points
139  ) const;
140 
141  //- Cell volume
142  scalar mag
143  (
144  const labelList& pointLabels,
145  const pointField& points
146  ) const;
147 
148  //- Return info proxy.
149  // Used to print token information to a stream
150  InfoProxy<cellModel> info() const
151  {
152  return *this;
153  }
154 
155  //- WriteData member function required by regIOobject
156  bool writeData(Ostream& os) const
157  {
158  os << *this;
159  return os.good();
160  }
161 
162 
163  // Friend operators
164 
165  //- Equality operator: true => ptr to models are equal !
166  friend bool operator==(const cellModel&, const cellModel&);
167 
168  //- Inequality operator: true => ptr to models are not equal !
169  friend bool operator!=(const cellModel&, const cellModel&);
170 
171 
172  // Ostream operator
173 
174  friend Ostream& operator<<(Ostream&, const cellModel&);
175 };
176 
177 
178 template<>
179 Ostream& operator<<(Ostream& os, const InfoProxy<cellModel>& ip);
180 
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace Foam
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #include "cellModelI.H"
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 #endif
193 
194 // ************************************************************************* //
label nFaces() const
Return number of faces.
Definition: cellModelI.H:62
autoPtr< cellModel > clone() const
Return clone.
Definition: cellModel.H:98
static autoPtr< cellModel > New(Istream &is)
Return a new cellModel on free-store created from Istream.
Definition: cellModel.H:92
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
labelList pointLabels(nPoints, -1)
label nEdges() const
Return number of edges.
Definition: cellModelI.H:56
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
label nPoints() const
Return number of points.
Definition: cellModelI.H:50
vector centre(const labelList &pointLabels, const pointField &points) const
Vector centroid.
Definition: cellModel.C:32
InfoProxy< cellModel > info() const
Return info proxy.
Definition: cellModel.H:149
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:330
const pointField & points
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
A class for handling words, derived from string.
Definition: word.H:59
bool writeData(Ostream &os) const
WriteData member function required by regIOobject.
Definition: cellModel.H:155
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
friend bool operator!=(const cellModel &, const cellModel &)
Inequality operator: true => ptr to models are not equal !
Definition: cellModelI.H:129
const faceList & modelFaces() const
Return a raw list of model faces.
Definition: cellModelI.H:90
label index() const
Return index of model in the model list.
Definition: cellModelI.H:44
scalar mag(const labelList &pointLabels, const pointField &points) const
Cell volume.
Definition: cellModel.C:89
friend Ostream & operator<<(Ostream &, const cellModel &)
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:45
Ostream & operator<<(Ostream &, const ensightPart &)
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
Definition: cellModel.H:64
edgeList edges(const labelList &pointLabels) const
Return list of edges.
Definition: cellModelI.H:70
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const word & name() const
Return model name.
Definition: cellModelI.H:38
bool operator!=(const particle &, const particle &)
Definition: particle.C:1205
friend bool operator==(const cellModel &, const cellModel &)
Equality operator: true => ptr to models are equal !
Definition: cellModelI.H:123
faceList faces(const labelList &pointLabels) const
Return list of faces.
Definition: cellModelI.H:97
Namespace for OpenFOAM.
cellModel(Istream &)
Construct from Istream.
Definition: cellModelIO.C:31