cellModel.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::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
77 
78  //- Faces of the model
80 
81  //- Edges of the model
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 // ************************************************************************* //
Foam::cellModel::operator<<
friend Ostream & operator<<(Ostream &, const cellModel &)
Foam::cellModel::info
InfoProxy< cellModel > info() const
Return info proxy.
Definition: cellModel.H:149
Foam::cellModel::nPoints_
label nPoints_
Number of points in the model which determines the geometry.
Definition: cellModel.H:75
Foam::cellModel::index_
label index_
Label in the model list.
Definition: cellModel.H:72
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::InfoProxy
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:45
InfoProxy.H
Foam::cellModel::nFaces
label nFaces() const
Return number of faces.
Definition: cellModelI.H:62
Foam::cellModel::New
static autoPtr< cellModel > New(Istream &is)
Return a new cellModel on free-store created from Istream.
Definition: cellModel.H:92
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::cellModel::cellModel
cellModel(Istream &)
Construct from Istream.
Definition: cellModelIO.C:31
faceList.H
Foam::cellModel::clone
autoPtr< cellModel > clone() const
Return clone.
Definition: cellModel.H:98
Foam::cellModel::nPoints
label nPoints() const
Return number of points.
Definition: cellModelI.H:50
cellModelI.H
Foam::cellModel::writeData
bool writeData(Ostream &os) const
WriteData member function required by regIOobject.
Definition: cellModel.H:155
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::cellModel::nEdges
label nEdges() const
Return number of edges.
Definition: cellModelI.H:56
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::cellModel::mag
scalar mag(const labelList &pointLabels, const pointField &points) const
Cell volume.
Definition: cellModel.C:89
Foam::cellModel::operator!=
friend bool operator!=(const cellModel &, const cellModel &)
Inequality operator: true => ptr to models are not equal !
Definition: cellModelI.H:129
Foam::cellModel::modelFaces
const faceList & modelFaces() const
Return a raw list of model faces.
Definition: cellModelI.H:90
Foam::cellModel::centre
vector centre(const labelList &pointLabels, const pointField &points) const
Vector centroid.
Definition: cellModel.C:32
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::cellModel::name_
word name_
Name.
Definition: cellModel.H:69
Foam::cellModel::edges
edgeList edges(const labelList &pointLabels) const
Return list of edges.
Definition: cellModelI.H:70
Foam::operator!=
bool operator!=(const particle &, const particle &)
Definition: particle.C:147
edgeList.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::cellModel::name
const word & name() const
Return model name.
Definition: cellModelI.H:38
Foam::cellModel::faces_
faceList faces_
Faces of the model.
Definition: cellModel.H:78
pointField.H
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::cellModel::faces
faceList faces(const labelList &pointLabels) const
Return list of faces.
Definition: cellModelI.H:97
Foam::cellModel::operator==
friend bool operator==(const cellModel &, const cellModel &)
Equality operator: true => ptr to models are equal !
Definition: cellModelI.H:123
Foam::Vector< scalar >
Foam::cellModel::edges_
edgeList edges_
Edges of the model.
Definition: cellModel.H:81
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::cellModel
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
Definition: cellModel.H:64
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::IOstream::good
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
pointLabels
labelList pointLabels(nPoints, -1)
Foam::cellModel::index
label index() const
Return index of model in the model list.
Definition: cellModelI.H:44
autoPtr.H