initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / mesh / generation / blockMesh / checkBlockMesh.C
blob3abb4a6c71fa83a68a620f52ac034baf16297447
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
27 \*---------------------------------------------------------------------------*/
29 #include "blockMesh.H"
31 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
33 // Check the blockMesh topology
34 void Foam::blockMesh::checkBlockMesh(const polyMesh& bm)
36     Info<< nl << "Check block mesh topology" << endl;
38     bool blockMeshOK = true;
40     const pointField& points = bm.points();
41     const faceList& faces = bm.faces();
42     const cellList& cells = bm.cells();
43     const polyPatchList& patches = bm.boundaryMesh();
45     label nBoundaryFaces=0;
46     forAll(cells, celli)
47     {
48         nBoundaryFaces += cells[celli].nFaces();
49     }
51     nBoundaryFaces -= 2*bm.nInternalFaces();
53     label nDefinedBoundaryFaces=0;
54     forAll(patches, patchi)
55     {
56         nDefinedBoundaryFaces += patches[patchi].size();
57     }
60     Info<< nl << tab << "Basic statistics" << endl;
62     Info<< tab << tab << "Number of internal faces : "
63         << bm.nInternalFaces() << endl;
65     Info<< tab << tab << "Number of boundary faces : "
66         << nBoundaryFaces << endl;
68     Info<< tab << tab << "Number of defined boundary faces : "
69         << nDefinedBoundaryFaces << endl;
71     Info<< tab << tab << "Number of undefined boundary faces : "
72         << nBoundaryFaces - nDefinedBoundaryFaces << endl;
74     if ((nBoundaryFaces - nDefinedBoundaryFaces) > 0)
75     {
76         Info<< tab << tab << tab
77             << "(Warning : only leave undefined the front and back planes "
78             << "of 2D planar geometries!)" << endl;
79     }
81     Info<< nl << tab << "Checking patch -> block consistency" << endl;
84     forAll(patches, patchi)
85     {
86         const faceList& Patch = patches[patchi];
88         forAll(Patch, patchFacei)
89         {
90             const face& patchFace = Patch[patchFacei];
91             bool patchFaceOK = false;
93             forAll(cells, celli)
94             {
95                 const labelList& cellFaces = cells[celli];
97                 forAll(cellFaces, cellFacei)
98                 {
99                     if (patchFace == faces[cellFaces[cellFacei]])
100                     {
101                         patchFaceOK = true;
103                         if
104                         (
105                             (
106                                 patchFace.normal(points)
107                               & faces[cellFaces[cellFacei]].normal(points)
108                             ) < 0.0
109                         )
110                         {
111                             Info<< tab << tab
112                                 << "Face " << patchFacei
113                                 << " of patch " << patchi
114                                 << " (" << patches[patchi].name() << ")"
115                                 << " points inwards"
116                                 << endl;
118                             blockMeshOK = false;
119                         }
120                     }
121                 }
122             }
124             if (!patchFaceOK)
125             {
126                 Info<< tab << tab
127                     << "Face " << patchFacei
128                     << " of patch " << patchi
129                     << " (" << patches[patchi].name() << ")"
130                     << " does not match any block faces" << endl;
132                 blockMeshOK = false;
133             }
134         }
135     }
137     if (!blockMeshOK)
138     {
139         FatalErrorIn("blockMesh::checkBlockMesh(const polyMesh& bm)")
140             << "Block mesh topology incorrect, stopping mesh generation!"
141             << exit(FatalError);
142     }
145 // ************************************************************************* //