diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertSurfaceFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertSurfaceFields.H index 0681e103b3a42fecdfe43cb239827190ac3eef8c..6803a25d7461445c20abd4838e2872c7e0a5eae1 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertSurfaceFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertSurfaceFields.H @@ -194,11 +194,8 @@ Description continue; } - uindirectPrimitivePatch pp - ( - UIndirectList<face>(mesh.faces(), fz), - mesh.points() - ); + // Retrieve as primitiveFacePatch with faces properly flipped + const primitiveFacePatch& pp = fz(); vtkWriterType_faceZone writer ( @@ -224,11 +221,11 @@ Description for (const auto& fld : sScalars) { - writer.write(fld); + writer.write(fld, fz.addressing()); } for (const auto& fld : sVectors) { - writer.write(fld); + writer.write(fld, fz.addressing()); } fileName outputName(writer.output()); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeAreaFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeAreaFields.H index 9bd2cb8c37c6f0dd479d9fe02669ef51df2b596d..ca265a25c95819b99d668a808b300b717b135a4a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeAreaFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeAreaFields.H @@ -28,7 +28,7 @@ InNamespace Description Read finite-area fields from disk - and write with vtk::surfaceMeshWriter + and write with vtk::uindirectPatchGeoFieldsWriter SourceFiles writeAreaFields.H diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfaceFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfaceFields.H index ef6752783195ef807760349b19a8544bbd96ff7a..b41ce0a8893e8b1cddb33370174d3067f34e97cb 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfaceFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeSurfaceFields.H @@ -38,7 +38,8 @@ SourceFiles #define writeSurfaceFields_H #include "readFields.H" -#include "foamVtkUIndPatchGeoFieldsWriter.H" +#include "primitiveFacePatch.H" +#include "foamVtkGenericPatchGeoFieldsWriter.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -46,7 +47,9 @@ namespace Foam { // Writer type for face zones + fields -typedef vtk::uindirectPatchGeoFieldsWriter vtkWriterType_faceZone; +typedef + vtk::GenericPatchGeoFieldsWriter<primitiveFacePatch> + vtkWriterType_faceZone; } // End namespace Foam diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H index 857e878b215082a43bf400dd4d7feefac5935622..01be2b30bae5b6e34bf012611b81e6cc83c6ea63 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H @@ -211,6 +211,7 @@ public: //- Helper function to re-direct to zone::localID(...) label whichCell(const label globalCellID) const; + //- Check zone definition. Return true if in error. virtual bool checkDefinition(const bool report = false) const; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H index 6bdb8c65d48335788a94ce0f2e37655be69c0fbf..ea247d84dbf45883983b532c7523578b51650ba0 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H @@ -45,7 +45,6 @@ SourceFiles #include "zone.H" #include "faceZoneMeshFwd.H" -#include "boolList.H" #include "primitiveFacePatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -323,6 +322,7 @@ public: const bool flipMapValue ); + //- Check zone definition. Return true if in error. virtual bool checkDefinition(const bool report = false) const; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H index 0b883e84130655310d7c0835a28e069fe264d52c..6702c027d580166c9293c9afbd05b561f1454b42 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H @@ -214,6 +214,7 @@ public: //- Helper function to re-direct to zone::localID(...) label whichPoint(const label globalPointID) const; + //- Check zone definition. Return true if in error. virtual bool checkDefinition(const bool report = false) const; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H index d211b3f64c25f0aacf950fb80fc8c48c52dc1e28..f99a63bff42ccb602b3ac015e761c8986bc60207 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H @@ -136,16 +136,24 @@ public: // Member Functions - //- Return a reference to the look-up map + //- Demand-driven: the look-up map from global to local id const Map<label>& lookupMap() const; //- Lookup local address in zone for given global index. // \return the local address, or -1 if the item is not in the zone label localID(const label globalID) const; + + //- The addressing used by the zone + const labelList& addressing() const noexcept + { + return static_cast<const labelList&>(*this); + } + //- Clear addressing virtual void clearAddressing(); + //- Check zone definition. Return true if in error. virtual bool checkDefinition(const bool report = false) const = 0; diff --git a/src/conversion/vtk/output/foamVtkGenericPatchGeoFieldsWriter.C b/src/conversion/vtk/output/foamVtkGenericPatchGeoFieldsWriter.C index ff8c162b855335b651dba3012f51621d9d90c71f..2cfcdfb29a1cb1876495ac3846a336c7c92d1230 100644 --- a/src/conversion/vtk/output/foamVtkGenericPatchGeoFieldsWriter.C +++ b/src/conversion/vtk/output/foamVtkGenericPatchGeoFieldsWriter.C @@ -32,12 +32,20 @@ template<class Type> Foam::tmp<Foam::Field<Type>> Foam::vtk::GenericPatchGeoFieldsWriter<PatchType>::getFaceField ( - const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld + const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld, + const labelUList& faceAddr ) const { - const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh(); + if (this->patch().size() != faceAddr.size()) + { + FatalErrorInFunction + << "Inconsistent sizing: patch has " + << this->patch().size() << " faces, addressing has " + << faceAddr.size() << " faces!" << nl + << Foam::exit(FatalError); + } - const labelList& faceAddr = this->patch().addressing(); + const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh(); auto tfld = tmp<Field<Type>>::New(faceAddr.size()); auto iter = tfld.ref().begin(); @@ -69,13 +77,14 @@ template<class PatchType> template<class Type> void Foam::vtk::GenericPatchGeoFieldsWriter<PatchType>::write ( - const GeometricField<Type, fvsPatchField, surfaceMesh>& field + const GeometricField<Type, fvsPatchField, surfaceMesh>& field, + const labelUList& faceAddr ) { this->GenericPatchWriter<PatchType>::writeCellData ( field.name(), - getFaceField(field)() + getFaceField(field, faceAddr)() ); } diff --git a/src/conversion/vtk/output/foamVtkGenericPatchGeoFieldsWriter.H b/src/conversion/vtk/output/foamVtkGenericPatchGeoFieldsWriter.H index 0ec42b092c12ca8d1f5e971e74058c8f8b5eb02d..b76971eec842a25cc4f217edbe851f5a9e017304 100644 --- a/src/conversion/vtk/output/foamVtkGenericPatchGeoFieldsWriter.H +++ b/src/conversion/vtk/output/foamVtkGenericPatchGeoFieldsWriter.H @@ -62,10 +62,12 @@ class GenericPatchGeoFieldsWriter // Private Member Functions //- Get face field (internal face or boundary face) + //- at specified face locations template<class Type> tmp<Field<Type>> getFaceField ( - const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld + const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld, + const labelUList& faceAddr ) const; @@ -88,11 +90,14 @@ public: // Member Functions - //- Write volume-mesh surface field (CellData) + //- Write volume-mesh surface field (CellData) from specified mesh + //- faces. + // For an indirect patch this will often simply be its addressing() template<class Type> void write ( - const GeometricField<Type, fvsPatchField, surfaceMesh>& field + const GeometricField<Type, fvsPatchField, surfaceMesh>& field, + const labelUList& faceAddr ); //- Write area-mesh surface field (CellData) diff --git a/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.H b/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.H index 4acb3a19ab76974c4a9c1045e7acfa7cd75df246..f3aafa779668574252ec4cc8ac1775e974d59917 100644 --- a/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.H +++ b/src/conversion/vtk/output/foamVtkSurfaceMeshWriter.H @@ -8,39 +8,20 @@ Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + This file is part of OpenFOAM, distributed under GPL-3.0-or-later. Typedef Foam::vtk::surfaceMeshWriter Description - Alias for Foam::vtk::indirectPatchGeoFieldsWriter. - - Write vtp file (or legacy vtk) with support for geometric fields. - -See Also - Foam::vtk::GenericPatchWriter + Older typedef for Foam::vtk::indirectPatchGeoFieldsWriter \*---------------------------------------------------------------------------*/ #ifndef Foam_vtk_surfaceMeshWriter_H #define Foam_vtk_surfaceMeshWriter_H -#include "foamVtkGenericPatchGeoFieldsWriter.H" -#include "indirectPrimitivePatch.H" +#include "foamVtkIndPatchGeoFieldsWriter.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,9 +32,7 @@ namespace vtk // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -typedef - GenericPatchGeoFieldsWriter<indirectPrimitivePatch> - surfaceMeshWriter; +typedef indirectPatchGeoFieldsWriter surfaceMeshWriter; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/sets/topoSets/faceZoneSet.C b/src/meshTools/sets/topoSets/faceZoneSet.C index 753eae1b69393c68065ce931cde336dc1c66c08b..94dae8b70253a311a7304012776f36106749088e 100644 --- a/src/meshTools/sets/topoSets/faceZoneSet.C +++ b/src/meshTools/sets/topoSets/faceZoneSet.C @@ -86,7 +86,7 @@ Foam::faceZoneSet::faceZoneSet ) { const faceZone& fz = faceZones[zoneID]; - addressing_ = fz; + addressing_ = fz.addressing(); flipMap_ = fz.flipMap(); } diff --git a/src/meshTools/sets/topoSets/faceZoneSet.H b/src/meshTools/sets/topoSets/faceZoneSet.H index 8df6e623c6506e17b1effcdd11aefcfabe549d18..f5f6c9e62950be2a58031d7499807f7247942b7d 100644 --- a/src/meshTools/sets/topoSets/faceZoneSet.H +++ b/src/meshTools/sets/topoSets/faceZoneSet.H @@ -39,7 +39,6 @@ SourceFiles #define faceZoneSet_H #include "faceSet.H" -#include "boolList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //