From 1630b2df9e1e13685de24e9d1a844e8d57182440 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Fri, 3 Feb 2012 12:47:43 +0000 Subject: [PATCH] ENH: snappyHexMesh: added option to check mesh --- .../generation/snappyHexMesh/snappyHexMesh.C | 71 +++++++++++++++---- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index d3627791c1d..40adb83035b 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 // ~~~~~ -- GitLab