OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

polyMeshGeometry.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::polyMeshGeometry
00027 
00028 Description
00029     Updateable mesh geometry and checking routines.
00030 
00031     - non-ortho done across coupled faces.
00032     - faceWeight (delta factors) done across coupled faces.
00033 
00034 SourceFiles
00035     polyMeshGeometry.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef polyMeshGeometry_H
00040 #define polyMeshGeometry_H
00041 
00042 #include "pointFields.H"
00043 #include "HashSet.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 /*---------------------------------------------------------------------------*\
00051                            Class polyMeshGeometry Declaration
00052 \*---------------------------------------------------------------------------*/
00053 
00054 class polyMeshGeometry
00055 {
00056         //- Reference to polyMesh.
00057         const polyMesh& mesh_;
00058 
00059         //- Uptodate copy of face areas
00060         vectorField faceAreas_;
00061 
00062         //- Uptodate copy of face centres
00063         vectorField faceCentres_;
00064 
00065         //- Uptodate copy of cell centres
00066         vectorField cellCentres_;
00067 
00068         //- Uptodate copy of cell volumes
00069         scalarField cellVolumes_;
00070 
00071 
00072     // Private Member Functions
00073 
00074         //- Update face areas and centres on selected faces.
00075         void updateFaceCentresAndAreas
00076         (
00077             const pointField& p,
00078             const labelList& changedFaces
00079         );
00080 
00081         //- Update cell volumes and centres on selected cells. Requires
00082         //  cells and faces to be consistent set.
00083         void updateCellCentresAndVols
00084         (
00085             const labelList& changedCells,
00086             const labelList& changedFaces
00087         );
00088 
00089         //- Detect&report non-ortho error for single face.
00090         static scalar checkNonOrtho
00091         (
00092             const polyMesh& mesh,
00093             const bool report,
00094             const scalar severeNonorthogonalityThreshold,
00095             const label faceI,
00096             const vector& s,    // face area vector
00097             const vector& d,    // cc-cc vector
00098 
00099             label& severeNonOrth,
00100             label& errorNonOrth,
00101             labelHashSet* setPtr
00102         );
00103 
00104         //- Calculate skewness given two cell centres and one face centre.
00105         static scalar calcSkewness
00106         (
00107             const point& ownCc,
00108             const point& neiCc,
00109             const point& fc
00110         );
00111 
00112 public:
00113 
00114     ClassName("polyMeshGeometry");
00115 
00116     // Constructors
00117 
00118         //- Construct from mesh
00119         polyMeshGeometry(const polyMesh&);
00120 
00121 
00122     // Member Functions
00123 
00124         // Access
00125 
00126             const polyMesh& mesh() const
00127             {
00128                 return mesh_;
00129             }
00130 
00131             const vectorField& faceAreas() const
00132             {
00133                 return faceAreas_;
00134             }
00135             const vectorField& faceCentres() const
00136             {
00137                 return faceCentres_;
00138             }
00139             const vectorField& cellCentres() const
00140             {
00141                 return cellCentres_;
00142             }
00143             const scalarField& cellVolumes() const
00144             {
00145                 return cellVolumes_;
00146             }
00147 
00148         // Edit
00149 
00150             //- Take over properties from mesh
00151             void correct();
00152 
00153             //- Recalculate on selected faces. Recalculates cell properties
00154             //  on owner and neighbour of these cells.
00155             void correct
00156             (
00157                 const pointField& p,
00158                 const labelList& changedFaces
00159             );
00160 
00161             //- Helper function: get affected cells from faces
00162             static labelList affectedCells
00163             (
00164                 const polyMesh&,
00165                 const labelList& changedFaces
00166             );
00167 
00168 
00169         // Checking of selected faces with supplied geometry (mesh only used for
00170         // topology). Coupled aware (coupled faces treated as internal ones)
00171 
00172             //- See primitiveMesh
00173             static bool checkFaceDotProduct
00174             (
00175                 const bool report,
00176                 const scalar orthWarn,
00177                 const polyMesh&,
00178                 const vectorField& cellCentres,
00179                 const vectorField& faceAreas,
00180                 const labelList& checkFaces,
00181                 const List<labelPair>& baffles,
00182                 labelHashSet* setPtr
00183             );
00184 
00185             //- See primitiveMesh
00186             static bool checkFacePyramids
00187             (
00188                 const bool report,
00189                 const scalar minPyrVol,
00190                 const polyMesh&,
00191                 const vectorField& cellCentres,
00192                 const pointField& p,
00193                 const labelList& checkFaces,
00194                 const List<labelPair>& baffles,
00195                 labelHashSet*
00196             );
00197 
00198             //- See primitiveMesh
00199             static bool checkFaceSkewness
00200             (
00201                 const bool report,
00202                 const scalar internalSkew,
00203                 const scalar boundarySkew,
00204                 const polyMesh& mesh,
00205                 const vectorField& cellCentres,
00206                 const vectorField& faceCentres,
00207                 const vectorField& faceAreas,
00208                 const labelList& checkFaces,
00209                 const List<labelPair>& baffles,
00210                 labelHashSet* setPtr
00211             );
00212 
00213             //- Interpolation weights (0.5 for regular mesh)
00214             static bool checkFaceWeights
00215             (
00216                 const bool report,
00217                 const scalar warnWeight,
00218                 const polyMesh& mesh,
00219                 const vectorField& cellCentres,
00220                 const vectorField& faceCentres,
00221                 const vectorField& faceAreas,
00222                 const labelList& checkFaces,
00223                 const List<labelPair>& baffles,
00224                 labelHashSet* setPtr
00225             );
00226 
00227             //- Cell volume ratio of neighbouring cells (1 for regular mesh)
00228             static bool checkVolRatio
00229             (
00230                 const bool report,
00231                 const scalar warnRatio,
00232                 const polyMesh& mesh,
00233                 const scalarField& cellVolumes,
00234                 const labelList& checkFaces,
00235                 const List<labelPair>& baffles,
00236                 labelHashSet* setPtr
00237             );
00238 
00239             //- See primitiveMesh
00240             static bool checkFaceAngles
00241             (
00242                 const bool report,
00243                 const scalar maxDeg,
00244                 const polyMesh& mesh,
00245                 const vectorField& faceAreas,
00246                 const pointField& p,
00247                 const labelList& checkFaces,
00248                 labelHashSet* setPtr
00249             );
00250 
00251             //- Triangle (from face-centre decomposition) normal v.s.
00252             //  average face normal
00253             static bool checkFaceTwist
00254             (
00255                 const bool report,
00256                 const scalar minTwist,
00257                 const polyMesh&,
00258                 const vectorField& cellCentres,
00259                 const vectorField& faceAreas,
00260                 const vectorField& faceCentres,
00261                 const pointField& p,
00262                 const labelList& checkFaces,
00263                 labelHashSet* setPtr
00264             );
00265 
00266             //- Consecutive triangle (from face-centre decomposition) normals
00267             static bool checkTriangleTwist
00268             (
00269                 const bool report,
00270                 const scalar minTwist,
00271                 const polyMesh&,
00272                 const vectorField& faceAreas,
00273                 const vectorField& faceCentres,
00274                 const pointField& p,
00275                 const labelList& checkFaces,
00276                 labelHashSet* setPtr
00277             );
00278 
00279             //- Small faces
00280             static bool checkFaceArea
00281             (
00282                 const bool report,
00283                 const scalar minArea,
00284                 const polyMesh&,
00285                 const vectorField& faceAreas,
00286                 const labelList& checkFaces,
00287                 labelHashSet* setPtr
00288             );
00289 
00290             static bool checkCellDeterminant
00291             (
00292                 const bool report,
00293                 const scalar minDet,
00294                 const polyMesh&,
00295                 const vectorField& faceAreas,
00296                 const labelList& checkFaces,
00297                 const labelList& affectedCells,
00298                 labelHashSet* setPtr
00299             );
00300 
00301 
00302         // Checking of selected faces with local geometry. Uses above static
00303         // functions. Parallel aware.
00304 
00305             bool checkFaceDotProduct
00306             (
00307                 const bool report,
00308                 const scalar orthWarn,
00309                 const labelList& checkFaces,
00310                 const List<labelPair>& baffles,
00311                 labelHashSet* setPtr
00312             ) const;
00313 
00314             bool checkFacePyramids
00315             (
00316                 const bool report,
00317                 const scalar minPyrVol,
00318                 const pointField& p,
00319                 const labelList& checkFaces,
00320                 const List<labelPair>& baffles,
00321                 labelHashSet* setPtr
00322             ) const;
00323 
00324             bool checkFaceSkewness
00325             (
00326                 const bool report,
00327                 const scalar internalSkew,
00328                 const scalar boundarySkew,
00329                 const labelList& checkFaces,
00330                 const List<labelPair>& baffles,
00331                 labelHashSet* setPtr
00332             ) const;
00333 
00334             bool checkFaceWeights
00335             (
00336                 const bool report,
00337                 const scalar warnWeight,
00338                 const labelList& checkFaces,
00339                 const List<labelPair>& baffles,
00340                 labelHashSet* setPtr
00341             ) const;
00342 
00343             bool checkVolRatio
00344             (
00345                 const bool report,
00346                 const scalar warnRatio,
00347                 const labelList& checkFaces,
00348                 const List<labelPair>& baffles,
00349                 labelHashSet* setPtr
00350             ) const;
00351 
00352             bool checkFaceAngles
00353             (
00354                 const bool report,
00355                 const scalar maxDeg,
00356                 const pointField& p,
00357                 const labelList& checkFaces,
00358                 labelHashSet* setPtr
00359             ) const;
00360 
00361             bool checkFaceTwist
00362             (
00363                 const bool report,
00364                 const scalar minTwist,
00365                 const pointField& p,
00366                 const labelList& checkFaces,
00367                 labelHashSet* setPtr
00368             ) const;
00369 
00370             bool checkTriangleTwist
00371             (
00372                 const bool report,
00373                 const scalar minTwist,
00374                 const pointField& p,
00375                 const labelList& checkFaces,
00376                 labelHashSet* setPtr
00377             ) const;
00378 
00379             bool checkFaceArea
00380             (
00381                 const bool report,
00382                 const scalar minArea,
00383                 const labelList& checkFaces,
00384                 labelHashSet* setPtr
00385             ) const;
00386 
00387             bool checkCellDeterminant
00388             (
00389                 const bool report,
00390                 const scalar warnDet,
00391                 const labelList& checkFaces,
00392                 const labelList& affectedCells,
00393                 labelHashSet* setPtr
00394             ) const;
00395 };
00396 
00397 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00398 
00399 } // End namespace Foam
00400 
00401 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00402 
00403 #endif
00404 
00405 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd