FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/pointField.H>
43 #include <OpenFOAM/edgeList.H>
44 #include <OpenFOAM/faceList.H>
45 #include <OpenFOAM/InfoProxy.H>
46 #include <OpenFOAM/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
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
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #include <OpenFOAM/cellModelI.H>
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #endif
189 
190 // ************************ vim: set sw=4 sts=4 et: ************************ //