diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 250ddc086a..84a0589546 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2022 OpenCFD Ltd. + Copyright (C) 2015-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,6 +52,7 @@ Description #include "snapParameters.H" #include "layerParameters.H" #include "vtkCoordSetWriter.H" +#include "vtkSurfaceWriter.H" #include "faceSet.H" #include "motionSmoother.H" #include "polyTopoChange.H" @@ -859,19 +860,36 @@ int main(int argc, char *argv[]) // Writer for writing lines autoPtr setFormatter; { - const word setFormat + const word writerType ( meshDict.getOrDefault ( "setFormat", - coordSetWriters::vtkWriter::typeName // Default: "vtk" + coordSetWriters::vtkWriter::typeName // Default: "vtk" ) ); setFormatter = coordSetWriter::New ( - setFormat, - meshDict.subOrEmptyDict("formatOptions").optionalSubDict(setFormat) + writerType, + meshDict.subOrEmptyDict("formatOptions").optionalSubDict(writerType) + ); + } + // Writer for writing surfaces + refPtr surfFormatter; + { + const word type + ( + meshDict.getOrDefault + ( + "surfaceFormat", + surfaceWriters::vtkWriter::typeName // Default: "vtk" + ) + ); + surfFormatter = surfaceWriter::New + ( + type, + meshDict.subOrEmptyDict("formatOptions").optionalSubDict(type) ); } @@ -1774,6 +1792,7 @@ int main(int argc, char *argv[]) globalToMasterPatch, globalToSlavePatch, setFormatter(), + surfFormatter, dryRun ); diff --git a/etc/caseDicts/annotated/snappyHexMeshDict b/etc/caseDicts/annotated/snappyHexMeshDict index 7f2333bcc4..c49c1f2941 100644 --- a/etc/caseDicts/annotated/snappyHexMeshDict +++ b/etc/caseDicts/annotated/snappyHexMeshDict @@ -868,6 +868,9 @@ meshQualityControls //// Format for writing lines. E.g. leak path. Default is vtk format. //setFormat ensight; +//// Format to use for surfaces. E.g. leak-closure faces. Default is vtk format. +//surfaceFormat vtk; + // Merge tolerance. Is fraction of overall bounding box of initial mesh. // Note: the write tolerance needs to be higher than this. mergeTolerance 1e-6; diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H index fce8d76e65..6961ac7927 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.H @@ -60,6 +60,7 @@ SourceFiles #include "volumeType.H" #include "DynamicField.H" #include "coordSetWriter.H" +#include "surfaceWriter.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -613,6 +614,7 @@ private: const pointField& locationsOutsideMesh, const bool exitIfLeakPath, const refPtr& leakPathFormatter, + refPtr& surfFormatter, const labelList& neiLevel, const pointField& neiCc, @@ -873,6 +875,7 @@ private: const pointField& locationsOutsideMesh, const bool exitIfLeakPath, const refPtr& leakPathFormatter, + refPtr& surfFormatter, labelList& cellToZone, labelList& unnamedRegion1, @@ -1343,7 +1346,8 @@ public: const wordList& regionsInMesh, const pointField& locationsOutsideMesh, const bool exitIfLeakPath, - const refPtr& leakPathFormatter + const refPtr& leakPathFormatter, + refPtr& surfFormatter ); //- Merge free-standing baffles @@ -1375,7 +1379,8 @@ public: const wordList& regionsInMesh, const pointField& locationsOutsideMesh, const bool exitIfLeakPath, - const refPtr& leakPathFormatter + const refPtr& leakPathFormatter, + refPtr& surfFormatter ); //- Remove cells from limitRegions if level -1 @@ -1479,6 +1484,7 @@ public: const pointField& locationsOutsideMesh, const bool exitIfLeakPath, const refPtr& leakPathFormatter, + refPtr& surfFormatter, wordPairHashTable& zonesToFaceZone ); diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C index 781dd60d09..24fcc02398 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2014 OpenFOAM Foundation - Copyright (C) 2015-2022 OpenCFD Ltd. + Copyright (C) 2015-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -291,6 +291,7 @@ void Foam::meshRefinement::getBafflePatches const pointField& locationsOutsideMesh, const bool exitIfLeakPath, const refPtr& leakPathFormatter, + refPtr& surfFormatter, const labelList& neiLevel, const pointField& neiCc, @@ -326,6 +327,7 @@ void Foam::meshRefinement::getBafflePatches locationsOutsideMesh, exitIfLeakPath, leakPathFormatter, + surfFormatter, cellToZone, unnamedRegion1, @@ -2848,6 +2850,7 @@ void Foam::meshRefinement::zonify const pointField& locationsOutsideMesh, const bool exitIfLeakPath, const refPtr& leakPathFormatter, + refPtr& surfFormatter, labelList& cellToZone, labelList& unnamedRegion1, @@ -3221,27 +3224,66 @@ void Foam::meshRefinement::zonify str.write(mesh_.points()[pointi]); } } - if (debug && returnReduceOr(unnamedClosureFaces.size())) + + if (returnReduceOr(unnamedClosureFaces.size()) && surfFormatter) { - mkDir(mesh_.time().timePath()); - OBJstream str(mesh_.time().timePath()/"unnamedClosureFaces.obj"); - Pout<< "Writing " << unnamedClosureFaces.size() - << " unnamedClosureFaces to " << str.name() << endl; - for (const label facei : unnamedClosureFaces) - { - str.write(mesh_.faces()[facei], mesh_.points(), false); - } + fileName outputName + ( + mesh_.time().globalPath() + / functionObject::outputPrefix + / mesh_.pointsInstance() + / "unnamedClosureFaces" + ); + outputName.clean(); // Remove unneeded ".." + + Info<< "Writing " + << returnReduce(unnamedClosureFaces.size(), sumOp