FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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