ENH: add ensight writeBox method (eg, for simple 'placeholder' geometry)

- related to issue #3095. Some type of geometry is required when
  loading "measured" ensight data.

ENH: emit a fallback geometry-box for foamToEnsight

- eg, with "foamToEnsight -no-internal -no-boundary" and lagrangian
This commit is contained in:
Mark Olesen 2024-02-01 12:41:37 +01:00
parent 4ae4f0928d
commit cb416fb3ec
5 changed files with 78 additions and 10 deletions

View File

@ -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());
}
}

View File

@ -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;
};

View File

@ -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"
);
};

View File

@ -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<>

View File

@ -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;
};