primitiveMeshGeometry.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 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::primitiveMeshGeometry
26 
27 Description
28  Updateable mesh geometry + checking routines.
29 
30 SourceFiles
31  primitiveMeshGeometry.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef primitiveMeshGeometry_H
36 #define primitiveMeshGeometry_H
37 
38 #include "pointFields.H"
39 #include "HashSet.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class primitiveMeshGeometry Declaration
48 \*---------------------------------------------------------------------------*/
49 
51 {
52  //- Reference to primitiveMesh.
53  const primitiveMesh& mesh_;
54 
55  //- Uptodate copy of face areas
56  vectorField faceAreas_;
57 
58  //- Uptodate copy of face centres
59  vectorField faceCentres_;
60 
61  //- Uptodate copy of cell centres
62  vectorField cellCentres_;
63 
64  //- Uptodate copy of cell volumes
65  scalarField cellVolumes_;
66 
67 
68  // Private Member Functions
69 
70  //- Update face areas and centres on selected faces.
71  void updateFaceCentresAndAreas
72  (
73  const pointField& p,
74  const labelList& changedFaces
75  );
76 
77  //- Update cell volumes and centres on selected cells. Requires
78  // cells and faces to be consistent set.
79  void updateCellCentresAndVols
80  (
81  const labelList& changedCells,
82  const labelList& changedFaces
83  );
84 
85 public:
86 
87  ClassName("primitiveMeshGeometry");
88 
89  // Constructors
90 
91  //- Construct from mesh
93 
94 
95  // Member Functions
96 
97  // Access
98 
99  const primitiveMesh& mesh() const
100  {
101  return mesh_;
102  }
104  const vectorField& faceAreas() const
105  {
106  return faceAreas_;
107  }
108  const vectorField& faceCentres() const
109  {
110  return faceCentres_;
111  }
112  const vectorField& cellCentres() const
113  {
114  return cellCentres_;
115  }
116  const scalarField& cellVolumes() const
117  {
118  return cellVolumes_;
119  }
120 
121  // Edit
122 
123  //- Take over properties from mesh
124  void correct();
125 
126  //- Recalculate on selected faces. Recalculates cell properties
127  // on owner and neighbour of these cells.
128  void correct
129  (
130  const pointField& p,
131  const labelList& changedFaces
132  );
133 
134  //- Helper function: get affected cells from faces
135  labelList affectedCells(const labelList& changedFaces) const;
136 
137 
138  // Checking of selected faces with supplied geometry (mesh only used for
139  // topology). Parallel aware.
140 
141  static bool checkFaceDotProduct
142  (
143  const bool report,
144  const scalar orthWarn,
145  const primitiveMesh&,
146  const vectorField& cellCentres,
147  const vectorField& faceAreas,
148  const labelList& checkFaces,
149  labelHashSet* setPtr
150  );
151 
152  static bool checkFacePyramids
153  (
154  const bool report,
155  const scalar minPyrVol,
156  const primitiveMesh&,
157  const vectorField& cellCentres,
158  const pointField& p,
159  const labelList& checkFaces,
160  labelHashSet*
161  );
162 
163  static bool checkFaceSkewness
164  (
165  const bool report,
166  const scalar internalSkew,
167  const scalar boundarySkew,
168  const primitiveMesh& mesh,
169  const vectorField& cellCentres,
170  const vectorField& faceCentres,
171  const vectorField& faceAreas,
172  const labelList& checkFaces,
173  labelHashSet* setPtr
174  );
175 
176  static bool checkFaceWeights
177  (
178  const bool report,
179  const scalar warnWeight,
180  const primitiveMesh& mesh,
181  const vectorField& cellCentres,
182  const vectorField& faceCentres,
183  const vectorField& faceAreas,
184  const labelList& checkFaces,
185  labelHashSet* setPtr
186  );
187 
188  static bool checkFaceAngles
189  (
190  const bool report,
191  const scalar maxDeg,
192  const primitiveMesh& mesh,
193  const vectorField& faceAreas,
194  const pointField& p,
195  const labelList& checkFaces,
196  labelHashSet* setPtr
197  );
198 
199  //static bool checkFaceFlatness
200  //(
201  // const bool report,
202  // const scalar warnFlatness,
203  // const primitiveMesh&,
204  // const vectorField& faceAreas,
205  // const vectorField& faceCentres,
206  // const pointField& p,
207  // const labelList& checkFaces,
208  // labelHashSet* setPtr
209  //);
210 
211  static bool checkFaceTwist
212  (
213  const bool report,
214  const scalar minTwist,
215  const primitiveMesh&,
216  const vectorField& faceAreas,
217  const vectorField& faceCentres,
218  const pointField& p,
219  const labelList& checkFaces,
220  labelHashSet* setPtr
221  );
222 
223  static bool checkFaceArea
224  (
225  const bool report,
226  const scalar minArea,
227  const primitiveMesh&,
228  const vectorField& faceAreas,
229  const labelList& checkFaces,
230  labelHashSet* setPtr
231  );
232 
233  static bool checkCellDeterminant
234  (
235  const bool report,
236  const scalar minDet,
237  const primitiveMesh&,
238  const vectorField& faceAreas,
239  const labelList& checkFaces,
240  const labelList& affectedCells,
241  labelHashSet* setPtr
242  );
243 
244 
245  // Checking of selected faces with local geometry. Uses above static
246  // functions. Parallel aware.
247 
249  (
250  const bool report,
251  const scalar orthWarn,
252  const labelList& checkFaces,
253  labelHashSet* setPtr
254  ) const;
255 
256  bool checkFacePyramids
257  (
258  const bool report,
259  const scalar minPyrVol,
260  const pointField& p,
261  const labelList& checkFaces,
262  labelHashSet* setPtr
263  ) const;
264 
265  bool checkFaceSkewness
266  (
267  const bool report,
268  const scalar internalSkew,
269  const scalar boundarySkew,
270  const labelList& checkFaces,
271  labelHashSet* setPtr
272  ) const;
273 
274  bool checkFaceWeights
275  (
276  const bool report,
277  const scalar warnWeight,
278  const labelList& checkFaces,
279  labelHashSet* setPtr
280  ) const;
281 
282  bool checkFaceAngles
283  (
284  const bool report,
285  const scalar maxDeg,
286  const pointField& p,
287  const labelList& checkFaces,
288  labelHashSet* setPtr
289  ) const;
290 
291  //bool checkFaceFlatness
292  //(
293  // const bool report,
294  // const scalar warnFlatness,
295  // const pointField& p,
296  // const labelList& checkFaces,
297  // labelHashSet* setPtr
298  //) const;
299 
300  bool checkFaceTwist
301  (
302  const bool report,
303  const scalar minTwist,
304  const pointField& p,
305  const labelList& checkFaces,
306  labelHashSet* setPtr
307  ) const;
308 
309  bool checkFaceArea
310  (
311  const bool report,
312  const scalar minArea,
313  const labelList& checkFaces,
314  labelHashSet* setPtr
315  ) const;
316 
318  (
319  const bool report,
320  const scalar warnDet,
321  const labelList& checkFaces,
322  const labelList& affectedCells,
323  labelHashSet* setPtr
324  ) const;
325 };
326 
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 
329 } // End namespace Foam
330 
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 
333 #endif
334 
335 // ************************************************************************* //
const vectorField & faceAreas() const
ClassName("primitiveMeshGeometry")
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
static bool checkFacePyramids(const bool report, const scalar minPyrVol, const primitiveMesh &, const vectorField &cellCentres, const pointField &p, const labelList &checkFaces, labelHashSet *)
const scalarField & cellVolumes() const
labelList affectedCells(const labelList &changedFaces) const
Helper function: get affected cells from faces.
static bool checkFaceArea(const bool report, const scalar minArea, const primitiveMesh &, const vectorField &faceAreas, const labelList &checkFaces, labelHashSet *setPtr)
static bool checkCellDeterminant(const bool report, const scalar minDet, const primitiveMesh &, const vectorField &faceAreas, const labelList &checkFaces, const labelList &affectedCells, labelHashSet *setPtr)
static bool checkFaceSkewness(const bool report, const scalar internalSkew, const scalar boundarySkew, const primitiveMesh &mesh, const vectorField &cellCentres, const vectorField &faceCentres, const vectorField &faceAreas, const labelList &checkFaces, labelHashSet *setPtr)
static bool checkFaceAngles(const bool report, const scalar maxDeg, const primitiveMesh &mesh, const vectorField &faceAreas, const pointField &p, const labelList &checkFaces, labelHashSet *setPtr)
primitiveMeshGeometry(const primitiveMesh &)
Construct from mesh.
void correct()
Take over properties from mesh.
const vectorField & faceCentres() const
Updateable mesh geometry + checking routines.
static bool checkFaceDotProduct(const bool report, const scalar orthWarn, const primitiveMesh &, const vectorField &cellCentres, const vectorField &faceAreas, const labelList &checkFaces, labelHashSet *setPtr)
static bool checkFaceWeights(const bool report, const scalar warnWeight, const primitiveMesh &mesh, const vectorField &cellCentres, const vectorField &faceCentres, const vectorField &faceAreas, const labelList &checkFaces, labelHashSet *setPtr)
const primitiveMesh & mesh() const
volScalarField & p
const vectorField & cellCentres() const
static bool checkFaceTwist(const bool report, const scalar minTwist, const primitiveMesh &, const vectorField &faceAreas, const vectorField &faceCentres, const pointField &p, const labelList &checkFaces, labelHashSet *setPtr)
Namespace for OpenFOAM.