From 61dd6252276cf325e56356476c31479d306c9f9e Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 23 Nov 2015 15:24:33 +0000 Subject: [PATCH] ENH: checkMesh: have -writeSets option - checkMesh has option to write faceSets or (outside of) cellSets as sampledSurface format. It automatically reconstructs the set on the master and writes it to the postProcessing folder (as any sampledSurface). E.g. mpirun -np 6 checkMesh -allTopology -allGeometry -writeSets vtk -parallel - fixed order writing of symmTensor in Ensight writers --- .../mesh/manipulation/checkMesh/Make/files | 2 +- .../mesh/manipulation/checkMesh/Make/options | 4 + .../manipulation/checkMesh/checkGeometry.C | 69 ++- .../manipulation/checkMesh/checkGeometry.H | 8 +- .../mesh/manipulation/checkMesh/checkMesh.C | 48 ++- .../manipulation/checkMesh/checkMeshQuality.C | 10 +- .../manipulation/checkMesh/checkMeshQuality.H | 9 +- .../mesh/manipulation/checkMesh/checkTools.C | 397 ++++++++++++++++++ .../mesh/manipulation/checkMesh/checkTools.H | 19 + .../manipulation/checkMesh/checkTopology.C | 96 ++++- .../manipulation/checkMesh/checkTopology.H | 11 +- .../manipulation/checkMesh/printMeshStats.C | 170 -------- .../manipulation/checkMesh/printMeshStats.H | 6 - .../dataConversion/foamToEnsight/Make/options | 5 +- .../foamToEnsight/ensightCloudField.C | 7 +- .../foamToEnsight/ensightField.C | 90 +++- .../foamToEnsight/ensightField.H | 15 + .../foamToEnsight/ensightMesh.C | 4 +- .../foamToEnsight/foamToEnsight.C | 126 +++++- .../foamToEnsightParts/Make/options | 2 + src/fileFormats/Make/files | 1 + .../ensight/ensightPTraits.C | 39 +- .../ensight/ensightPTraits.H | 60 ++- .../ensight/ensightSetWriter.C | 27 +- src/sampling/Make/files | 1 - .../boundaryData/boundaryDataSurfaceWriter.H | 3 +- 26 files changed, 976 insertions(+), 253 deletions(-) create mode 100644 applications/utilities/mesh/manipulation/checkMesh/checkTools.C create mode 100644 applications/utilities/mesh/manipulation/checkMesh/checkTools.H delete mode 100644 applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C delete mode 100644 applications/utilities/mesh/manipulation/checkMesh/printMeshStats.H rename src/{sampling/sampledSurface/writers => fileFormats/sampledSetWriters}/ensight/ensightPTraits.C (72%) rename src/{sampling/sampledSurface/writers => fileFormats/sampledSetWriters}/ensight/ensightPTraits.H (68%) diff --git a/applications/utilities/mesh/manipulation/checkMesh/Make/files b/applications/utilities/mesh/manipulation/checkMesh/Make/files index 1a3130a23c..21febe2789 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/Make/files +++ b/applications/utilities/mesh/manipulation/checkMesh/Make/files @@ -1,4 +1,4 @@ -printMeshStats.C +checkTools.C checkTopology.C checkGeometry.C checkMeshQuality.C diff --git a/applications/utilities/mesh/manipulation/checkMesh/Make/options b/applications/utilities/mesh/manipulation/checkMesh/Make/options index 2ff5dbabfe..4700e225a5 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/Make/options +++ b/applications/utilities/mesh/manipulation/checkMesh/Make/options @@ -1,8 +1,12 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude EXE_LIBS = \ -lmeshTools \ + -lsampling \ + -lsurfMesh \ -ldynamicMesh diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index 68c316f24d..320319cac7 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -7,6 +7,8 @@ #include "wedgePolyPatch.H" #include "unitConversion.H" #include "polyMeshTetDecomposition.H" +#include "surfaceWriter.H" +#include "checkTools.H" // Find wedge with opposite orientation. Note: does not actually check that @@ -477,7 +479,12 @@ bool Foam::checkCoupledPoints } -Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) +Foam::label Foam::checkGeometry +( + const polyMesh& mesh, + const bool allGeometry, + const autoPtr& writer +) { label noFailedChecks = 0; @@ -563,6 +570,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " non closed cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), cells); + } } } @@ -575,6 +586,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << aspectCells.name() << endl; aspectCells.instance() = mesh.pointsInstance(); aspectCells.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), aspectCells); + } } } @@ -592,6 +607,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " zero area faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -610,6 +629,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " zero volume cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), cells); + } } } } @@ -629,6 +652,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " non-orthogonal faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } @@ -647,6 +674,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -665,6 +696,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " skew faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -685,6 +720,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -714,6 +753,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << "decomposition tets to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -774,6 +817,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -793,6 +840,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " warped faces to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } } @@ -810,6 +861,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " under-determined cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), cells); + } } } @@ -826,6 +881,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << " concave cells to set " << cells.name() << endl; cells.instance() = mesh.pointsInstance(); cells.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), cells); + } } } @@ -843,6 +902,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } @@ -860,6 +923,10 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry) << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H index edc1f44826..9658512eb1 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.H @@ -6,6 +6,7 @@ namespace Foam { class polyMesh; class wedgePolyPatch; + class surfaceWriter; label findOppositeWedge(const polyMesh&, const wedgePolyPatch&); @@ -21,5 +22,10 @@ namespace Foam //- Check 0th vertex on coupled faces bool checkCoupledPoints(const polyMesh&, const bool report, labelHashSet*); - label checkGeometry(const polyMesh& mesh, const bool allGeometry); + label checkGeometry + ( + const polyMesh& mesh, + const bool allGeometry, + const autoPtr& + ); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C index b11946a28f..527ba497d3 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,16 +42,20 @@ Usage \param -region \ \n Specify an alternative mesh region. + \param -writeSets \ \n + Reconstruct all cellSets and faceSets geometry and write to postProcessing/ + directory according to surfaceFormat (e.g. vtk or ensight) + \*---------------------------------------------------------------------------*/ #include "argList.H" #include "timeSelector.H" #include "Time.H" - #include "polyMesh.H" #include "globalMeshData.H" +#include "vtkSurfaceWriter.H" -#include "printMeshStats.H" +#include "checkTools.H" #include "checkTopology.H" #include "checkGeometry.H" #include "checkMeshQuality.H" @@ -84,6 +88,12 @@ int main(int argc, char *argv[]) "meshQuality", "read user-defined mesh quality criterions from system/meshQualityDict" ); + argList::addOption + ( + "writeSets", + "surfaceFormat" + "reconstruct and write all faceSets and cellSets in selected format" + ); #include "setRootCase.H" #include "createTime.H" @@ -95,6 +105,9 @@ int main(int argc, char *argv[]) const bool allTopology = args.optionFound("allTopology"); const bool meshQuality = args.optionFound("meshQuality"); + word surfaceFormat; + const bool writeSets = args.optionReadIfPresent("writeSets", surfaceFormat); + if (noTopology) { Info<< "Disabling all topology checks." << nl << endl; @@ -112,6 +125,12 @@ int main(int argc, char *argv[]) { Info<< "Enabling user-defined geometry checks." << nl << endl; } + if (writeSets) + { + Info<< "Reconstructing and writing " << surfaceFormat + << " representation" + << " of all faceSets and cellSets." << nl << endl; + } autoPtr qualDict; @@ -134,6 +153,13 @@ int main(int argc, char *argv[]) } + autoPtr writer; + if (writeSets) + { + writer = surfaceWriter::New(surfaceFormat); + } + + forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); @@ -161,14 +187,20 @@ int main(int argc, char *argv[]) if (!noTopology) { - nFailedChecks += checkTopology(mesh, allTopology, allGeometry); + nFailedChecks += checkTopology + ( + mesh, + allTopology, + allGeometry, + writer + ); } - nFailedChecks += checkGeometry(mesh, allGeometry); + nFailedChecks += checkGeometry(mesh, allGeometry, writer); if (meshQuality) { - nFailedChecks += checkMeshQuality(mesh, qualDict()); + nFailedChecks += checkMeshQuality(mesh, qualDict(), writer); } @@ -189,11 +221,11 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; - label nFailedChecks = checkGeometry(mesh, allGeometry); + label nFailedChecks = checkGeometry(mesh, allGeometry, writer); if (meshQuality) { - nFailedChecks += checkMeshQuality(mesh, qualDict()); + nFailedChecks += checkMeshQuality(mesh, qualDict(), writer); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C index b00f02f8ef..a6a01c7336 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.C @@ -3,12 +3,14 @@ #include "cellSet.H" #include "faceSet.H" #include "motionSmoother.H" - +#include "surfaceWriter.H" +#include "checkTools.H" Foam::label Foam::checkMeshQuality ( const polyMesh& mesh, - const dictionary& dict + const dictionary& dict, + const autoPtr& writer ) { label noFailedChecks = 0; @@ -27,6 +29,10 @@ Foam::label Foam::checkMeshQuality << " faces in error to set " << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); + if (writer.valid()) + { + mergeAndWrite(writer(), faces); + } } } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H index 1e5b3489c9..52507986bf 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMeshQuality.H @@ -2,5 +2,12 @@ namespace Foam { - label checkMeshQuality(const polyMesh& mesh, const dictionary&); + class surfaceWriter; + + label checkMeshQuality + ( + const polyMesh&, + const dictionary&, + const autoPtr& + ); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C new file mode 100644 index 0000000000..55cc2fcc1d --- /dev/null +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C @@ -0,0 +1,397 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "checkTools.H" +#include "polyMesh.H" +#include "globalMeshData.H" +#include "hexMatcher.H" +#include "wedgeMatcher.H" +#include "prismMatcher.H" +#include "pyrMatcher.H" +#include "tetWedgeMatcher.H" +#include "tetMatcher.H" +#include "IOmanip.H" +#include "faceSet.H" +#include "cellSet.H" +#include "PatchTools.H" +#include "Time.H" +#include "surfaceWriter.H" +#include "sampledSurfaces.H" +#include "syncTools.H" + + +void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) +{ + Info<< "Mesh stats" << nl + << " points: " + << returnReduce(mesh.points().size(), sumOp