From 62a203c9db6fb0052a8aeb5606650a32e811a42e Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 16 May 2012 11:12:49 +0100 Subject: [PATCH] ENH: checkMesh: add meshQualityDict option --- .../mesh/manipulation/checkMesh/Make/files | 1 + .../mesh/manipulation/checkMesh/Make/options | 6 +- .../mesh/manipulation/checkMesh/checkMesh.C | 87 +++++++++++++++++-- .../manipulation/checkMesh/checkMeshQuality.C | 34 ++++++++ .../manipulation/checkMesh/checkMeshQuality.H | 6 ++ 5 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C create mode 100644 applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H diff --git a/applications/utilities/mesh/manipulation/checkMesh/Make/files b/applications/utilities/mesh/manipulation/checkMesh/Make/files index f0b7c16694..1a3130a23c 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/Make/files +++ b/applications/utilities/mesh/manipulation/checkMesh/Make/files @@ -1,6 +1,7 @@ printMeshStats.C checkTopology.C checkGeometry.C +checkMeshQuality.C checkMesh.C EXE = $(FOAM_APPBIN)/checkMesh diff --git a/applications/utilities/mesh/manipulation/checkMesh/Make/options b/applications/utilities/mesh/manipulation/checkMesh/Make/options index 54c035b8f5..70c838b774 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/Make/options +++ b/applications/utilities/mesh/manipulation/checkMesh/Make/options @@ -1,5 +1,7 @@ EXE_INC = \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude EXE_LIBS = \ - -lmeshTools + -lmeshTools \ + -ldynamicMesh diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C index 3f0ae4589c..dc400f5f41 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.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 @@ -27,6 +27,21 @@ Application Description Checks validity of a mesh +Usage + - checkMesh [OPTION] + + \param -allGeometry \n + Checks all (including non finite-volume specific) geometry + + \param -allTopology \n + Checks all (including non finite-volume specific) addressing + + \param -meshQualityDict \n + Checks against user defined (in \a system/meshQualityDict) quality settings + + \param -region \ \n + Specify an alternative mesh region. + \*---------------------------------------------------------------------------*/ #include "argList.H" @@ -39,6 +54,7 @@ Description #include "printMeshStats.H" #include "checkTopology.H" #include "checkGeometry.H" +#include "checkMeshQuality.H" using namespace Foam; @@ -63,6 +79,11 @@ int main(int argc, char *argv[]) "allTopology", "include extra topology checks" ); + argList::addBoolOption + ( + "meshQualityDict", + "read user-defined mesh quality criterions from system/meshQualityDict" + ); # include "setRootCase.H" # include "createTime.H" @@ -72,6 +93,46 @@ int main(int argc, char *argv[]) const bool noTopology = args.optionFound("noTopology"); const bool allGeometry = args.optionFound("allGeometry"); const bool allTopology = args.optionFound("allTopology"); + const bool meshQualityDict = args.optionFound("meshQualityDict"); + + if (noTopology) + { + Info<< "Disabling all topology checks." << nl << endl; + } + if (allTopology) + { + Info<< "Enabling all (cell, face, edge, point) topology checks." + << nl << endl; + } + if (allGeometry) + { + Info<< "Enabling all geometry checks." << nl << endl; + } + if (meshQualityDict) + { + Info<< "Enabling user-defined geometry checks." << nl << endl; + } + + + autoPtr qualDict; + if (meshQualityDict) + { + qualDict.reset + ( + new IOdictionary + ( + IOobject + ( + "meshQualityDict", + mesh.time().system(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ) + ); + } + forAll(timeDirs, timeI) { @@ -96,25 +157,31 @@ int main(int argc, char *argv[]) printMeshStats(mesh, allTopology); - label noFailedChecks = 0; + label nFailedChecks = 0; if (!noTopology) { - noFailedChecks += checkTopology(mesh, allTopology, allGeometry); + nFailedChecks += checkTopology(mesh, allTopology, allGeometry); } - noFailedChecks += checkGeometry(mesh, allGeometry); + nFailedChecks += checkGeometry(mesh, allGeometry); - // Note: no reduction in noFailedChecks necessary since is + if (meshQualityDict) + { + nFailedChecks += checkMeshQuality(mesh, qualDict()); + } + + + // Note: no reduction in nFailedChecks necessary since is // counter of checks, not counter of failed cells,faces etc. - if (noFailedChecks == 0) + if (nFailedChecks == 0) { Info<< "\nMesh OK.\n" << endl; } else { - Info<< "\nFailed " << noFailedChecks << " mesh checks.\n" + Info<< "\nFailed " << nFailedChecks << " mesh checks.\n" << endl; } } @@ -124,6 +191,12 @@ int main(int argc, char *argv[]) label nFailedChecks = checkGeometry(mesh, allGeometry); + if (meshQualityDict) + { + nFailedChecks += checkMeshQuality(mesh, qualDict()); + } + + if (nFailedChecks) { Info<< "\nFailed " << nFailedChecks << " mesh checks.\n" diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C new file mode 100644 index 0000000000..b00f02f8ef --- /dev/null +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C @@ -0,0 +1,34 @@ +#include "checkMeshQuality.H" +#include "polyMesh.H" +#include "cellSet.H" +#include "faceSet.H" +#include "motionSmoother.H" + + +Foam::label Foam::checkMeshQuality +( + const polyMesh& mesh, + const dictionary& dict +) +{ + label noFailedChecks = 0; + + { + faceSet faces(mesh, "meshQualityFaces", mesh.nFaces()/100+1); + motionSmoother::checkMesh(false, mesh, dict, faces); + + label nFaces = returnReduce(faces.size(), sumOp