diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index d3627791c1d3d205eb15fdf8046505d8f8823088..40adb83035b70fa2b02bf9a154e265e81f06c132 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,6 +46,8 @@ Description #include "snapParameters.H" #include "layerParameters.H" +#include "faceSet.H" +#include "motionSmoother.H" using namespace Foam; @@ -122,6 +124,13 @@ int main(int argc, char *argv[]) { # include "addOverwriteOption.H" + Foam::argList::addBoolOption + ( + "checkOnly", + "check existing mesh against snappyHexMeshDict settings" + ); + + # include "setRootCase.H" # include "createTime.H" runTime.functionObjects().off(); @@ -132,24 +141,13 @@ int main(int argc, char *argv[]) const bool overwrite = args.optionFound("overwrite"); + const bool checkOnly = args.optionFound("checkOnly"); + // Check patches and faceZones are synchronised mesh.boundaryMesh().checkParallelSync(true); meshRefinement::checkCoupledFaceZones(mesh); - // Read decomposePar dictionary - IOdictionary decomposeDict - ( - IOobject - ( - "decomposeParDict", - runTime.system(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ) - ); - // Read meshing dictionary IOdictionary meshDict ( @@ -186,6 +184,51 @@ int main(int argc, char *argv[]) ); + if (checkOnly) + { + Info<< "Checking initial mesh ..." << endl; + faceSet wrongFaces(mesh, "wrongFaces", mesh.nFaces()/100); + motionSmoother::checkMesh(false, mesh, motionDict, wrongFaces); + + const label nInitErrors = returnReduce + ( + wrongFaces.size(), + sumOp<label>() + ); + + Info<< "Detected " << nInitErrors << " illegal faces" + << " (concave, zero area or negative cell pyramid volume)" + << endl; + + if (nInitErrors > 0) + { + Info<< "Writing " << nInitErrors + << " faces in error to set " + << wrongFaces.name() << endl; + wrongFaces.instance() = mesh.pointsInstance(); + wrongFaces.write(); + } + + Info<< "End\n" << endl; + + return 0; + } + + + // Read decomposePar dictionary + IOdictionary decomposeDict + ( + IOobject + ( + "decomposeParDict", + runTime.system(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + + // Debug // ~~~~~