checkMesh, functionObjects::checkMesh: Updated and made consistent

Now both the checkMesh utility and functionObject operate in the same manner
with the same controls, executing the same checkGeometry and checkTopology
functions from the new meshCheck library.  The controls have been updated and
made more consistent and flexible, in particular by the addition of optional
user specification for the non-orthogonality and skewness error thresholds:

Application
    checkMesh

Description
    Checks validity of a mesh.

Usage
    \b checkMesh [OPTION]

    Options:
      - \par noTopology
        Skip checking the mesh topology

      - \par -allTopology
        Check all (including non finite-volume specific) addressing

      - \par -allGeometry
        Check all (including non finite-volume specific) geometry

      - \par -meshQuality
        Check against user defined (in \a system/meshQualityDict) quality
        settings

      - \par -region \<name\>
        Specify an alternative mesh region.

      - \par -writeSurfaces
        Reconstruct cellSets and faceSets of problem faces and write to
        postProcessing directory.

      - \par -surfaceFormat <format>
        Format used to write the cellSets and faceSets surfaces
        e.g. vtk or ensight.

      - \par -writeSets
        Reconstruct pointSets of problem points nd write to
        postProcessing directory.

      - \par -setFormat <format>
        Format used to write the pointSets
        e.g. vtk or ensight.

      - \par -nonOrthThreshold <threshold value in degrees>
        Threshold in degrees for reporting non-orthogonality errors,
        default: 70"

      - \par -skewThreshold <threshold value>
        Threshold for reporting skewness errors, default: 4.

Class
    Foam::functionObjects::checkMesh

Description
    Executes primitiveMesh::checkMesh(true) every execute time for which the
    mesh changed, i.e. moved or changed topology.

    Useful to check the correctness of changing and morphing meshes.

Usage
    \table
        Property      | Description               | Required     | Default value
        type          | type name: checkMesh      | yes          |
        noTopology    | Skip checking the mesh topology | no     | false
        allTopology   | Check all addressing      | no           | false
        allGeometry   | Check all geometry        | no           | false
        writeSurfaces | Reconstruct and write problem faces | no | false
        surfaceFormat | Format for problem faceSets | no         | vtk
        writeSets     | Reconstruct and write problem points | no | false
        setFormat     | Format used to write the problem pointSets | no | vtk
        nonOrthThreshold | Threshold for non-orthogonality errors | no | 70 deg
        skewThreshold | Threshold for reporting skewness errors | no | 4
    \endtable

    Example of checkMesh specification:
    \verbatim
    checkMesh
    {
        type            checkMesh;
        libs            ("libutilityFunctionObjects.so");

        executeControl  timeStep;
        executeInterval 10;

        allGeometry     true;
        allTopology     true;

        writeSurfaces   true;
        surfaceFormat   vtk;

        writeSets       true;
        setFormat       vtk;
    }
    \endverbatim

    or using the standard configuration file:

    \verbatim
    #includeFunc checkMesh(executeInterval=10, allGeometry=true)
    \endverbatim
This commit is contained in:
Henry Weller
2023-10-24 14:36:35 +01:00
parent 819c9388f1
commit 4ab9979305
11 changed files with 278 additions and 90 deletions

View File

@ -1,7 +1,9 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshCheck/lnInclude
-I$(LIB_SRC)/meshCheck/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshCheck
-lmeshCheck \
-lsampling

View File

@ -26,6 +26,8 @@ License
#include "checkMesh.H"
#include "fvMesh.H"
#include "meshCheck.H"
#include "vtkSetWriter.H"
#include "vtkSurfaceWriter.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -63,11 +65,99 @@ Foam::functionObjects::checkMesh::~checkMesh()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::checkMesh::read(const dictionary& dict)
{
noTopology_ = dict.lookupOrDefault("noTopology", false);
allGeometry_ = dict.lookupOrDefault("allGeometry", false);
allTopology_ = dict.lookupOrDefault("allTopology", false);
writeSurfaces_ = dict.lookupOrDefault("writeSurfaces", false);
if (writeSurfaces_)
{
surfaceFormat_ = dict.lookupOrDefault<word>
(
"surfaceFormat",
vtkSurfaceWriter::typeName
);
}
writeSets_ = dict.lookupOrDefault("writeSets", false);
if (writeSets_)
{
setFormat_ = dict.lookupOrDefault<word>
(
"setFormat",
vtkSetWriter::typeName
);
}
nonOrthThreshold_ = dict.lookupOrDefault("nonOrthThreshold", 70.0);
skewThreshold_ = dict.lookupOrDefault("skewThreshold", 4.0);
return functionObject::read(dict);
}
bool Foam::functionObjects::checkMesh::execute()
{
if (mesh_.changing())
{
return meshCheck::checkMesh(mesh_, true);
autoPtr<surfaceWriter> surfWriter;
if (writeSurfaces_)
{
surfWriter = surfaceWriter::New
(
surfaceFormat_,
mesh_.time().writeFormat(),
mesh_.time().writeCompression()
);
}
autoPtr<setWriter> setWriter;
if (writeSets_)
{
setWriter = setWriter::New
(
setFormat_,
mesh_.time().writeFormat(),
mesh_.time().writeCompression()
);
}
label nFailedChecks = 0;
if (!noTopology_)
{
nFailedChecks += meshCheck::checkTopology
(
mesh_,
allTopology_,
surfWriter,
setWriter
);
}
nFailedChecks += meshCheck::checkGeometry
(
mesh_,
allGeometry_,
nonOrthThreshold_,
skewThreshold_,
surfWriter,
setWriter
);
if (nFailedChecks == 0)
{
Info<< "\n Mesh OK.\n" << endl;
}
else
{
Info<< "\n Failed " << nFailedChecks << " mesh checks.\n"
<< endl;
}
return nFailedChecks == 0;
}
else
{

View File

@ -30,6 +30,21 @@ Description
Useful to check the correctness of changing and morphing meshes.
Usage
\table
Property | Description | Required | Default value
type | type name: checkMesh | yes |
noTopology | Skip checking the mesh topology | no | false
allTopology | Check all addressing | no | false
allGeometry | Check all geometry | no | false
writeSurfaces | Reconstruct and write problem faces | no | false
surfaceFormat | Format for problem faceSets | no | vtk
writeSets | Reconstruct and write problem points | no | false
setFormat | Format used to write the problem pointSets | no | vtk
nonOrthThreshold | Threshold for non-orthogonality errors | no | 70 deg
skewThreshold | Threshold for reporting skewness errors | no | 4
\endtable
Example of checkMesh specification:
\verbatim
checkMesh
@ -39,11 +54,22 @@ Description
executeControl timeStep;
executeInterval 10;
allGeometry true;
allTopology true;
writeSurfaces true;
surfaceFormat vtk;
writeSets true;
setFormat vtk;
}
\endverbatim
or using the standard configuration file:
\verbatim
#includeFunc checkMesh(executeInterval=10)
#includeFunc checkMesh(executeInterval=10, allGeometry=true)
\endverbatim
SourceFiles
@ -73,6 +99,20 @@ class checkMesh
{
// Private Data
bool noTopology_;
bool allGeometry_;
bool allTopology_;
bool writeSurfaces_;
word surfaceFormat_;
bool writeSets_;
word setFormat_;
scalar nonOrthThreshold_;
scalar skewThreshold_;
public:
//- Runtime type information
@ -96,6 +136,9 @@ public:
// Member Functions
//- Read the checkMesh controls
virtual bool read(const dictionary&);
//- Return the list of fields required
virtual wordList fields() const
{