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

checkBlockMesh.C

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 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "blockMesh.H"
00030 
00031 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00032 
00033 // Check the blockMesh topology
00034 void Foam::blockMesh::checkBlockMesh(const polyMesh& bm)
00035 {
00036     Info<< nl << "Check block mesh topology" << endl;
00037 
00038     bool blockMeshOK = true;
00039 
00040     const pointField& points = bm.points();
00041     const faceList& faces = bm.faces();
00042     const cellList& cells = bm.cells();
00043     const polyPatchList& patches = bm.boundaryMesh();
00044 
00045     label nBoundaryFaces=0;
00046     forAll(cells, celli)
00047     {
00048         nBoundaryFaces += cells[celli].nFaces();
00049     }
00050 
00051     nBoundaryFaces -= 2*bm.nInternalFaces();
00052 
00053     label nDefinedBoundaryFaces=0;
00054     forAll(patches, patchi)
00055     {
00056         nDefinedBoundaryFaces += patches[patchi].size();
00057     }
00058 
00059 
00060     Info<< nl << tab << "Basic statistics" << endl;
00061 
00062     Info<< tab << tab << "Number of internal faces : "
00063         << bm.nInternalFaces() << endl;
00064 
00065     Info<< tab << tab << "Number of boundary faces : "
00066         << nBoundaryFaces << endl;
00067 
00068     Info<< tab << tab << "Number of defined boundary faces : "
00069         << nDefinedBoundaryFaces << endl;
00070 
00071     Info<< tab << tab << "Number of undefined boundary faces : "
00072         << nBoundaryFaces - nDefinedBoundaryFaces << endl;
00073 
00074     if ((nBoundaryFaces - nDefinedBoundaryFaces) > 0)
00075     {
00076         Info<< tab << tab << tab
00077             << "(Warning : only leave undefined the front and back planes "
00078             << "of 2D planar geometries!)" << endl;
00079     }
00080 
00081     Info<< nl << tab << "Checking patch -> block consistency" << endl;
00082 
00083 
00084     forAll(patches, patchi)
00085     {
00086         const faceList& Patch = patches[patchi];
00087 
00088         forAll(Patch, patchFacei)
00089         {
00090             const face& patchFace = Patch[patchFacei];
00091             bool patchFaceOK = false;
00092 
00093             forAll(cells, celli)
00094             {
00095                 const labelList& cellFaces = cells[celli];
00096 
00097                 forAll(cellFaces, cellFacei)
00098                 {
00099                     if (patchFace == faces[cellFaces[cellFacei]])
00100                     {
00101                         patchFaceOK = true;
00102 
00103                         if
00104                         (
00105                             (
00106                                 patchFace.normal(points)
00107                               & faces[cellFaces[cellFacei]].normal(points)
00108                             ) < 0.0
00109                         )
00110                         {
00111                             Info<< tab << tab
00112                                 << "Face " << patchFacei
00113                                 << " of patch " << patchi
00114                                 << " (" << patches[patchi].name() << ")"
00115                                 << " points inwards"
00116                                 << endl;
00117 
00118                             blockMeshOK = false;
00119                         }
00120                     }
00121                 }
00122             }
00123 
00124             if (!patchFaceOK)
00125             {
00126                 Info<< tab << tab
00127                     << "Face " << patchFacei
00128                     << " of patch " << patchi
00129                     << " (" << patches[patchi].name() << ")"
00130                     << " does not match any block faces" << endl;
00131 
00132                 blockMeshOK = false;
00133             }
00134         }
00135     }
00136 
00137     if (!blockMeshOK)
00138     {
00139         FatalErrorIn("blockMesh::checkBlockMesh(const polyMesh& bm)")
00140             << "Block mesh topology incorrect, stopping mesh generation!"
00141             << exit(FatalError);
00142     }
00143 }
00144 
00145 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd