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

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-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 Application
00025     checkMesh
00026 
00027 Description
00028     Checks validity of a mesh
00029 
00030 Usage
00031 
00032     - checkMesh [OPTIONS]
00033 
00034     @param -noTopology \n
00035     Do not check mesh-topology.
00036 
00037     @param -allTopology \n
00038     More extensive topology checks.
00039 
00040     @param -allGeometry \n
00041     More extensive geometry checks.
00042 
00043     @param -region <name>\n
00044     Only apply to named mesh region.
00045 
00046     @param -latestTime \n
00047     Only apply to latest time step.
00048 
00049     @param -time <time>\n
00050     Apply only to specific time.
00051 
00052     @param -case <dir>\n
00053     Case directory.
00054 
00055     @param -parallel \n
00056     Run in parallel.
00057 
00058     @param -help \n
00059     Display help message.
00060 
00061     @param -doc \n
00062     Display Doxygen API documentation page for this application.
00063 
00064     @param -srcDoc \n
00065     Display Doxygen source documentation page for this application.
00066 
00067 \*---------------------------------------------------------------------------*/
00068 
00069 #include <OpenFOAM/argList.H>
00070 #include <OpenFOAM/timeSelector.H>
00071 #include <OpenFOAM/Time.H>
00072 
00073 #include <OpenFOAM/polyMesh.H>
00074 #include <OpenFOAM/globalMeshData.H>
00075 
00076 #include "printMeshStats.H"
00077 #include "checkTopology.H"
00078 #include "checkGeometry.H"
00079 
00080 using namespace Foam;
00081 
00082 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00083 
00084 int main(int argc, char *argv[])
00085 {
00086     timeSelector::addOptions();
00087 #   include <OpenFOAM/addRegionOption.H>
00088     argList::validOptions.insert("noTopology", "");
00089     argList::validOptions.insert("allGeometry", "");
00090     argList::validOptions.insert("allTopology", "");
00091 
00092 #   include <OpenFOAM/setRootCase.H>
00093 #   include <OpenFOAM/createTime.H>
00094     instantList timeDirs = timeSelector::select0(runTime, args);
00095 #   include <OpenFOAM/createNamedPolyMesh.H>
00096 
00097     const bool noTopology  = args.optionFound("noTopology");
00098     const bool allGeometry = args.optionFound("allGeometry");
00099     const bool allTopology = args.optionFound("allTopology");
00100 
00101     forAll(timeDirs, timeI)
00102     {
00103         runTime.setTime(timeDirs[timeI], timeI);
00104 
00105         polyMesh::readUpdateState state = mesh.readUpdate();
00106 
00107         if
00108         (
00109             !timeI
00110          || state == polyMesh::TOPO_CHANGE
00111          || state == polyMesh::TOPO_PATCH_CHANGE
00112         )
00113         {
00114             Info<< "Time = " << runTime.timeName() << nl << endl;
00115 
00116             // Clear mesh before checking
00117             mesh.clearOut();
00118 
00119             // Reconstruct globalMeshData
00120             mesh.globalData();
00121 
00122             printMeshStats(mesh, allTopology);
00123 
00124             label noFailedChecks = 0;
00125 
00126             if (!noTopology)
00127             {
00128                 noFailedChecks += checkTopology(mesh, allTopology, allGeometry);
00129             }
00130 
00131             noFailedChecks += checkGeometry(mesh, allGeometry);
00132 
00133             // Note: no reduction in noFailedChecks necessary since is
00134             //       counter of checks, not counter of failed cells,faces etc.
00135 
00136             if (noFailedChecks == 0)
00137             {
00138                 Info<< "\nMesh OK.\n" << endl;
00139             }
00140             else
00141             {
00142                 Info<< "\nFailed " << noFailedChecks << " mesh checks.\n"
00143                     << endl;
00144             }
00145         }
00146         else if (state == polyMesh::POINTS_MOVED)
00147         {
00148             Info<< "Time = " << runTime.timeName() << nl << endl;
00149 
00150             label nFailedChecks = checkGeometry(mesh, allGeometry);
00151 
00152             if (nFailedChecks)
00153             {
00154                 Info<< "\nFailed " << nFailedChecks << " mesh checks.\n"
00155                     << endl;
00156             }
00157             else
00158             {
00159                 Info << "\nMesh OK.\n" << endl;
00160             }
00161         }
00162     }
00163 
00164     Info<< "End\n" << endl;
00165 
00166     return 0;
00167 }
00168 
00169 
00170 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines