From 1177dbd111e2aafdbe5f47b4d01946138df29119 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 21 Apr 2021 17:22:41 +0100 Subject: [PATCH] ENH: checkMesh: -allRegions. See #2072 --- .../mesh/manipulation/checkMesh/checkMesh.C | 192 ++- .../mesh/manipulation/checkMesh/checkTools.C | 14 +- .../manipulation/renumberMesh/renumberMesh.C | 1406 +++++++++-------- .../polyMesh/polyMeshCheck/polyMeshTools.C | 32 + .../polyMesh/polyMeshCheck/polyMeshTools.H | 8 + 5 files changed, 872 insertions(+), 780 deletions(-) diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C index c68bf78709..14e91bd7dd 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C @@ -50,6 +50,9 @@ Usage - \par -region \ Specify an alternative mesh region. + - \par -allRegions + Check all regions in regionProperties. + \param -writeSets \ \n Reconstruct all cellSets and faceSets geometry and write to postProcessing directory according to surfaceFormat (e.g. vtk or ensight). Additionally @@ -74,6 +77,8 @@ Usage #include "vtkSetWriter.H" #include "vtkSurfaceWriter.H" #include "IOdictionary.H" +#include "regionProperties.H" +#include "polyMeshTools.H" #include "checkTools.H" #include "checkTopology.H" @@ -93,7 +98,8 @@ int main(int argc, char *argv[]) ); timeSelector::addOptions(); - #include "addRegionOption.H" + #include "addAllRegionOptions.H" + argList::addBoolOption ( "noTopology", @@ -139,8 +145,9 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" + #include "getAllRegionOptions.H" instantList timeDirs = timeSelector::select0(runTime, args); - #include "createNamedMesh.H" + #include "createNamedMeshes.H" const bool noTopology = args.found("noTopology"); const bool allGeometry = args.found("allGeometry"); @@ -230,23 +237,27 @@ int main(int argc, char *argv[]) } - autoPtr qualDict; + PtrList qualDict(meshes.size()); if (meshQuality) { - qualDict.reset - ( - new IOdictionary + forAll(meshes, meshi) + { + qualDict.set ( - IOobject + meshi, + new IOdictionary ( - "meshQualityDict", - mesh.time().system(), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE + IOobject + ( + "meshQualityDict", + meshes[meshi].time().system(), + meshes[meshi], + IOobject::MUST_READ, + IOobject::NO_WRITE + ) ) - ) - ); + ); + } } @@ -263,7 +274,13 @@ int main(int argc, char *argv[]) { runTime.setTime(timeDirs[timeI], timeI); - polyMesh::readUpdateState state = mesh.readUpdate(); + // Get most changed of all meshes + polyMesh::readUpdateState state = polyMesh::UNCHANGED; + for (auto& mesh : meshes) + { + state = polyMeshTools::combine(state, mesh.readUpdate()); + } + if ( @@ -274,87 +291,100 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; - // Reconstruct globalMeshData - mesh.globalData(); - - printMeshStats(mesh, allTopology); - - label nFailedChecks = 0; - - if (!noTopology) + forAll(meshes, meshi) { - nFailedChecks += checkTopology + const auto& mesh = meshes[meshi]; + + // Reconstruct globalMeshData + mesh.globalData(); + + printMeshStats(mesh, allTopology); + + label nFailedChecks = 0; + + if (!noTopology) + { + nFailedChecks += checkTopology + ( + mesh, + allTopology, + allGeometry, + surfWriter, + setWriter + ); + } + + nFailedChecks += checkGeometry ( mesh, - allTopology, allGeometry, surfWriter, setWriter ); + + if (meshQuality) + { + nFailedChecks += + checkMeshQuality(mesh, qualDict[meshi], surfWriter); + } + + + // Note: no reduction in nFailedChecks necessary since is + // counter of checks, not counter of failed cells,faces + // etc. + + if (nFailedChecks == 0) + { + Info<< "\nMesh OK.\n" << endl; + } + else + { + Info<< "\nFailed " << nFailedChecks << " mesh checks.\n" + << endl; + } + + + // Write selected fields + Foam::writeFields(mesh, selectedFields, writeFaceFields); } - - nFailedChecks += checkGeometry - ( - mesh, - allGeometry, - surfWriter, - setWriter - ); - - if (meshQuality) - { - nFailedChecks += checkMeshQuality(mesh, qualDict(), surfWriter); - } - - - // Note: no reduction in nFailedChecks necessary since is - // counter of checks, not counter of failed cells,faces etc. - - if (nFailedChecks == 0) - { - Info<< "\nMesh OK.\n" << endl; - } - else - { - Info<< "\nFailed " << nFailedChecks << " mesh checks.\n" - << endl; - } - - - // Write selected fields - Foam::writeFields(mesh, selectedFields, writeFaceFields); } else if (state == polyMesh::POINTS_MOVED) { Info<< "Time = " << runTime.timeName() << nl << endl; - label nFailedChecks = checkGeometry - ( - mesh, - allGeometry, - surfWriter, - setWriter - ); - - if (meshQuality) + forAll(meshes, meshi) { - nFailedChecks += checkMeshQuality(mesh, qualDict(), surfWriter); + const auto& mesh = meshes[meshi]; + + label nFailedChecks = checkGeometry + ( + mesh, + allGeometry, + surfWriter, + setWriter + ); + + if (meshQuality) + { + nFailedChecks += + checkMeshQuality(mesh, qualDict[meshi], surfWriter); + } + + + if (nFailedChecks) + { + Info<< "\nFailed " << nFailedChecks << " mesh checks.\n" + << endl; + } + else + { + Info<< "\nMesh OK.\n" << endl; + } + + + // Write selected fields + Foam::writeFields(mesh, selectedFields, writeFaceFields); } - - - if (nFailedChecks) - { - Info<< "\nFailed " << nFailedChecks << " mesh checks.\n" - << endl; - } - else - { - Info<< "\nMesh OK.\n" << endl; - } - - - // Write selected fields - Foam::writeFields(mesh, selectedFields, writeFaceFields); } } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C index ad29e420dc..80cc521258 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2017 OpenFOAM Foundation - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,10 +50,18 @@ License void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) { - Info<< "Mesh stats" << nl - << " points: " + if (mesh.name() == Foam::polyMesh::defaultRegion) + { + Info<< "Mesh stats" << nl; + } + else + { + Info<< "Mesh " << mesh.name() << " stats" << nl; + } + Info<< " points: " << returnReduce(mesh.points().size(), sumOp