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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::primitiveMeshGeometry
28 
29 Description
30  Updateable mesh geometry + checking routines.
31 
32 SourceFiles
33  primitiveMeshGeometry.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef primitiveMeshGeometry_H
38 #define primitiveMeshGeometry_H
39 
40 #include "pointFields.H"
41 #include "HashSet.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class primitiveMeshGeometry Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 {
54  //- Reference to primitiveMesh.
55  const primitiveMesh& mesh_;
56 
57  //- Uptodate copy of face areas
58  vectorField faceAreas_;
59 
60  //- Uptodate copy of face centres
61  vectorField faceCentres_;
62 
63  //- Uptodate copy of cell centres
64  vectorField cellCentres_;
65 
66  //- Uptodate copy of cell volumes
67  scalarField cellVolumes_;
68 
69 
70  // Private Member Functions
71 
72  //- Update face areas and centres on selected faces.
73  void updateFaceCentresAndAreas
74  (
75  const pointField& p,
76  const labelList& changedFaces
77  );
78 
79  //- Update cell volumes and centres on selected cells. Requires
80  // cells and faces to be consistent set.
81  void updateCellCentresAndVols
82  (
83  const labelList& changedCells,
84  const labelList& changedFaces
85  );
86 
87 public:
88 
89  ClassName("primitiveMeshGeometry");
90 
91  // Constructors
92 
93  //- Construct from mesh
95 
96 
97  // Member Functions
98 
99  // Access
100 
101  const primitiveMesh& mesh() const
102  {
103  return mesh_;
104  }
105 
106  const vectorField& faceAreas() const
107  {
108  return faceAreas_;
109  }
110  const vectorField& faceCentres() const
111  {
112  return faceCentres_;
113  }
114  const vectorField& cellCentres() const
115  {
116  return cellCentres_;
117  }
118  const scalarField& cellVolumes() const
119  {
120  return cellVolumes_;
121  }
122 
123  // Edit
124 
125  //- Take over properties from mesh
126  void correct();
127 
128  //- Recalculate on selected faces. Recalculates cell properties
129  // on owner and neighbour of these cells.
130  void correct
131  (
132  const pointField& p,
133  const labelList& changedFaces
134  );
135 
136  //- Helper function: get affected cells from faces
137  labelList affectedCells(const labelList& changedFaces) const;
138 
139 
140  // Checking of selected faces with supplied geometry (mesh only used for
141  // topology). Parallel aware.
142 
143  static bool checkFaceDotProduct
144  (
145  const bool report,
146  const scalar orthWarn,
147  const primitiveMesh&,
148  const vectorField& cellCentres,
149  const vectorField& faceAreas,
150  const labelList& checkFaces,
151  labelHashSet* setPtr
152  );
153 
154  static bool checkFacePyramids
155  (
156  const bool report,
157  const scalar minPyrVol,
158  const primitiveMesh&,
159  const vectorField& cellCentres,
160  const pointField& p,
161  const labelList& checkFaces,
162  labelHashSet*
163  );
164 
165  static bool checkFaceSkewness
166  (
167  const bool report,
168  const scalar internalSkew,
169  const scalar boundarySkew,
170  const primitiveMesh& mesh,
171  const vectorField& cellCentres,
172  const vectorField& faceCentres,
173  const vectorField& faceAreas,
174  const labelList& checkFaces,
175  labelHashSet* setPtr
176  );
177 
178  static bool checkFaceWeights
179  (
180  const bool report,
181  const scalar warnWeight,
182  const primitiveMesh& mesh,
183  const vectorField& cellCentres,
184  const vectorField& faceCentres,
185  const vectorField& faceAreas,
186  const labelList& checkFaces,
187  labelHashSet* setPtr
188  );
189 
190  static bool checkFaceAngles
191  (
192  const bool report,
193  const scalar maxDeg,
194  const primitiveMesh& mesh,
195  const vectorField& faceAreas,
196  const pointField& p,
197  const labelList& checkFaces,
198  labelHashSet* setPtr
199  );
200 
201  //static bool checkFaceFlatness
202  //(
203  // const bool report,
204  // const scalar warnFlatness,
205  // const primitiveMesh&,
206  // const vectorField& faceAreas,
207  // const vectorField& faceCentres,
208  // const pointField& p,
209  // const labelList& checkFaces,
210  // labelHashSet* setPtr
211  //);
212 
213  static bool checkFaceTwist
214  (
215  const bool report,
216  const scalar minTwist,
217  const primitiveMesh&,
218  const vectorField& faceAreas,
219  const vectorField& faceCentres,
220  const pointField& p,
221  const labelList& checkFaces,
222  labelHashSet* setPtr
223  );
224 
225  static bool checkFaceArea
226  (
227  const bool report,
228  const scalar minArea,
229  const primitiveMesh&,
230  const vectorField& faceAreas,
231  const labelList& checkFaces,
232  labelHashSet* setPtr
233  );
234 
235  static bool checkCellDeterminant
236  (
237  const bool report,
238  const scalar minDet,
239  const primitiveMesh&,
240  const vectorField& faceAreas,
241  const labelList& checkFaces,
242  const labelList& affectedCells,
243  labelHashSet* setPtr
244  );
245 
246 
247  // Checking of selected faces with local geometry. Uses above static
248  // functions. Parallel aware.
249 
251  (
252  const bool report,
253  const scalar orthWarn,
254  const labelList& checkFaces,
255  labelHashSet* setPtr
256  ) const;
257 
258  bool checkFacePyramids
259  (
260  const bool report,
261  const scalar minPyrVol,
262  const pointField& p,
263  const labelList& checkFaces,
264  labelHashSet* setPtr
265  ) const;
266 
267  bool checkFaceSkewness
268  (
269  const bool report,
270  const scalar internalSkew,
271  const scalar boundarySkew,
272  const labelList& checkFaces,
273  labelHashSet* setPtr
274  ) const;
275 
276  bool checkFaceWeights
277  (
278  const bool report,
279  const scalar warnWeight,
280  const labelList& checkFaces,
281  labelHashSet* setPtr
282  ) const;
283 
284  bool checkFaceAngles
285  (
286  const bool report,
287  const scalar maxDeg,
288  const pointField& p,
289  const labelList& checkFaces,
290  labelHashSet* setPtr
291  ) const;
292 
293  //bool checkFaceFlatness
294  //(
295  // const bool report,
296  // const scalar warnFlatness,
297  // const pointField& p,
298  // const labelList& checkFaces,
299  // labelHashSet* setPtr
300  //) const;
301 
302  bool checkFaceTwist
303  (
304  const bool report,
305  const scalar minTwist,
306  const pointField& p,
307  const labelList& checkFaces,
308  labelHashSet* setPtr
309  ) const;
310 
311  bool checkFaceArea
312  (
313  const bool report,
314  const scalar minArea,
315  const labelList& checkFaces,
316  labelHashSet* setPtr
317  ) const;
318 
320  (
321  const bool report,
322  const scalar warnDet,
323  const labelList& checkFaces,
324  const labelList& affectedCells,
325  labelHashSet* setPtr
326  ) const;
327 };
328 
329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 
331 } // End namespace Foam
332 
333 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 
335 #endif
336 
337 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::primitiveMeshGeometry::faceAreas
const vectorField & faceAreas() const
Definition: primitiveMeshGeometry.H:105
Foam::primitiveMeshGeometry::affectedCells
labelList affectedCells(const labelList &changedFaces) const
Helper function: get affected cells from faces.
Definition: primitiveMeshGeometry.C:192
Foam::primitiveMeshGeometry::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshGeometry.H:113
Foam::primitiveMeshGeometry::checkFacePyramids
static bool checkFacePyramids(const bool report, const scalar minPyrVol, const primitiveMesh &, const vectorField &cellCentres, const pointField &p, const labelList &checkFaces, labelHashSet *)
Definition: primitiveMeshGeometry.C:400
Foam::primitiveMeshGeometry::cellVolumes
const scalarField & cellVolumes() const
Definition: primitiveMeshGeometry.H:117
Foam::HashSet< label, Hash< label > >
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::primitiveMeshGeometry::checkCellDeterminant
static bool checkCellDeterminant(const bool report, const scalar minDet, const primitiveMesh &, const vectorField &faceAreas, const labelList &checkFaces, const labelList &affectedCells, labelHashSet *setPtr)
Definition: primitiveMeshGeometry.C:1152
Foam::primitiveMeshGeometry
Updateable mesh geometry + checking routines.
Definition: primitiveMeshGeometry.H:51
Foam::Field< vector >
Foam::primitiveMeshGeometry::faceCentres
const vectorField & faceCentres() const
Definition: primitiveMeshGeometry.H:109
Foam::primitiveMeshGeometry::checkFaceAngles
static bool checkFaceAngles(const bool report, const scalar maxDeg, const primitiveMesh &mesh, const vectorField &faceAreas, const pointField &p, const labelList &checkFaces, labelHashSet *setPtr)
Definition: primitiveMeshGeometry.C:731
HashSet.H
Foam::primitiveMeshGeometry::checkFaceSkewness
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)
Definition: primitiveMeshGeometry.C:510
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::primitiveMeshGeometry::correct
void correct()
Take over properties from mesh.
Definition: primitiveMeshGeometry.C:236
Foam::primitiveMeshGeometry::mesh
const primitiveMesh & mesh() const
Definition: primitiveMeshGeometry.H:100
Foam::primitiveMeshGeometry::primitiveMeshGeometry
primitiveMeshGeometry(const primitiveMesh &)
Construct from mesh.
Definition: primitiveMeshGeometry.C:221
Foam::primitiveMeshGeometry::checkFaceArea
static bool checkFaceArea(const bool report, const scalar minArea, const primitiveMesh &, const vectorField &faceAreas, const labelList &checkFaces, labelHashSet *setPtr)
Definition: primitiveMeshGeometry.C:1093
Foam::List< label >
Foam::primitiveMeshGeometry::checkFaceDotProduct
static bool checkFaceDotProduct(const bool report, const scalar orthWarn, const primitiveMesh &, const vectorField &cellCentres, const vectorField &faceAreas, const labelList &checkFaces, labelHashSet *setPtr)
Definition: primitiveMeshGeometry.C:259
Foam::primitiveMeshGeometry::checkFaceWeights
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)
Definition: primitiveMeshGeometry.C:647
Foam::primitiveMeshGeometry::checkFaceTwist
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)
Definition: primitiveMeshGeometry.C:989
Foam::labelHashSet
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition: HashSet.H:85
Foam::primitiveMeshGeometry::ClassName
ClassName("primitiveMeshGeometry")
pointFields.H
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78