From 6e509c10fca93443fd2be05f4d3076d968521177 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 15 Feb 2022 15:36:50 +0100 Subject: [PATCH] ENH: handle manifold cells in VTK, Ensight output (#2396) - also disables PointData if manifold cells are detected. This is a partial workaround for volPointInterpolation problems with handling manifold cells. --- .../foamToVTK/convertVolumeFields.H | 11 ++++++++++ .../ensight/output/ensightOutput.C | 13 ++++++++---- .../ensight/part/cells/ensightCells.C | 5 +++++ .../ensight/part/cells/ensightCells.H | 6 ++++++ .../ensight/part/cells/ensightCellsAddr.C | 18 +++++++++++------ .../ensight/part/cells/ensightCellsI.H | 8 +++++++- src/fileFormats/vtk/part/foamVtuSizing.C | 20 ++++++++++++++----- src/fileFormats/vtk/part/foamVtuSizing.H | 6 ++++++ src/fileFormats/vtk/part/foamVtuSizingI.H | 8 +++++++- src/fileFormats/vtk/part/foamVtuSizingImpl.C | 13 ++++++++---- .../utilities/ensightWrite/ensightWrite.H | 1 - .../utilities/vtkWrite/vtkWrite.C | 20 +++++++++++++------ 12 files changed, 101 insertions(+), 28 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H index db25c78cdc..d224b5d01c 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H @@ -86,6 +86,17 @@ Description { // Use the appropriate mesh (baseMesh or subMesh) vtuMeshCells.reset(meshProxy.mesh()); + + if (doPointValues && vtuMeshCells.manifold()) + { + doPointValues = false; + nPointFields = 0; + Warning + << nl + << "Manifold cells detected (eg, AMI) - disabling PointData" + << nl + << endl; + } } internalWriter = autoPtr::New diff --git a/src/fileFormats/ensight/output/ensightOutput.C b/src/fileFormats/ensight/output/ensightOutput.C index 27e12cba9f..df07a35655 100644 --- a/src/fileFormats/ensight/output/ensightOutput.C +++ b/src/fileFormats/ensight/output/ensightOutput.C @@ -31,6 +31,7 @@ License #include "face.H" #include "polyMesh.H" #include "ListOps.H" +#include "manifoldCellsMeshObject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -80,7 +81,8 @@ Foam::labelList Foam::ensightOutput::Detail::getPolysNFaces const labelUList& addr ) { - const cellList& meshCells = mesh.cells(); + ///const cellList& meshCells = mesh.cells(); + const cellList& meshCells = manifoldCellsMeshObject::New(mesh).cells(); labelList list(addr.size()); @@ -103,7 +105,8 @@ Foam::labelList Foam::ensightOutput::Detail::getPolysNPointsPerFace const labelUList& addr ) { - const cellList& meshCells = mesh.cells(); + ///const cellList& meshCells = mesh.cells(); + const cellList& meshCells = manifoldCellsMeshObject::New(mesh).cells(); const faceList& meshFaces = mesh.faces(); // Count the number of faces per element @@ -211,7 +214,8 @@ Foam::ensightOutput::Detail::getPolysFacePoints const labelList& pointMap ) { - const cellList& meshCells = mesh.cells(); + ///const cellList& meshCells = mesh.cells(); + const cellList& meshCells = manifoldCellsMeshObject::New(mesh).cells(); const faceList& meshFaces = mesh.faces(); const labelList& owner = mesh.faceOwner(); @@ -286,7 +290,8 @@ void Foam::ensightOutput::writePolysPoints const labelList& pointMap ) { - const cellList& meshCells = mesh.cells(); + ///const cellList& meshCells = mesh.cells(); + const cellList& meshCells = manifoldCellsMeshObject::New(mesh).cells(); const faceList& meshFaces = mesh.faces(); const labelList& owner = mesh.faceOwner(); diff --git a/src/fileFormats/ensight/part/cells/ensightCells.C b/src/fileFormats/ensight/part/cells/ensightCells.C index 92164841d6..edbcde79c2 100644 --- a/src/fileFormats/ensight/part/cells/ensightCells.C +++ b/src/fileFormats/ensight/part/cells/ensightCells.C @@ -30,6 +30,7 @@ License #include "bitSet.H" #include "polyMesh.H" #include "cellModel.H" +#include "manifoldCellsMeshObject.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -78,6 +79,7 @@ void Foam::ensightCells::resizeAll() Foam::ensightCells::ensightCells() : ensightPart(), + manifold_(false), offsets_(Zero), sizes_(Zero) {} @@ -123,6 +125,7 @@ void Foam::ensightCells::clear() ensightPart::clear(); + manifold_ = false; sizes_ = Zero; offsets_ = Zero; } @@ -166,6 +169,8 @@ void Foam::ensightCells::classifyImpl const Addressing& cellIds ) { + manifold_ = manifoldCellsMeshObject::New(mesh).manifold(); + // References to cell shape models const cellModel& tet = cellModel::ref(cellModel::TET); const cellModel& pyr = cellModel::ref(cellModel::PYR); diff --git a/src/fileFormats/ensight/part/cells/ensightCells.H b/src/fileFormats/ensight/part/cells/ensightCells.H index c36a6222e6..f2f7edce17 100644 --- a/src/fileFormats/ensight/part/cells/ensightCells.H +++ b/src/fileFormats/ensight/part/cells/ensightCells.H @@ -89,6 +89,9 @@ private: // Private Data + //- Manifold cells detected + bool manifold_; + //- Begin/end offsets for address of each element type FixedList offsets_; @@ -166,6 +169,9 @@ public: // Access + //- Manifold mesh cells detected? Globally consistent quantity. + inline bool manifold() const noexcept; + //- Processor-local size of all elements. using ensightPart::size; diff --git a/src/fileFormats/ensight/part/cells/ensightCellsAddr.C b/src/fileFormats/ensight/part/cells/ensightCellsAddr.C index 7633ba2679..ff8a7019f8 100644 --- a/src/fileFormats/ensight/part/cells/ensightCellsAddr.C +++ b/src/fileFormats/ensight/part/cells/ensightCellsAddr.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,23 +30,26 @@ License #include "globalIndex.H" #include "globalMeshData.H" #include "ListOps.H" +#include "manifoldCellsMeshObject.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::Map Foam::ensightCells::meshPointMap(const polyMesh& mesh) const { - const label nEstimate = 8*this->size(); + ///const cellList& meshCells = mesh.cells(); + const cellList& meshCells = manifoldCellsMeshObject::New(mesh).cells(); + const faceList& meshFaces = mesh.faces(); - Map