OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen 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-2007 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     polyMeshGeometry
00027 
00028 Description
00029     Updateable mesh geometry + 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 "labelHashSet.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         //- Helper: 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 
00105 public:
00106 
00107     ClassName("polyMeshGeometry");
00108 
00109     // Constructors
00110 
00111         //- Construct from mesh
00112         polyMeshGeometry(const polyMesh&);
00113 
00114 
00115     // Member Functions
00116 
00117         // Access
00118 
00119             const polyMesh& mesh() const
00120             {
00121                 return mesh_;
00122             }
00123 
00124             const vectorField& faceAreas() const
00125             {
00126                 return faceAreas_;
00127             }
00128             const vectorField& faceCentres() const
00129             {
00130                 return faceCentres_;
00131             }
00132             const vectorField& cellCentres() const
00133             {
00134                 return cellCentres_;
00135             }
00136             const scalarField& cellVolumes() const
00137             {
00138                 return cellVolumes_;
00139             }
00140 
00141         // Edit
00142 
00143             //- Take over properties from mesh
00144             void correct();
00145 
00146             //- Recalculate on selected faces. Recalculates cell properties
00147             //  on owner and neighbour of these cells.
00148             void correct
00149             (
00150                 const pointField& p,
00151                 const labelList& changedFaces
00152             );
00153 
00154             //- Helper function: get affected cells from faces
00155             labelList affectedCells(const labelList& changedFaces) const;
00156 
00157 
00158         // Checking of selected faces with supplied geometry (mesh only used for
00159         // topology). Parallel aware.
00160 
00161             static bool checkFaceDotProduct
00162             (
00163                 const bool report,
00164                 const scalar orthWarn,
00165                 const polyMesh&,
00166                 const vectorField& cellCentres,
00167                 const vectorField& faceAreas,
00168                 const labelList& checkFaces,
00169                 labelHashSet* setPtr
00170             );
00171 
00172             static bool checkFacePyramids
00173             (
00174                 const bool report,
00175                 const scalar minPyrVol,
00176                 const polyMesh&,
00177                 const vectorField& cellCentres,
00178                 const pointField& p,
00179                 const labelList& checkFaces,
00180                 labelHashSet*
00181             );
00182 
00183             static bool checkFaceSkewness
00184             (
00185                 const bool report,
00186                 const scalar internalSkew,
00187                 const scalar boundarySkew,
00188                 const polyMesh& mesh,
00189                 const vectorField& cellCentres,
00190                 const vectorField& faceCentres,
00191                 const vectorField& faceAreas,
00192                 const labelList& checkFaces,
00193                 labelHashSet* setPtr
00194             );
00195 
00196             static bool checkFaceWeights
00197             (
00198                 const bool report,
00199                 const scalar warnWeight,
00200                 const polyMesh& mesh,
00201                 const vectorField& cellCentres,
00202                 const vectorField& faceCentres,
00203                 const vectorField& faceAreas,
00204                 const labelList& checkFaces,
00205                 labelHashSet* setPtr
00206             );
00207 
00208             static bool checkFaceAngles
00209             (
00210                 const bool report,
00211                 const scalar maxDeg,
00212                 const polyMesh& mesh,
00213                 const vectorField& faceAreas,
00214                 const pointField& p,
00215                 const labelList& checkFaces,
00216                 labelHashSet* setPtr
00217             );
00218 
00219             static bool checkFaceTwist
00220             (
00221                 const bool report,
00222                 const scalar minTwist,
00223                 const polyMesh&,
00224                 const vectorField& faceAreas,
00225                 const vectorField& faceCentres,
00226                 const pointField& p,
00227                 const labelList& checkFaces,
00228                 labelHashSet* setPtr
00229             );
00230 
00231             static bool checkFaceArea
00232             (
00233                 const bool report,
00234                 const scalar minArea,
00235                 const polyMesh&,
00236                 const vectorField& faceAreas,
00237                 const labelList& checkFaces,
00238                 labelHashSet* setPtr
00239             );
00240 
00241             static bool checkCellDeterminant
00242             (
00243                 const bool report,
00244                 const scalar minDet,
00245                 const polyMesh&,
00246                 const vectorField& faceAreas,
00247                 const labelList& checkFaces,
00248                 const labelList& affectedCells,
00249                 labelHashSet* setPtr
00250             );
00251 
00252 
00253         // Checking of selected faces with local geometry. Uses above static
00254         // functions. Parallel aware.
00255 
00256             bool checkFaceDotProduct
00257             (
00258                 const bool report,
00259                 const scalar orthWarn,
00260                 const labelList& checkFaces,
00261                 labelHashSet* setPtr
00262             ) const;
00263 
00264             bool checkFacePyramids
00265             (
00266                 const bool report,
00267                 const scalar minPyrVol,
00268                 const pointField& p,
00269                 const labelList& checkFaces,
00270                 labelHashSet* setPtr
00271             ) const;
00272 
00273             bool checkFaceSkewness
00274             (
00275                 const bool report,
00276                 const scalar internalSkew,
00277                 const scalar boundarySkew,
00278                 const labelList& checkFaces,
00279                 labelHashSet* setPtr
00280             ) const;
00281 
00282             bool checkFaceWeights
00283             (
00284                 const bool report,
00285                 const scalar warnWeight,
00286                 const labelList& checkFaces,
00287                 labelHashSet* setPtr
00288             ) const;
00289 
00290             bool checkFaceAngles
00291             (
00292                 const bool report,
00293                 const scalar maxDeg,
00294                 const pointField& p,
00295                 const labelList& checkFaces,
00296                 labelHashSet* setPtr
00297             ) const;
00298 
00299             bool checkFaceTwist
00300             (
00301                 const bool report,
00302                 const scalar minTwist,
00303                 const pointField& p,
00304                 const labelList& checkFaces,
00305                 labelHashSet* setPtr
00306             ) const;
00307 
00308             bool checkFaceArea
00309             (
00310                 const bool report,
00311                 const scalar minArea,
00312                 const labelList& checkFaces,
00313                 labelHashSet* setPtr
00314             ) const;
00315 
00316             bool checkCellDeterminant
00317             (
00318                 const bool report,
00319                 const scalar warnDet,
00320                 const labelList& checkFaces,
00321                 const labelList& affectedCells,
00322                 labelHashSet* setPtr
00323             ) const;
00324 };
00325 
00326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00327 
00328 } // End namespace Foam
00329 
00330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00331 
00332 #endif
00333 
00334 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd