initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / mesh / manipulation / checkMesh.save / checkMesh.C
blobec598b4c215b45114ed9e9dc7268582c6d688dc5
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 Application
26     checkMesh
28 Description
29     Checks validity of a mesh
31 \*---------------------------------------------------------------------------*/
33 #include "argList.H"
34 #include "Time.H"
35 #include "polyMesh.H"
36 #include "globalMeshData.H"
38 #include "printMeshStats.H"
39 #include "checkTopology.H"
40 #include "checkGeometry.H"
42 using namespace Foam;
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 int main(int argc, char *argv[])
49 #   include "addTimeOptionsNoConstant.H"
51     argList::validOptions.insert("fullTopology", "");
52     argList::validOptions.insert("pointNearness", "");
53     argList::validOptions.insert("cellDeterminant", "");
55 #   include "setRootCase.H"
56 #   include "createTime.H"
58     // Get times list
59     instantList Times = runTime.times();
61 #   include "checkTimeOptionsNoConstant.H"
63     runTime.setTime(Times[startTime], startTime);
65 #   include "createPolyMesh.H"
67     bool firstCheck = true;
69     for (label i=startTime; i<endTime; i++)
70     {
71         runTime.setTime(Times[i], i);
73         polyMesh::readUpdateState state = mesh.readUpdate();
75         if
76         (
77             firstCheck
78          || state == polyMesh::TOPO_CHANGE
79          || state == polyMesh::TOPO_PATCH_CHANGE
80         )
81         {
82             firstCheck = false;
84             Info<< "Time = " << runTime.timeName() << nl << endl;
86             // Clear mesh before checking
87             mesh.clearOut();
89             // Reconstruct globalMeshData
90             mesh.globalData();
92             printMeshStats(mesh);
94             label noFailedChecks = 0;
96             noFailedChecks += checkTopology
97             (
98                 mesh,
99                 args.options().found("fullTopology")
100             );
102             noFailedChecks += checkGeometry
103             (
104                 mesh,
105                 args.options().found("pointNearness"),
106                 args.options().found("cellDeterminant")
107             );
109             reduce(noFailedChecks, sumOp<label>());
111             if (noFailedChecks == 0)
112             {
113                 Info<< "\nMesh OK."
114                     << nl << endl;
115             }
116             else
117             {
118                 Info<< "\nFailed " << noFailedChecks << " mesh checks."
119                     << nl << endl;
120             }
121         }
122         else if (state == polyMesh::POINTS_MOVED)
123         {
124             label noFailedChecks = checkGeometry
125             (
126                 mesh,
127                 args.options().found("pointNearness"),
128                 args.options().found("cellDeterminant")
129             );
131             reduce(noFailedChecks, sumOp<label>());
133             if (noFailedChecks == 0)
134             {
135                 Info << "\nMesh OK."
136                     << nl << endl;
137             }
138             else
139             {
140                 Info<< "\nFailed " << noFailedChecks << " mesh checks."
141                     << nl << endl;
142             }
143         }
144     }
146     Info<< "End\n" << endl;
148     return(0);
152 // ************************************************************************* //