diff --git a/src/conversion/ensight/output/ensightOutputVolFieldTemplates.C b/src/conversion/ensight/output/ensightOutputVolFieldTemplates.C index 2294cf25ad..de1238cf54 100644 --- a/src/conversion/ensight/output/ensightOutputVolFieldTemplates.C +++ b/src/conversion/ensight/output/ensightOutputVolFieldTemplates.C @@ -320,6 +320,8 @@ bool Foam::ensightOutput::Serial::writeVolField ensightFile& os ) { + constexpr bool parallel = false; // serial + const label patchi = part.patchIndex(); if (patchi >= 0 && patchi < vf.boundaryField().size()) @@ -329,7 +331,7 @@ bool Foam::ensightOutput::Serial::writeVolField vf.boundaryField()[patchi], part, os, - false // serial + parallel ); } @@ -345,12 +347,14 @@ bool Foam::ensightOutput::Serial::writeVolField ensightFile& os ) { + constexpr bool parallel = false; // serial + return ensightOutput::Detail::writeCellField ( vf.internalField(), part, os, - false // serial + parallel ); } diff --git a/src/fileFormats/ensight/part/ensightPart.H b/src/fileFormats/ensight/part/ensightPart.H index 3277c2c03b..2b9d3f9d3b 100644 --- a/src/fileFormats/ensight/part/ensightPart.H +++ b/src/fileFormats/ensight/part/ensightPart.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,12 +50,6 @@ SourceFiles namespace Foam { -// Forward declarations -class ensightPart; - -ensightGeoFile& operator<<(ensightGeoFile&, const ensightPart&); - - /*---------------------------------------------------------------------------*\ Class ensightPart Declaration \*---------------------------------------------------------------------------*/ @@ -114,7 +108,7 @@ public: // Constructors //- Construct with description - ensightPart(const string& description); + explicit ensightPart(const string& description); //- Destructor @@ -139,7 +133,7 @@ public: } //- Change the part name or description - void name(string value) + void rename(string value) { name_ = std::move(value); } @@ -147,31 +141,36 @@ public: // Output - //- Write geometry - virtual void write(ensightGeoFile&) const = 0; - - //- Helper: write geometry with given pointField - virtual void write - ( - ensightGeoFile&, - const pointField& - ) const = 0; - - //- Write summary information about the object - virtual void writeSummary(Ostream&) const = 0; + virtual void writeSummary(Ostream& os) const = 0; //- Print various types of debugging information - virtual void dumpInfo(Ostream&) const = 0; - - - // IOstream Operators + virtual void dumpInfo(Ostream& os) const = 0; //- Write geometry - friend ensightGeoFile& operator<<(ensightGeoFile&, const ensightPart&); + virtual void write(ensightGeoFile& os) const = 0; + //- Helper: write geometry with given pointField + virtual void write(ensightGeoFile& os, const pointField&) const = 0; + + + // Housekeeping + + //- Deprecated(2019-12) - use rename() method + // \deprecated(2019-12) - use rename() method + void FOAM_DEPRECATED_FOR(2019-12, "rename() method") + name(string value) + { + name_ = std::move(value); + } }; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +//- IOstream Operator to write geometry +ensightGeoFile& operator<<(ensightGeoFile& os, const ensightPart& part); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/fileFormats/ensight/part/ensightPartCells.C b/src/fileFormats/ensight/part/ensightPartCells.C index ba7c30439c..8a206be91f 100644 --- a/src/fileFormats/ensight/part/ensightPartCells.C +++ b/src/fileFormats/ensight/part/ensightPartCells.C @@ -85,11 +85,12 @@ Foam::ensightPart::localPoints Foam::ensightPartCells::calcLocalPoints() const Foam::ensightPartCells::ensightPartCells ( label partIndex, - const polyMesh& mesh + const polyMesh& mesh, + const string& partName ) : ensightCells(partIndex), - ensightPart("cells"), + ensightPart(partName), mesh_(mesh) { classify(mesh); @@ -100,11 +101,12 @@ Foam::ensightPartCells::ensightPartCells ( label partIndex, const polyMesh& mesh, - const labelUList& cellIds + const labelUList& cellIds, + const string& partName ) : ensightCells(partIndex), - ensightPart("cells"), + ensightPart(partName), mesh_(mesh) { classify(mesh, cellIds); @@ -115,13 +117,15 @@ Foam::ensightPartCells::ensightPartCells ( label partIndex, const polyMesh& mesh, - const cellZone& zn + const bitSet& selection, + const string& partName ) : - ensightPartCells(partIndex, mesh, static_cast(zn)) + ensightCells(partIndex), + ensightPart(partName), + mesh_(mesh) { - // Rename according to the zone name - name(zn.name()); + classify(mesh, selection); } @@ -129,14 +133,22 @@ Foam::ensightPartCells::ensightPartCells ( label partIndex, const polyMesh& mesh, - const bitSet& selection + const cellZone& zn, + const string& partName ) : - ensightCells(partIndex), - ensightPart("cells"), - mesh_(mesh) + ensightPartCells + ( + partIndex, + mesh, + static_cast(zn), + zn.name() + ) { - classify(mesh, selection); + if (!partName.empty()) + { + rename(partName); + } } @@ -322,14 +334,7 @@ void Foam::ensightPartCells::dumpInfo(Ostream& os) const os.writeKeyword(ensightCells::key(what)); - // DIY flat output - os << addr.size() << '('; - forAll(addr, i) - { - if (i) os << ' '; - os << addr[i]; - } - os << ')' << endEntry; + addr.writeList(os, 0) << endEntry; // Flat output } os.endBlock(); diff --git a/src/fileFormats/ensight/part/ensightPartCells.H b/src/fileFormats/ensight/part/ensightPartCells.H index c99602bbe8..b0ddad0d4d 100644 --- a/src/fileFormats/ensight/part/ensightPartCells.H +++ b/src/fileFormats/ensight/part/ensightPartCells.H @@ -58,7 +58,7 @@ class ensightPartCells { // Private Data - //- Mesh referenced + //- The referenced mesh const polyMesh& mesh_; @@ -89,37 +89,46 @@ public: //- Runtime type information TypeName("ensightCells"); + // Constructors - //- Construct from polyMesh without zones - ensightPartCells - ( - label partIndex, - const polyMesh& mesh - ); - - //- Construct a "cells" part from polyMesh and list of cells + //- Construct from entire polyMesh without zones. + //- Part receives the specified name (default: "cells"). ensightPartCells ( label partIndex, const polyMesh& mesh, - const labelUList& cellIds + const string& partName = "cells" ); - //- Construct from polyMesh and cellZone with name of the zone. + //- Construct a part from polyMesh and list of cells. + //- Part receives the specified name (default: "cells"). ensightPartCells ( label partIndex, const polyMesh& mesh, - const cellZone& zn + const labelUList& cellIds, + const string& partName = "cells" ); - //- Construct a "cells" part from polyMesh and selection of cells + //- Construct a part from polyMesh and selection of cells. + //- Part receives the specified name (default: "cells"). ensightPartCells ( label partIndex, const polyMesh& mesh, - const bitSet& selection + const bitSet& selection, + const string& partName = "cells" + ); + + //- Construct from polyMesh and cellZone. + //- Part receives the name of the zone unless otherwise specified. + ensightPartCells + ( + label partIndex, + const polyMesh& mesh, + const cellZone& zn, + const string& partName = "" ); @@ -146,19 +155,17 @@ public: // Output - //- Write geometry - virtual void write(ensightGeoFile& os) const; - - //- Helper: write geometry given the pointField - virtual void write(ensightGeoFile& os, const pointField& points) const; - - //- Write summary information about the object virtual void writeSummary(Ostream& os) const; //- Print various types of debugging information virtual void dumpInfo(Ostream& os) const; + //- Write geometry + virtual void write(ensightGeoFile& os) const; + + //- Helper: write geometry with given pointField + virtual void write(ensightGeoFile& os, const pointField& points) const; }; diff --git a/src/fileFormats/ensight/part/ensightPartFaces.C b/src/fileFormats/ensight/part/ensightPartFaces.C index 4e005173a8..6e9d2747c4 100644 --- a/src/fileFormats/ensight/part/ensightPartFaces.C +++ b/src/fileFormats/ensight/part/ensightPartFaces.C @@ -35,6 +35,7 @@ namespace Foam defineTypeNameAndDebug(ensightPartFaces, 0); } + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::ensightPart::localPoints Foam::ensightPartFaces::calcLocalPoints() const @@ -113,7 +114,8 @@ Foam::ensightPartFaces::ensightPartFaces ( label partIndex, const polyMesh& mesh, - const polyPatch& patch + const polyPatch& patch, + const string& partName ) : ensightFaces(partIndex), @@ -124,11 +126,27 @@ Foam::ensightPartFaces::ensightPartFaces points_(mesh.points()), contiguousPoints_(false) { + if (!partName.empty()) + { + rename(partName); + } + // Classify the face shapes classify(patch); } +Foam::ensightPartFaces::ensightPartFaces +( + label partIndex, + const polyPatch& patch, + const string& partName +) +: + ensightPartFaces(partIndex, patch.boundaryMesh().mesh(), patch, partName) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::ensightPartFaces::writeConnectivity @@ -274,14 +292,7 @@ void Foam::ensightPartFaces::dumpInfo(Ostream& os) const os.writeKeyword(ensightFaces::key(what)); - // DIY flat output - os << addr.size() << '('; - forAll(addr, i) - { - if (i) os << ' '; - os << addr[i]; - } - os << ')' << endEntry; + addr.writeList(os, 0) << endEntry; // Flat output } os.endBlock(); diff --git a/src/fileFormats/ensight/part/ensightPartFaces.H b/src/fileFormats/ensight/part/ensightPartFaces.H index 868cea25b4..08fb6af73b 100644 --- a/src/fileFormats/ensight/part/ensightPartFaces.H +++ b/src/fileFormats/ensight/part/ensightPartFaces.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,10 +64,10 @@ class ensightPartFaces //- Patch index const label patchIndex_; - //- Faces referenced + //- The referenced faces const faceList& faces_; - //- pointField referenced + //- The referenced pointField const pointField& points_; //- Can skip local point renumbering when points are contiguous @@ -127,11 +127,22 @@ public: ); //- Construct from polyMesh and polyPatch + //- Part receives the name of the patch unless otherwise specified. ensightPartFaces ( label partIndex, const polyMesh& mesh, - const polyPatch& patch + const polyPatch& patch, + const string& partName = "" + ); + + //- Construct from polyPatch + //- Part receives the name of the patch unless otherwise specified. + ensightPartFaces + ( + label partIndex, + const polyPatch& patch, + const string& partName = "" ); @@ -169,15 +180,14 @@ public: //- Write summary information about the object virtual void writeSummary(Ostream& os) const; + //- Print various types of debugging information + virtual void dumpInfo(Ostream& os) const; + //- Write geometry virtual void write(ensightGeoFile& os) const; //- Helper: write geometry given the pointField virtual void write(ensightGeoFile& os, const pointField& points) const; - - - //- Print various types of debugging information - virtual void dumpInfo(Ostream& os) const; }; diff --git a/src/fileFormats/ensight/part/ensightParts.C b/src/fileFormats/ensight/part/ensightParts.C index 9c3486a609..70baac4647 100644 --- a/src/fileFormats/ensight/part/ensightParts.C +++ b/src/fileFormats/ensight/part/ensightParts.C @@ -28,6 +28,7 @@ License #include "ensightParts.H" #include "bitSet.H" +#include "emptyPolyPatch.H" #include "processorPolyPatch.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -51,44 +52,48 @@ void Foam::ensightParts::recalculate(const polyMesh& mesh) // Track which cells are in a zone or not bitSet selection(mesh.nCells()); - // Do cell zones + // Do all cell zones for (const cellZone& zn : mesh.cellZones()) { - if (zn.size()) + if (returnReduce(!zn.empty(), orOp())) { selection.set(zn); this->append(new ensightPartCells(nPart++, mesh, zn)); } } - if (selection.none()) + if (!nPart) { - // No zones at all? - do entire mesh - this->append(new ensightPartCells(nPart++, mesh)); + // No zones at all? - do entire mesh. Name as per ensightMesh + this->append(new ensightPartCells(nPart++, mesh, "internalMesh")); } else { // Flip from zoned to unzoned selection.flip(); - if (selection.any()) + if (returnReduce(selection.any(), orOp())) { - this->append(new ensightPartCells(nPart++, mesh, selection)); + this->append + ( + new ensightPartCells(nPart++, mesh, selection, "__internal__") + ); } } // Do boundaries, skipping empty and processor patches - for (const polyPatch& patch : mesh.boundaryMesh()) + for (const polyPatch& p : mesh.boundaryMesh()) { - if (isA(patch)) + if (isA(p)) { // No processor patches break; } - if (patch.size()) + + if (returnReduce(!p.empty(), orOp())) { - this->append(new ensightPartFaces(nPart++, mesh, patch)); + this->append(new ensightPartFaces(nPart++, mesh, p)); } } } diff --git a/src/fileFormats/ensight/part/ensightParts.H b/src/fileFormats/ensight/part/ensightParts.H index 5b08547ce4..6ee3b3b1f1 100644 --- a/src/fileFormats/ensight/part/ensightParts.H +++ b/src/fileFormats/ensight/part/ensightParts.H @@ -83,15 +83,14 @@ public: // Member Functions - //- Clear old information and construct anew from polyMesh - void recalculate(const polyMesh& mesh); - //- Number of parts using StorageType::size; + //- Clear old information and construct anew from polyMesh + void recalculate(const polyMesh& mesh); - //- Write the geometry - void write(ensightGeoFile& os) const; + + // Output //- Write summary information about the objects void writeSummary(Ostream& os) const; @@ -99,6 +98,14 @@ public: //- Print various types of debugging information void dumpInfo(Ostream& os) const; + //- Write the geometry to file + void write(autoPtr& os) const + { + write(os.ref()); + } + + //- Write the geometry to file + void write(ensightGeoFile& os) const; };