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

checkMesh.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 Application
00026     checkMesh
00027 
00028 Description
00029     Checks validity of a mesh
00030 
00031 \*---------------------------------------------------------------------------*/
00032 
00033 #include "argList.H"
00034 #include "timeSelector.H"
00035 #include "Time.H"
00036 
00037 #include "polyMesh.H"
00038 #include "globalMeshData.H"
00039 
00040 #include "printMeshStats.H"
00041 #include "checkTopology.H"
00042 #include "checkGeometry.H"
00043 
00044 using namespace Foam;
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 int main(int argc, char *argv[])
00049 {
00050     timeSelector::addOptions(false);   // no constant
00051 #   include "addRegionOption.H"
00052     argList::validOptions.insert("noTopology", "");
00053     argList::validOptions.insert("allGeometry", "");
00054     argList::validOptions.insert("allTopology", "");
00055 
00056 #   include "setRootCase.H"
00057 #   include "createTime.H"
00058     instantList timeDirs = timeSelector::select0(runTime, args);
00059 #   include "createNamedPolyMesh.H"
00060 
00061     const bool noTopology  = args.optionFound("noTopology");
00062     const bool allGeometry = args.optionFound("allGeometry");
00063     const bool allTopology = args.optionFound("allTopology");
00064 
00065     forAll(timeDirs, timeI)
00066     {
00067         runTime.setTime(timeDirs[timeI], timeI);
00068 
00069         polyMesh::readUpdateState state = mesh.readUpdate();
00070 
00071         if
00072         (
00073             !timeI
00074          || state == polyMesh::TOPO_CHANGE
00075          || state == polyMesh::TOPO_PATCH_CHANGE
00076         )
00077         {
00078             Info<< "Time = " << runTime.timeName() << nl << endl;
00079 
00080             // Clear mesh before checking
00081             mesh.clearOut();
00082 
00083             // Reconstruct globalMeshData
00084             mesh.globalData();
00085 
00086             printMeshStats(mesh, allTopology);
00087 
00088             label noFailedChecks = 0;
00089 
00090             if (!noTopology)
00091             {
00092                 noFailedChecks += checkTopology(mesh, allTopology, allGeometry);
00093             }
00094 
00095             noFailedChecks += checkGeometry(mesh, allGeometry);
00096 
00097             reduce(noFailedChecks, sumOp<label>());
00098 
00099             if (noFailedChecks == 0)
00100             {
00101                 Info<< "\nMesh OK.\n" << endl;
00102             }
00103             else
00104             {
00105                 Info<< "\nFailed " << noFailedChecks << " mesh checks.\n"
00106                     << endl;
00107             }
00108         }
00109         else if (state == polyMesh::POINTS_MOVED)
00110         {
00111             Info<< "Time = " << runTime.timeName() << nl << endl;
00112 
00113             label nFailedChecks = checkGeometry(mesh, allGeometry);
00114 
00115             reduce(nFailedChecks, sumOp<label>());
00116 
00117             if (nFailedChecks)
00118             {
00119                 Info<< "\nFailed " << nFailedChecks << " mesh checks.\n"
00120                     << endl;
00121             }
00122             else
00123             {
00124                 Info << "\nMesh OK.\n" << endl;
00125             }
00126         }
00127     }
00128 
00129     Info<< "End\n" << endl;
00130 
00131     return 0;
00132 }
00133 
00134 
00135 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd