diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertVolumeFields.H index db25c78cdc28bd4892d5b13e6c94e3206d46cc68..d224b5d01cc4138f2c210f7dfd640d26110dff30 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<vtk::internalWriter>::New diff --git a/src/fileFormats/ensight/output/ensightOutput.C b/src/fileFormats/ensight/output/ensightOutput.C index 27e12cba9f1df56d8a4dc6eb75b69ce1637980c7..df07a35655bfb56f9a8f2629bf466dd2d5693c31 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 92164841d6bbd47d9e047792875ef2ff00871a98..edbcde79c203db8d402c77d966613075bd204c15 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 c36a6222e6eb05734d51109620c0ebae4b545375..f2f7edce173af45aa9fe04315249062ea0ac2692 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<label, nTypes+1> 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 7633ba2679828c5328f49d7b173d2a2d09b49cb7..ff8a7019f831c68fb92bfe574a021986cb0092d0 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::label> 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<label> pointMap(nEstimate); + Map<label> pointMap(8*this->size()); // Pass 1: markup used points from cells for (const label celli : this->cellIds()) { - for (const label facei : mesh.cells()[celli]) + for (const label facei : meshCells[celli]) { - for (const label pointi : mesh.faces()[facei]) + for (const label pointi : meshFaces[facei]) { pointMap.insert(pointi, 0); } @@ -72,6 +75,9 @@ Foam::label Foam::ensightCells::meshPointMapppings bool parallel ) const { + ///const cellList& meshCells = mesh.cells(); + const cellList& meshCells = manifoldCellsMeshObject::New(mesh).cells(); + labelList pointToGlobal; const bool rewritePointMap = notNull(pointToGlobalRequest); @@ -177,7 +183,7 @@ Foam::label Foam::ensightCells::meshPointMapppings for (const label celli : this->cellIds()) { - for (const label facei : mesh.cells()[celli]) + for (const label facei : meshCells[celli]) { for (const label pointi : mesh.faces()[facei]) { diff --git a/src/fileFormats/ensight/part/cells/ensightCellsI.H b/src/fileFormats/ensight/part/cells/ensightCellsI.H index 18ece2b549c567018c345b0bd0172507f090a09d..52515d0c147ed624d447d964d4efc52e4bd17675 100644 --- a/src/fileFormats/ensight/part/cells/ensightCellsI.H +++ b/src/fileFormats/ensight/part/cells/ensightCellsI.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,6 +40,12 @@ inline Foam::label Foam::ensightCells::add(const elemType etype, label id) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +inline bool Foam::ensightCells::manifold() const noexcept +{ + return manifold_; +} + + inline const char* Foam::ensightCells::key(const elemType etype) { return elemNames[etype]; diff --git a/src/fileFormats/vtk/part/foamVtuSizing.C b/src/fileFormats/vtk/part/foamVtuSizing.C index c1a1688e7abe907e25e5e6749cf651dbfc5fe5b1..87a99cac4b890b2d4d9d42628c15ce130efa0f12 100644 --- a/src/fileFormats/vtk/part/foamVtuSizing.C +++ b/src/fileFormats/vtk/part/foamVtuSizing.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,6 +29,7 @@ License #include "foamVtkCore.H" #include "polyMesh.H" #include "cellShape.H" +#include "manifoldCellsMeshObject.H" // Only used in this file #include "foamVtuSizingImpl.C" @@ -222,6 +223,7 @@ Foam::vtk::vtuSizing::vtuSizing void Foam::vtk::vtuSizing::clear() noexcept { decompose_ = false; + manifold_ = false; selectionMode_ = FULL_MESH; nCells_ = 0; nPoints_ = 0; @@ -263,6 +265,9 @@ void Foam::vtk::vtuSizing::reset const cellModel& tetWedge = cellModel::ref(cellModel::TETWEDGE); const cellShapeList& shapes = mesh.cellShapes(); + ///const cellList& meshCells = mesh.cells(); + const cellList& meshCells = manifoldCellsMeshObject::New(mesh).cells(); + const faceList& meshFaces = mesh.faces(); // Unique vertex labels per polyhedral labelHashSet hashUniqId(2*256); @@ -285,6 +290,9 @@ void Foam::vtk::vtuSizing::reset selectionMode_ = selectionModeType::FULL_MESH; } + // Manifold cells detected? + manifold_ = manifoldCellsMeshObject::New(mesh).manifold(); + const label nInputCells = ( isSubsetMesh @@ -337,10 +345,10 @@ void Foam::vtk::vtuSizing::reset // Count vertices into first decomposed cell bool first = true; - const cell& cFaces = mesh.cells()[celli]; + const cell& cFaces = meshCells[celli]; for (const label facei : cFaces) { - const face& f = mesh.faces()[facei]; + const face& f = meshFaces[facei]; // Face decomposed into triangles and quads // Tri -> Tet, Quad -> Pyr @@ -365,7 +373,7 @@ void Foam::vtk::vtuSizing::reset { // Polyhedral: Not decomposed - const labelList& cFaces = mesh.cells()[celli]; + const labelList& cFaces = meshCells[celli]; // Unique node ids used (XML/INTERNAL, not needed for LEGACY) hashUniqId.clear(); @@ -376,7 +384,7 @@ void Foam::vtk::vtuSizing::reset for (const label facei : cFaces) { - const face& f = mesh.faces()[facei]; + const face& f = meshFaces[facei]; nFaceLabels_ += f.size(); hashUniqId.insert(f); @@ -411,6 +419,8 @@ void Foam::vtk::vtuSizing::resetShapes const cellModel& hex = cellModel::ref(cellModel::HEX); decompose_ = false; // Disallow decomposition + manifold_ = false; // Assume no manifold cells possible + selectionMode_ = SHAPE_MESH; const label nInputCells = shapes.size(); diff --git a/src/fileFormats/vtk/part/foamVtuSizing.H b/src/fileFormats/vtk/part/foamVtuSizing.H index 7b2c5a6081a9f6694b272b22ca7f8370b1e32ded..dbedb1f615ca02a5f81673c47b78d0ce8d25c0c8 100644 --- a/src/fileFormats/vtk/part/foamVtuSizing.H +++ b/src/fileFormats/vtk/part/foamVtuSizing.H @@ -169,6 +169,9 @@ private: //- Polyhedral decomposition requested bool decompose_; + //- Manifold cells detected + bool manifold_; + //- How the mesh cells have been selected or defined selectionModeType selectionMode_; @@ -344,6 +347,9 @@ public: //- Query the decompose flag (normally off) inline bool decompose() const noexcept; + //- Manifold mesh cells detected? Globally consistent quantity. + inline bool manifold() const noexcept; + //- Query how the mesh cells have been selected or defined inline selectionModeType selectionMode() const noexcept; diff --git a/src/fileFormats/vtk/part/foamVtuSizingI.H b/src/fileFormats/vtk/part/foamVtuSizingI.H index 6c205714879d1eee3f4a840a17cc0fae87ad044a..67550e3de1f2c2cf685264c703e8e9ae68013c92 100644 --- a/src/fileFormats/vtk/part/foamVtuSizingI.H +++ b/src/fileFormats/vtk/part/foamVtuSizingI.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,6 +35,12 @@ inline bool Foam::vtk::vtuSizing::decompose() const noexcept } +inline bool Foam::vtk::vtuSizing::manifold() const noexcept +{ + return manifold_; +} + + inline Foam::vtk::vtuSizing::selectionModeType Foam::vtk::vtuSizing::selectionMode() const noexcept { diff --git a/src/fileFormats/vtk/part/foamVtuSizingImpl.C b/src/fileFormats/vtk/part/foamVtuSizingImpl.C index 69abf42df56203f6d8496da6c8a5dbe883fe7631..ea834692515b29b3a911ee621aff0cd6c2b6f561 100644 --- a/src/fileFormats/vtk/part/foamVtuSizingImpl.C +++ b/src/fileFormats/vtk/part/foamVtuSizingImpl.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,6 +29,7 @@ License #include "foamVtkCore.H" #include "polyMesh.H" #include "cellShape.H" +#include "manifoldCellsMeshObject.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -229,6 +230,9 @@ void Foam::vtk::vtuSizing::populateArrays const cellModel& tetWedge = cellModel::ref(cellModel::TETWEDGE); const cellShapeList& shapes = mesh.cellShapes(); + ///const cellList& meshCells = mesh.cells(); + const cellList& meshCells = manifoldCellsMeshObject::New(mesh).cells(); + const faceList& meshFaces = mesh.faces(); // The face owner is needed to determine the face orientation const labelList& owner = mesh.faceOwner(); @@ -451,11 +455,11 @@ void Foam::vtk::vtuSizing::populateArrays // Whether to insert cell in place of original or not. bool firstCell = true; - const labelList& cFaces = mesh.cells()[celli]; + const labelList& cFaces = meshCells[celli]; for (const label facei : cFaces) { - const face& f = mesh.faces()[facei]; + const face& f = meshFaces[facei]; const bool isOwner = (owner[facei] == celli); // Count triangles/quads in decomposition @@ -579,7 +583,8 @@ void Foam::vtk::vtuSizing::populateArrays // face-stream // [nFaces, nFace0Pts, id1, id2, ..., nFace1Pts, id1, id2, ...] cellTypes[cellIndex] = vtk::cellType::VTK_POLYHEDRON; - const labelList& cFaces = mesh.cells()[celli]; + + const labelList& cFaces = meshCells[celli]; const label startLabel = faceIndexer; diff --git a/src/functionObjects/utilities/ensightWrite/ensightWrite.H b/src/functionObjects/utilities/ensightWrite/ensightWrite.H index f91aadc040e61de8813a332041916b869ca63a7f..1c4675d48ee1533437f4b0ddf2e92fae4986eddc 100644 --- a/src/functionObjects/utilities/ensightWrite/ensightWrite.H +++ b/src/functionObjects/utilities/ensightWrite/ensightWrite.H @@ -98,7 +98,6 @@ Description directory | The output directory name | no | postProcessing/NAME overwrite | Remove existing directory | no | false consecutive | Consecutive output numbering | no | false - nodeValues | Write values at nodes | no | false \endtable \heading Output Selection diff --git a/src/functionObjects/utilities/vtkWrite/vtkWrite.C b/src/functionObjects/utilities/vtkWrite/vtkWrite.C index 66939d61cc30cfd462a7e64e437a53eebc34c0e0..5f92c2a7cdc970bafe06d14fd804ffad0046e360 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWrite.C +++ b/src/functionObjects/utilities/vtkWrite/vtkWrite.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -347,15 +347,18 @@ bool Foam::functionObjects::vtkWrite::write() if (doInternal_) { - if (interpolate_) - { - pInterp.reset(new volPointInterpolation(meshProxy.mesh())); - } - if (vtuMeshCells.empty()) { // Use the appropriate mesh (baseMesh or subMesh) vtuMeshCells.reset(meshProxy.mesh()); + + if (interpolate_ && vtuMeshCells.manifold()) + { + interpolate_ = false; + WarningInFunction + << "Manifold cells detected - disabling PointData" + << endl; + } } internalWriter = autoPtr<vtk::internalWriter>::New @@ -385,6 +388,11 @@ bool Foam::functionObjects::vtkWrite::write() internalWriter->writeTimeValue(timeValue); internalWriter->writeGeometry(); + + if (interpolate_) + { + pInterp.reset(new volPointInterpolation(meshProxy.mesh())); + } }