Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / meshTools / primitiveMeshGeometry / primitiveMeshGeometry.H
blobdd9a8dc0763da637177e053b63638c171721b3d6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 Class
25     Foam::primitiveMeshGeometry
27 Description
28     Updateable mesh geometry + checking routines.
30 SourceFiles
31     primitiveMeshGeometry.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef primitiveMeshGeometry_H
36 #define primitiveMeshGeometry_H
38 #include "pointFields.H"
39 #include "HashSet.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 /*---------------------------------------------------------------------------*\
47                            Class primitiveMeshGeometry Declaration
48 \*---------------------------------------------------------------------------*/
50 class primitiveMeshGeometry
52         //- Reference to primitiveMesh.
53         const primitiveMesh& mesh_;
55         //- Uptodate copy of face areas
56         vectorField faceAreas_;
58         //- Uptodate copy of face centres
59         vectorField faceCentres_;
61         //- Uptodate copy of cell centres
62         vectorField cellCentres_;
64         //- Uptodate copy of cell volumes
65         scalarField cellVolumes_;
68     // Private Member Functions
70         //- Update face areas and centres on selected faces.
71         void updateFaceCentresAndAreas
72         (
73             const pointField& p,
74             const labelList& changedFaces
75         );
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         );
85 public:
87     ClassName("primitiveMeshGeometry");
89     // Constructors
91         //- Construct from mesh
92         primitiveMeshGeometry(const primitiveMesh&);
95     // Member Functions
97         // Access
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             }
121         // Edit
123             //- Take over properties from mesh
124             void correct();
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             );
134             //- Helper function: get affected cells from faces
135             labelList affectedCells(const labelList& changedFaces) const;
138         // Checking of selected faces with supplied geometry (mesh only used for
139         // topology). Parallel aware.
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             );
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             );
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             );
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             );
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             );
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             //);
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             );
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             );
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             );
245         // Checking of selected faces with local geometry. Uses above static
246         // functions. Parallel aware.
248             bool checkFaceDotProduct
249             (
250                 const bool report,
251                 const scalar orthWarn,
252                 const labelList& checkFaces,
253                 labelHashSet* setPtr
254             ) const;
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;
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;
274             bool checkFaceWeights
275             (
276                 const bool report,
277                 const scalar warnWeight,
278                 const labelList& checkFaces,
279                 labelHashSet* setPtr
280             ) const;
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;
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;
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;
309             bool checkFaceArea
310             (
311                 const bool report,
312                 const scalar minArea,
313                 const labelList& checkFaces,
314                 labelHashSet* setPtr
315             ) const;
317             bool checkCellDeterminant
318             (
319                 const bool report,
320                 const scalar warnDet,
321                 const labelList& checkFaces,
322                 const labelList& affectedCells,
323                 labelHashSet* setPtr
324             ) const;
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
329 } // End namespace Foam
331 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
333 #endif
335 // ************************************************************************* //