FreeFOAM The Cross-Platform CFD Toolkit
checkBlockMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "blockMesh.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 // Check the blockMesh topology
33 void Foam::blockMesh::checkBlockMesh(const polyMesh& bm)
34 {
35  Info<< nl << "Check block mesh topology" << endl;
36 
37  bool blockMeshOK = true;
38 
39  const pointField& points = bm.points();
40  const faceList& faces = bm.faces();
41  const cellList& cells = bm.cells();
42  const polyPatchList& patches = bm.boundaryMesh();
43 
44  label nBoundaryFaces=0;
45  forAll(cells, celli)
46  {
47  nBoundaryFaces += cells[celli].nFaces();
48  }
49 
50  nBoundaryFaces -= 2*bm.nInternalFaces();
51 
52  label nDefinedBoundaryFaces=0;
53  forAll(patches, patchi)
54  {
55  nDefinedBoundaryFaces += patches[patchi].size();
56  }
57 
58 
59  Info<< nl << tab << "Basic statistics" << endl;
60 
61  Info<< tab << tab << "Number of internal faces : "
62  << bm.nInternalFaces() << endl;
63 
64  Info<< tab << tab << "Number of boundary faces : "
65  << nBoundaryFaces << endl;
66 
67  Info<< tab << tab << "Number of defined boundary faces : "
68  << nDefinedBoundaryFaces << endl;
69 
70  Info<< tab << tab << "Number of undefined boundary faces : "
71  << nBoundaryFaces - nDefinedBoundaryFaces << endl;
72 
73  if ((nBoundaryFaces - nDefinedBoundaryFaces) > 0)
74  {
75  Info<< tab << tab << tab
76  << "(Warning : only leave undefined the front and back planes "
77  << "of 2D planar geometries!)" << endl;
78  }
79 
80  Info<< nl << tab << "Checking patch -> block consistency" << endl;
81 
82 
83  forAll(patches, patchi)
84  {
85  const faceList& Patch = patches[patchi];
86 
87  forAll(Patch, patchFacei)
88  {
89  const face& patchFace = Patch[patchFacei];
90  bool patchFaceOK = false;
91 
92  forAll(cells, celli)
93  {
94  const labelList& cellFaces = cells[celli];
95 
96  forAll(cellFaces, cellFacei)
97  {
98  if (patchFace == faces[cellFaces[cellFacei]])
99  {
100  patchFaceOK = true;
101 
102  if
103  (
104  (
105  patchFace.normal(points)
106  & faces[cellFaces[cellFacei]].normal(points)
107  ) < 0.0
108  )
109  {
110  Info<< tab << tab
111  << "Face " << patchFacei
112  << " of patch " << patchi
113  << " (" << patches[patchi].name() << ")"
114  << " points inwards"
115  << endl;
116 
117  blockMeshOK = false;
118  }
119  }
120  }
121  }
122 
123  if (!patchFaceOK)
124  {
125  Info<< tab << tab
126  << "Face " << patchFacei
127  << " of patch " << patchi
128  << " (" << patches[patchi].name() << ")"
129  << " does not match any block faces" << endl;
130 
131  blockMeshOK = false;
132  }
133  }
134  }
135 
136  if (!blockMeshOK)
137  {
138  FatalErrorIn("blockMesh::checkBlockMesh(const polyMesh& bm)")
139  << "Block mesh topology incorrect, stopping mesh generation!"
140  << exit(FatalError);
141  }
142 }
143 
144 // ************************ vim: set sw=4 sts=4 et: ************************ //