diff --git a/src/fileFormats/ensight/mesh/ensightMesh.C b/src/fileFormats/ensight/mesh/ensightMesh.C index 8681c14abbcb1ba9eaeba5c8c2b38ce46e09fb19..d57478fa2d82a44342354cc4d015f8d40c2ae96d 100644 --- a/src/fileFormats/ensight/mesh/ensightMesh.C +++ b/src/fileFormats/ensight/mesh/ensightMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -449,6 +449,19 @@ void Foam::ensightMesh::write { faceZoneParts_[id].write(os, mesh_, parallel); } + + // No geometry parts written? + // - with lagrangian-only output the VTK EnsightReader still + // needs a volume geometry, and ensight usually does too + if + ( + cellZoneParts_.empty() + && boundaryParts_.empty() + && faceZoneParts_.empty() + ) + { + ensightCells::writeBox(os, mesh_.bounds()); + } } diff --git a/src/fileFormats/ensight/mesh/ensightMesh.H b/src/fileFormats/ensight/mesh/ensightMesh.H index fb61d716ebd2efce8df315a32ed0ab17138ebb03..a0cc1cbf54da6d55af6e542da23d0928afc15ddd 100644 --- a/src/fileFormats/ensight/mesh/ensightMesh.H +++ b/src/fileFormats/ensight/mesh/ensightMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -216,18 +216,22 @@ public: // Output - //- Write geometry to file. Normally in parallel + //- Write geometry to file (normally in parallel). + // If all geometry is disabled, it will simply writes the mesh + // bounding box (to ensure that the geometry file is non-empty) void write ( ensightGeoFile& os, - bool parallel = Pstream::parRun() + bool parallel = UPstream::parRun() ) const; - //- Write geometry to file. Normally in parallel + //- Write geometry to file (normally in parallel). + // If all geometry is disabled, it will simply writes the mesh + // bounding box (to ensure that the geometry file is non-empty) inline void write ( autoPtr<ensightGeoFile>& os, - bool parallel = Pstream::parRun() + bool parallel = UPstream::parRun() ) const; }; diff --git a/src/fileFormats/ensight/part/cells/ensightCells.H b/src/fileFormats/ensight/part/cells/ensightCells.H index ac64cd0d81c6fa3f7aec5b420e3825d332df6a56..5b2197a20690ed3b698c738baa4e5ffa1be9a723 100644 --- a/src/fileFormats/ensight/part/cells/ensightCells.H +++ b/src/fileFormats/ensight/part/cells/ensightCells.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,6 +46,7 @@ namespace Foam // Forward Declarations class bitSet; +class boundBox; class polyMesh; template<class T> class InfoProxy; @@ -279,6 +280,16 @@ public: const polyMesh& mesh, bool parallel ) const; + + //- Write bounding box geometry. + //- All parameters are only relevant on master + static void writeBox + ( + ensightGeoFile& os, + const boundBox& bb, + const label partIndex = 0, + const word& partName = "geometry-box" + ); }; diff --git a/src/fileFormats/ensight/part/cells/ensightCellsIO.C b/src/fileFormats/ensight/part/cells/ensightCellsIO.C index f45f70a4176983ec5e246b833d2a6836331569d3..2223861df624a51b668cc99db7fec5ff3625b312 100644 --- a/src/fileFormats/ensight/part/cells/ensightCellsIO.C +++ b/src/fileFormats/ensight/part/cells/ensightCellsIO.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,7 +28,9 @@ License #include "ensightCells.H" #include "ensightOutput.H" #include "InfoProxy.H" +#include "boundBox.H" #include "polyMesh.H" +#include "cellModel.H" #include "globalIndex.H" #include "globalMeshData.H" #include "manifoldCellsMeshObject.H" @@ -330,6 +332,44 @@ void Foam::ensightCells::write } +void Foam::ensightCells::writeBox +( + ensightGeoFile& os, + const boundBox& bb, + const label partIndex, + const word& partName +) +{ + pointField points; + cellShapeList shapes; + + if (UPstream::master()) + { + points = bb.hexCorners(); + shapes.emplace_back(cellModel::HEX, identity(8)); + } + + ensightOutput::Detail::writeCoordinates + ( + os, + partIndex, + partName, + 8, // nPoints (global) + points, + false // serial only! (parallel=false) + ); + + if (UPstream::master()) + { + os.writeKeyword(ensightCells::key(ensightCells::elemType::HEXA8)); + os.write(shapes.size()); // one cell (global) + os.newline(); + + ensightOutput::writeCellShapes(os, shapes); + } +} + + // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template<> diff --git a/src/finiteArea/output/ensight/ensightFaMesh.H b/src/finiteArea/output/ensight/ensightFaMesh.H index 394b4d5463eaff73c661d63fa0a4f17be24b5608..ce3deb7534a5307dc37a111154ac09f02110b91f 100644 --- a/src/finiteArea/output/ensight/ensightFaMesh.H +++ b/src/finiteArea/output/ensight/ensightFaMesh.H @@ -148,14 +148,14 @@ public: void write ( ensightGeoFile& os, - bool parallel = Pstream::parRun() + bool parallel = UPstream::parRun() ) const; //- Write geometry to file. Normally in parallel inline void write ( autoPtr<ensightGeoFile>& os, - bool parallel = Pstream::parRun() + bool parallel = UPstream::parRun() ) const; };