diff --git a/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H b/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H index f42149adc9..b514960c4b 100644 --- a/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H +++ b/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H @@ -152,7 +152,7 @@ Description if ( - !cleanupPatches.found(patchName) + !cleanupPatches.contains(patchName) || returnReduceOr(oldPatches[patchi].size()) ) { @@ -188,8 +188,9 @@ Description // Cleanup empty merged point zones { - PtrList& zones = mesh.pointZones(); - mesh.pointZones().clearAddressing(); + auto& zmesh = mesh.pointZones(); + zmesh.clearAddressing(); + PtrList& zones = zmesh; wordHashSet removedZones(2*zones.size()); @@ -198,12 +199,11 @@ Description { if ( - !cleanupPointZones.found(zones[zonei].name()) + !cleanupPointZones.contains(zones[zonei].name()) || returnReduceOr(zones[zonei].size()) ) { zones.set(nZones, zones.release(zonei)); - zones[nZones].index() = nZones; // re-index ++nZones; } else @@ -212,6 +212,7 @@ Description } } zones.resize(nZones); + zmesh.reindex(); if (removedZones.size()) { @@ -223,8 +224,9 @@ Description // Cleanup empty merged face zones { - PtrList& zones = mesh.faceZones(); - mesh.faceZones().clearAddressing(); + auto& zmesh = mesh.faceZones(); + zmesh.clearAddressing(); + PtrList& zones = zmesh; wordHashSet removedZones(2*zones.size()); @@ -233,12 +235,11 @@ Description { if ( - !cleanupFaceZones.found(zones[zonei].name()) + !cleanupFaceZones.contains(zones[zonei].name()) || returnReduceOr(zones[zonei].size()) ) { zones.set(nZones, zones.release(zonei)); - zones[nZones].index() = nZones; // re-index ++nZones; } else @@ -247,6 +248,7 @@ Description } } zones.resize(nZones); + zmesh.reindex(); if (removedZones.size()) { diff --git a/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C b/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C index ebbe91e718..0ac94b7a3f 100644 --- a/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C +++ b/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C @@ -33,7 +33,6 @@ License Foam::patchIdentifier::patchIdentifier() : - name_(), index_(0) {} diff --git a/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.C b/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.C index abe0b802ed..892b419301 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.C +++ b/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.C @@ -33,15 +33,15 @@ License Foam::geometricSurfacePatch::geometricSurfacePatch() : - geometricSurfacePatch(0) + name_("patch"), + index_(0) {} Foam::geometricSurfacePatch::geometricSurfacePatch(const label index) : name_("patch"), - index_(index), - geometricType_() + index_(index) {} @@ -52,8 +52,7 @@ Foam::geometricSurfacePatch::geometricSurfacePatch ) : name_(name), - index_(index), - geometricType_() + index_(index) {} diff --git a/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.H b/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.H index 382a24779c..0d5813393e 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.H +++ b/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.H @@ -36,8 +36,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef geometricSurfacePatch_H -#define geometricSurfacePatch_H +#ifndef Foam_geometricSurfacePatch_H +#define Foam_geometricSurfacePatch_H #include "surfZoneIdentifier.H" #include "stdFoam.H" @@ -106,9 +106,16 @@ public: //- Copy construct geometricSurfacePatch(const geometricSurfacePatch&) = default; + //- Move construct + geometricSurfacePatch(geometricSurfacePatch&&) = default; + //- Copy assignment geometricSurfacePatch& - operator=(const geometricSurfacePatch&) = default; + operator=(const geometricSurfacePatch&) = default; + + //- Move assignment + geometricSurfacePatch& + operator=(geometricSurfacePatch&&) = default; // Constructors @@ -147,40 +154,22 @@ public: // Member Functions //- The patch/zone name - const word& name() const noexcept - { - return name_; - } + const word& name() const noexcept { return name_; } //- Modifiable patch/zone name - word& name() noexcept - { - return name_; - } + word& name() noexcept { return name_; } //- The index of this patch/zone in the surface mesh - label index() const noexcept - { - return index_; - } + label index() const noexcept { return index_; } //- Modifiable index of this patch/zone in the surface mesh - label& index() noexcept - { - return index_; - } + label& index() noexcept { return index_; } //- The geometric type of the patch/zone - const word& geometricType() const noexcept - { - return geometricType_; - } + const word& geometricType() const noexcept { return geometricType_; } //- Modifiable geometric type of the patch/zone - word& geometricType() noexcept - { - return geometricType_; - } + word& geometricType() noexcept { return geometricType_; } //- Write (geometricType) dictionary entry //- (without surrounding braces) diff --git a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C index deb490c8a0..d717bc184d 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C +++ b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,15 +33,13 @@ License Foam::surfZoneIdentifier::surfZoneIdentifier() : - surfZoneIdentifier(0) + index_(0) {} Foam::surfZoneIdentifier::surfZoneIdentifier(const label index) : - name_(), - index_(index), - geometricType_() + index_(index) {} @@ -52,8 +50,7 @@ Foam::surfZoneIdentifier::surfZoneIdentifier ) : name_(name), - index_(index), - geometricType_() + index_(index) {} @@ -77,9 +74,7 @@ Foam::surfZoneIdentifier::surfZoneIdentifier const label index ) : - name_(name), - index_(index), - geometricType_() + surfZoneIdentifier(name, index) { dict.readIfPresent("geometricType", geometricType_); } @@ -88,13 +83,31 @@ Foam::surfZoneIdentifier::surfZoneIdentifier Foam::surfZoneIdentifier::surfZoneIdentifier ( const surfZoneIdentifier& ident, - const label index + const label newIndex ) : - name_(ident.name_), - index_(index), - geometricType_(ident.geometricType_) -{} + surfZoneIdentifier(ident) +{ + if (newIndex >= 0) + { + index_ = newIndex; + } +} + + +Foam::surfZoneIdentifier::surfZoneIdentifier +( + surfZoneIdentifier&& ident, + const label newIndex +) +: + surfZoneIdentifier(std::move(ident)) +{ + if (newIndex >= 0) + { + index_ = newIndex; + } +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H index 4a94e7bd04..1eebd37068 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H +++ b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,8 +39,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef surfZoneIdentifier_H -#define surfZoneIdentifier_H +#ifndef Foam_surfZoneIdentifier_H +#define Foam_surfZoneIdentifier_H #include "word.H" #include "label.H" @@ -97,16 +97,22 @@ public: //- Copy construct surfZoneIdentifier(const surfZoneIdentifier&) = default; + //- Move construct + surfZoneIdentifier(surfZoneIdentifier&&) = default; + //- Copy assignment surfZoneIdentifier& operator=(const surfZoneIdentifier&) = default; + //- Move assignment + surfZoneIdentifier& operator=(surfZoneIdentifier&&) = default; + // Constructors //- Default construct. Uses name="", index=0 surfZoneIdentifier(); - //- Construct null with specified index + //- Construct with name="" and specified index explicit surfZoneIdentifier(const label index); //- Construct from mandatory components @@ -128,51 +134,40 @@ public: const label index ); - //- Copy construct, resetting the index + //- Copy construct, resetting the index (if non-negative) surfZoneIdentifier ( const surfZoneIdentifier& ident, - const label index + const label newIndex + ); + + //- Move construct, resetting the index (if non-negative) + surfZoneIdentifier + ( + surfZoneIdentifier&& ident, + const label newIndex ); // Member Functions //- The patch/zone name - const word& name() const - { - return name_; - } + const word& name() const noexcept { return name_; } //- Modifiable patch/zone name - word& name() - { - return name_; - } + word& name() noexcept { return name_; } - //- The geometric type of the patch/zone - const word& geometricType() const - { - return geometricType_; - } + //- The (optional) geometric type of the patch/zone + const word& geometricType() const noexcept { return geometricType_; } - //- Modifiable geometric type of the patch/zone - word& geometricType() - { - return geometricType_; - } + //- Modifiable (optional) geometric type of the patch/zone + word& geometricType() noexcept { return geometricType_; } //- The index of this patch/zone in the surface mesh - label index() const - { - return index_; - } + label index() const noexcept { return index_; } //- Modifiable index of this patch/zone in the surface mesh - label& index() - { - return index_; - } + label& index() noexcept { return index_; } //- Write (geometricType) dictionary entry //- (without surrounding braces) diff --git a/src/OpenFOAM/meshes/Identifiers/zone/zoneIdentifier.C b/src/OpenFOAM/meshes/Identifiers/zone/zoneIdentifier.C index a1b5888317..21091d3795 100644 --- a/src/OpenFOAM/meshes/Identifiers/zone/zoneIdentifier.C +++ b/src/OpenFOAM/meshes/Identifiers/zone/zoneIdentifier.C @@ -32,7 +32,6 @@ License Foam::zoneIdentifier::zoneIdentifier() : - name_(), index_(0) {} diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index bc3611feb5..608fad8a70 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -1506,7 +1506,10 @@ void Foam::polyBoundaryMesh::writeEntry if (!keyword.empty()) { os.write(keyword); - os << (entries.empty() ? token::SPACE : token::NL); + if (entries.empty()) + { + os << token::SPACE; + } } writeEntry(os); diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C index f6b1683040..fb047ee2c0 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C @@ -530,6 +530,32 @@ const } +template +bool Foam::ZoneMesh::reindex() +{ + PtrList& zones = *this; + + bool changed = false; + + // Adapt indices + forAll(zones, zonei) + { + if (zones[zonei].index() != zonei) + { + zones[zonei].index() = zonei; + changed = true; + } + } + + if (changed) + { + this->clearLocalAddressing(); + } + + return changed; +} + + template Foam::labelList Foam::ZoneMesh::indices ( @@ -1069,16 +1095,76 @@ void Foam::ZoneMesh::updateMetaData() } else { - dictionary& meta = this->getMetaData(); - meta.set("names", zoneNames); + // Save as a list of names without the leading size + tokenList toks(2+zoneNames.size()); + + auto iter = toks.begin(); + (*iter).pToken(token::BEGIN_LIST); + iter = std::move(zoneNames.begin(), zoneNames.end(), ++iter); + (*iter).pToken(token::END_LIST); + + this->getMetaData().set("names", std::move(toks)); } } +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +void Foam::ZoneMesh::writeEntry(Ostream& os) const +{ + const PtrList& entries = *this; + + os << entries.size(); + + if (entries.empty()) + { + // 0-sized : can write with less vertical space + os << token::BEGIN_LIST << token::END_LIST; + } + else + { + os << nl << token::BEGIN_LIST << nl; + + for (const auto& zn : entries) + { + os.beginBlock(zn.name()); + zn.write(os); + os.endBlock(); + } + os << token::END_LIST; + } +} + + +template +void Foam::ZoneMesh::writeEntry +( + const word& keyword, + Ostream& os +) const +{ + const PtrList& entries = *this; + + if (!keyword.empty()) + { + os.write(keyword); + if (entries.empty()) + { + os << token::SPACE; + } + } + + writeEntry(os); + + if (!keyword.empty()) os.endEntry(); +} + + template bool Foam::ZoneMesh::writeData(Ostream& os) const { - os << *this; + writeEntry(os); return os.good(); } @@ -1163,24 +1249,7 @@ Foam::Ostream& Foam::operator<< const ZoneMesh& zones ) { - const label sz = zones.size(); - - if (sz) - { - os << sz << nl << token::BEGIN_LIST; - - for (label i=0; i < sz; ++i) - { - zones[i].writeDict(os); - } - - os << token::END_LIST; - } - else - { - os << sz << token::BEGIN_LIST << token::END_LIST; - } - + zones.writeEntry(os); return os; } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H index 52106290d0..aec94bddf0 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H @@ -113,6 +113,9 @@ public: // Public Typedefs + //- The referenced mesh type + typedef MeshType mesh_type; + //- The zone type. Same as PtrList::value_type typedef ZoneType zone_type; @@ -226,6 +229,11 @@ public: //- Sorted list of zone names satisfying the input matchers wordList sortedNames(const wordRes& matcher) const; + //- Adjust the index of zone entries to be consistent with their + //- position in the list. + // If the indexing changed, invalidates any mapping. + // \returns true if the indexing changed. + bool reindex(); //- The (sorted) patch indices for all matches, //- optionally matching zone groups. @@ -380,8 +388,15 @@ public: //- Update internal meta-data (eg, prior to writing) void updateMetaData(); + //- Write as a plain list of entries + void writeEntry(Ostream& os) const; + + //- Write as a primitive entry with given name. + //- If the keyword is empty, revert to a plain list. + void writeEntry(const word& keyword, Ostream& os) const; + //- The writeData member function required by regIOobject - bool writeData(Ostream& os) const; + virtual bool writeData(Ostream& os) const; // Ostream Operator diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C index 092081f418..40045ba784 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,11 +27,10 @@ License \*---------------------------------------------------------------------------*/ #include "cellZone.H" -#include "addToRunTimeSelectionTable.H" #include "cellZoneMesh.H" #include "polyMesh.H" -#include "primitiveMesh.H" #include "IOstream.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -42,14 +41,12 @@ namespace Foam addToRunTimeSelectionTable(cellZone, cellZone, dictionary); } -const char * const Foam::cellZone::labelsName = "cellLabels"; - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::cellZone::cellZone(const cellZoneMesh& zm) : - cellZone(word::null, 0, zm) + zone(), + zoneMesh_(zm) {} @@ -99,7 +96,7 @@ Foam::cellZone::cellZone const cellZoneMesh& zm ) : - zone(name, dict, this->labelsName, index), + zone(name, dict, cellZone::labelsName(), index), zoneMesh_(zm) {} @@ -107,7 +104,19 @@ Foam::cellZone::cellZone Foam::cellZone::cellZone ( const cellZone& originalZone, - const Foam::zero, + const cellZoneMesh& zm, + const label newIndex +) +: + zone(originalZone, newIndex), + zoneMesh_(zm) +{} + + +Foam::cellZone::cellZone +( + const cellZone& originalZone, + Foam::zero, const cellZoneMesh& zm, const label newIndex ) @@ -120,7 +129,7 @@ Foam::cellZone::cellZone Foam::cellZone::cellZone ( const cellZone& originalZone, - const Foam::zero, + Foam::zero, const label index, const cellZoneMesh& zm ) @@ -160,28 +169,17 @@ Foam::cellZone::cellZone // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::label Foam::cellZone::whichCell(const label globalCellID) const +Foam::label Foam::cellZone::max_index() const noexcept { - return zone::localID(globalCellID); + return zoneMesh_.mesh().nCells(); } -bool Foam::cellZone::checkDefinition(const bool report) const -{ - return zone::checkDefinition(zoneMesh_.mesh().nCells(), report); -} - - -void Foam::cellZone::writeDict(Ostream& os) const -{ - os.beginBlock(name()); - - os.writeEntry("type", type()); - zoneIdentifier::write(os); - writeEntry(this->labelsName, os); - - os.endBlock(); -} +// void Foam::cellZone::sort() +// { +// clearAddressing(); +// Foam::sort(static_cast(*this)); +// } void Foam::cellZone::resetAddressing(cellZone&& zn) @@ -223,6 +221,13 @@ void Foam::cellZone::resetAddressing(labelList&& addr) } +void Foam::cellZone::write(Ostream& os) const +{ + zone::write(os); + labelList::writeEntry(cellZone::labelsName(), os); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // void Foam::cellZone::operator=(const cellZone& zn) diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H index 00279ef242..22b94776bf 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -75,8 +75,7 @@ public: // Static Data Members //- The name associated with the zone-labels dictionary entry - //- ("cellLabels") - static const char * const labelsName; + static constexpr const char* labelsName() { return "cellLabels"; } //- Runtime type information @@ -143,13 +142,23 @@ public: const cellZoneMesh& zm ); - //- Construct empty with original zone information (name, index, groups) - //- and mesh reference. Optionally specify a new index. + //- Copy construct with new mesh reference. cellZone ( const cellZone& originalZone, - const Foam::zero, const cellZoneMesh& zm, + //! The new index (optional. -1 retains the original value) + const label newIndex = -1 + ); + + //- Construct empty with original zone information (name, index, groups) + //- and mesh reference. + cellZone + ( + const cellZone& originalZone, + Foam::zero, + const cellZoneMesh& zm, + //! The new index (optional. -1 retains the original value) const label newIndex = -1 ); @@ -158,7 +167,8 @@ public: cellZone ( const cellZone& originalZone, - const Foam::zero, + Foam::zero, + //! The new index (-1 retains the original value) const label index, const cellZoneMesh& zm ); @@ -169,6 +179,7 @@ public: ( const cellZone& originalZone, const labelUList& addr, + //! The new index (-1 retains the original value) const label index, const cellZoneMesh& zm ); @@ -179,15 +190,21 @@ public: ( const cellZone& originalZone, labelList&& addr, + //! The new index (-1 retains the original value) const label index, const cellZoneMesh& zm ); //- Construct and return a clone, resetting the zone mesh - virtual autoPtr clone(const cellZoneMesh& zm) const + virtual autoPtr clone + ( + const cellZoneMesh& zm, + //! The new index (optional. -1 retains the original value) + const label newIndex = -1 + ) const { - return autoPtr::New(*this, *this, index(), zm); + return autoPtr::New(*this, zm, newIndex); } //- Construct and return a clone, @@ -195,6 +212,7 @@ public: virtual autoPtr clone ( const labelUList& addr, + //! The new index (-1 retains the original value) const label index, const cellZoneMesh& zm ) const @@ -222,21 +240,30 @@ public: // Member Functions + //- The maximum index the zone may contain == mesh nCells() + label max_index() const noexcept; + //- Return reference to the zone mesh const cellZoneMesh& zoneMesh() const noexcept { return zoneMesh_; } //- The addressing (cell IDs) used for the zone - const labelList& addressing() const noexcept + using zone::addressing; + + //- The local index of the given mesh cell, -1 if not in the zone + label whichCell(const label meshCellID) const { - return static_cast(*this); + return zone::localID(meshCellID); } - //- Helper function to re-direct to zone::localID(...) - label whichCell(const label globalCellID) const; + // Checks - //- Check zone definition. Return true if in error. - virtual bool checkDefinition(const bool report = false) const; + //- Check zone definition. + // \return True if any errors. + virtual bool checkDefinition(const bool report = false) const + { + return zone::checkDefinition(max_index(), report); + } //- Check whether zone is synchronised across coupled boundaries. // \return True if any errors. @@ -245,9 +272,6 @@ public: return false; } - //- Write dictionary - virtual void writeDict(Ostream& os) const; - // Assign addressing @@ -275,8 +299,22 @@ public: // I-O + //- Write (dictionary entries) + virtual void write(Ostream& os) const; + //- Ostream Operator friend Ostream& operator<<(Ostream& os, const cellZone& zn); + + + // Housekeeping + + //- Deprecated(2025-09) Write dictionary + // \deprecated(2025-09) Write dictionary + FOAM_DEPRECATED_FOR(2025-09, "write() or operator<<") + void writeDict(Ostream& os) const + { + os.beginBlock(name()); write(os); os.endBlock(); + } }; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZoneMesh.H similarity index 100% rename from src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMesh.H rename to src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZoneMesh.H diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZoneMeshFwd.H similarity index 96% rename from src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H rename to src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZoneMeshFwd.H index d64a8acc0a..53d5baa7ed 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/cellZoneMeshFwd.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZoneMeshFwd.H @@ -41,7 +41,7 @@ namespace Foam class cellZone; class polyMesh; - template class ZoneMesh; + template class ZoneMesh; typedef ZoneMesh cellZoneMesh; } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C index d943495ddf..67916f9caf 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,12 +27,11 @@ License \*---------------------------------------------------------------------------*/ #include "faceZone.H" -#include "addToRunTimeSelectionTable.H" #include "faceZoneMesh.H" #include "polyMesh.H" -#include "primitiveMesh.H" #include "mapPolyMesh.H" #include "syncTools.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -43,8 +42,6 @@ namespace Foam addToRunTimeSelectionTable(faceZone, faceZone, dictionary); } -const char* const Foam::faceZone::labelsName = "faceLabels"; - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -220,7 +217,8 @@ void Foam::faceZone::checkAddressing() const Foam::faceZone::faceZone(const faceZoneMesh& zm) : - faceZone(word::null, 0, zm) + zone(), + zoneMesh_(zm) {} @@ -329,10 +327,10 @@ Foam::faceZone::faceZone const faceZoneMesh& zm ) : - zone(name, dict, this->labelsName, index), - flipMap_(dict.lookup("flipMap")), // OR: dict.get("flipMap") + zone(name, dict, faceZone::labelsName(), index), zoneMesh_(zm) { + dict.readEntry("flipMap", flipMap_, keyType::LITERAL); checkAddressing(); } @@ -340,7 +338,21 @@ Foam::faceZone::faceZone Foam::faceZone::faceZone ( const faceZone& originalZone, - const Foam::zero, + const faceZoneMesh& zm, + const label newIndex +) +: + zone(originalZone, newIndex), + zoneMesh_(zm) +{ + flipMap_ = originalZone.flipMap(); +} + + +Foam::faceZone::faceZone +( + const faceZone& originalZone, + Foam::zero, const faceZoneMesh& zm, const label newIndex ) @@ -353,7 +365,7 @@ Foam::faceZone::faceZone Foam::faceZone::faceZone ( const faceZone& originalZone, - const Foam::zero, + Foam::zero, const label index, const faceZoneMesh& zm ) @@ -401,12 +413,23 @@ Foam::faceZone::faceZone // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::label Foam::faceZone::whichFace(const label globalFaceID) const +Foam::label Foam::faceZone::max_index() const noexcept { - return zone::localID(globalFaceID); + return zoneMesh_.mesh().nFaces(); } +// void Foam::faceZone::sort() +// { +// clearAddressing(); +// auto& addr = static_cast(*this); +// +// auto order = Foam::sortedOrder(addr); +// addr = labelList(addr, order); +// flipMap_ = boolList(flipMap_, order); +// } + + const Foam::primitiveFacePatch& Foam::faceZone::patch() const { if (!patchPtr_) @@ -483,7 +506,6 @@ void Foam::faceZone::clearPrimitives() void Foam::faceZone::resetAddressing(faceZone&& zn) { - // TDB: clearGeom(); if (this == &zn) { return; // Self-assignment is a no-op @@ -498,7 +520,6 @@ void Foam::faceZone::resetAddressing(faceZone&& zn) void Foam::faceZone::resetAddressing(const faceZone& zn) { - // TDB: clearGeom(); if (this == &zn) { return; // Self-assignment is a no-op @@ -578,12 +599,6 @@ void Foam::faceZone::updateMesh(const mapPolyMesh& mpm) } -bool Foam::faceZone::checkDefinition(const bool report) const -{ - return zone::checkDefinition(zoneMesh().mesh().faces().size(), report); -} - - bool Foam::faceZone::checkParallelSync(const bool report) const { const polyMesh& mesh = zoneMesh().mesh(); @@ -683,24 +698,12 @@ void Foam::faceZone::movePoints(const pointField& pts) } } + void Foam::faceZone::write(Ostream& os) const { - os << nl << name() - << nl << static_cast(*this) - << nl << flipMap(); -} - - -void Foam::faceZone::writeDict(Ostream& os) const -{ - os.beginBlock(name()); - - os.writeEntry("type", type()); - zoneIdentifier::write(os); - writeEntry(this->labelsName, os); - flipMap().writeEntry("flipMap", os); - - os.endBlock(); + zone::write(os); + labelList::writeEntry(faceZone::labelsName(), os); + flipMap_.writeEntry("flipMap", os); } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H index 74bb5264e5..5328c4e63b 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -78,13 +78,13 @@ class faceZone // Private Data + //- Reference to zone list + const faceZoneMesh& zoneMesh_; + //- Flip map for all faces in the zone. // True if the face needs flipping for the correct orientation. boolList flipMap_; - //- Reference to zone list - const faceZoneMesh& zoneMesh_; - //- Demand-driven: Primitive patch of correctly flipped faces mutable std::unique_ptr patchPtr_; @@ -120,8 +120,7 @@ public: // Static Data Members //- The name associated with the zone-labels dictionary entry - //- ("faceLabels") - static const char * const labelsName; + static constexpr const char* labelsName() { return "faceLabels"; } //- Runtime type information @@ -211,13 +210,23 @@ public: const faceZoneMesh& zm ); - //- Construct empty with original zone information (name, index, groups) - //- and mesh reference. Optionally specify a new index. + //- Copy construct with new mesh reference. faceZone ( const faceZone& originalZone, - const Foam::zero, const faceZoneMesh& zm, + //! The new index (optional. -1 retains the original value) + const label newIndex = -1 + ); + + //- Construct empty with original zone information (name, index, groups) + //- and mesh reference. + faceZone + ( + const faceZone& originalZone, + Foam::zero, + const faceZoneMesh& zm, + //! The new index (optional. -1 retains the original value) const label newIndex = -1 ); @@ -226,7 +235,8 @@ public: faceZone ( const faceZone& originalZone, - const Foam::zero, + Foam::zero, + //! The new index (-1 retains the original value) const label index, const faceZoneMesh& zm ); @@ -239,6 +249,7 @@ public: const faceZone& originalZone, const labelUList& addr, const boolUList& fm, + //! The new index (-1 retains the original value) const label index, const faceZoneMesh& zm ); @@ -251,14 +262,20 @@ public: const faceZone& originalZone, labelList&& addr, boolList&& fm, + //! The new index (-1 retains the original value) const label index, const faceZoneMesh& zm ); //- Construct and return a clone, resetting the zone mesh - virtual autoPtr clone(const faceZoneMesh& zm) const + virtual autoPtr clone + ( + const faceZoneMesh& zm, + //! The new index (optional. -1 retains the original value) + const label newIndex = -1 + ) const { - return autoPtr::New(*this, *this, flipMap(), index(), zm); + return autoPtr::New(*this, zm, newIndex); } //- Construct and return a clone, @@ -267,6 +284,7 @@ public: ( const labelUList& addr, const boolUList& fm, + //! The new index (-1 retains the original value) const label index, const faceZoneMesh& zm ) const @@ -294,26 +312,43 @@ public: // Member Functions + //- The maximum index the zone may contain == mesh nFaces() + label max_index() const noexcept; + //- Return reference to the zone mesh const faceZoneMesh& zoneMesh() const noexcept { return zoneMesh_; } //- The addressing (face IDs) used for the zone - const labelList& addressing() const noexcept - { - return static_cast(*this); - } + using zone::addressing; //- Return face flip map const boolList& flipMap() const noexcept { return flipMap_; } - //- Helper function to re-direct to zone::localID(...) - label whichFace(const label globalCellID) const; + //- The local index of the given mesh face, -1 if not in the zone + label whichFace(const label meshFaceID) const + { + return zone::localID(meshFaceID); + } //- Return [demand-driven] reference to an equivalent primitive patch, //- with faces oriented according to flipMap() const primitiveFacePatch& patch() const; + // Checks + + //- Check zone definition. + // \return True if any errors. + virtual bool checkDefinition(const bool report = false) const + { + return zone::checkDefinition(max_index(), report); + } + + //- Check whether all procs have faces synchronised. + // \return True if any errors. + virtual bool checkParallelSync(const bool report = false) const; + + // Addressing into mesh //- The front cells layer. @@ -329,25 +364,6 @@ public: //- Return global edge index for local edges const labelList& meshEdges() const; - //- Check zone definition. Return true if in error. - virtual bool checkDefinition(const bool report = false) const; - - //- Check whether all procs have faces synchronised. - // \return True if any errors. - virtual bool checkParallelSync(const bool report = false) const; - - //- Correct patch after moving points - virtual void movePoints(const pointField& pts); - - //- Update for changes in topology - virtual void updateMesh(const mapPolyMesh& mpm); - - //- Write - virtual void write(Ostream& os) const; - - //- Write dictionary - virtual void writeDict(Ostream& os) const; - // Assign addressing @@ -392,8 +408,20 @@ public: void operator=(const faceZone& zn); + // Mesh Changes + + //- Correct patch after moving points + virtual void movePoints(const pointField& pts); + + //- Update for changes in topology + virtual void updateMesh(const mapPolyMesh& mpm); + + // I-O + //- Write (dictionary entries) + virtual void write(Ostream& os) const; + //- Ostream Operator friend Ostream& operator<<(Ostream& os, const faceZone& zn); @@ -411,6 +439,14 @@ public: //- Deprecated(2023-09) same as backCells // \deprecated(2023-09) same as backCells #1832 const labelList& slaveCells() const { return backCells(); } + + //- Deprecated(2025-09) Write dictionary + // \deprecated(2025-09) Write dictionary + FOAM_DEPRECATED_FOR(2025-09, "write() or operator<<") + void writeDict(Ostream& os) const + { + os.beginBlock(name()); write(os); os.endBlock(); + } }; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZoneMesh.H similarity index 100% rename from src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMesh.H rename to src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZoneMesh.H diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZoneMeshFwd.H similarity index 96% rename from src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H rename to src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZoneMeshFwd.H index 277d14c712..bc6c9a82d4 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/faceZoneMeshFwd.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZoneMeshFwd.H @@ -41,7 +41,7 @@ namespace Foam class faceZone; class polyMesh; - template class ZoneMesh; + template class ZoneMesh; typedef ZoneMesh faceZoneMesh; } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C index 6e0b3e558c..31be0b862c 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,11 +27,10 @@ License \*---------------------------------------------------------------------------*/ #include "pointZone.H" -#include "addToRunTimeSelectionTable.H" #include "pointZoneMesh.H" #include "polyMesh.H" -#include "primitiveMesh.H" #include "syncTools.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -42,14 +41,13 @@ namespace Foam addToRunTimeSelectionTable(pointZone, pointZone, dictionary); } -const char* const Foam::pointZone::labelsName = "pointLabels"; - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::pointZone::pointZone(const pointZoneMesh& zm) : - pointZone(word::null, 0, zm) + zone(), + zoneMesh_(zm) {} @@ -99,7 +97,7 @@ Foam::pointZone::pointZone const pointZoneMesh& zm ) : - zone(name, dict, this->labelsName, index), + zone(name, dict, pointZone::labelsName(), index), zoneMesh_(zm) {} @@ -107,7 +105,19 @@ Foam::pointZone::pointZone Foam::pointZone::pointZone ( const pointZone& originalZone, - const Foam::zero, + const pointZoneMesh& zm, + const label newIndex +) +: + zone(originalZone, newIndex), + zoneMesh_(zm) +{} + + +Foam::pointZone::pointZone +( + const pointZone& originalZone, + Foam::zero, const pointZoneMesh& zm, const label newIndex ) @@ -120,12 +130,12 @@ Foam::pointZone::pointZone Foam::pointZone::pointZone ( const pointZone& originalZone, - const Foam::zero, - const label index, + Foam::zero, + const label newIndex, const pointZoneMesh& zm ) : - zone(originalZone, labelList(), index), + zone(originalZone, labelList(), newIndex), zoneMesh_(zm) {} @@ -160,16 +170,17 @@ Foam::pointZone::pointZone // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::label Foam::pointZone::whichPoint(const label globalPointID) const +Foam::label Foam::pointZone::max_index() const noexcept { - return zone::localID(globalPointID); + return zoneMesh_.mesh().nPoints(); } -bool Foam::pointZone::checkDefinition(const bool report) const -{ - return zone::checkDefinition(zoneMesh_.mesh().points().size(), report); -} +// void Foam::pointZone::sort() +// { +// clearAddressing(); +// Foam::sort(static_cast(*this)); +// } bool Foam::pointZone::checkParallelSync(const bool report) const @@ -226,18 +237,6 @@ bool Foam::pointZone::checkParallelSync(const bool report) const } -void Foam::pointZone::writeDict(Ostream& os) const -{ - os.beginBlock(name()); - - os.writeEntry("type", type()); - zoneIdentifier::write(os); - writeEntry(this->labelsName, os); - - os.endBlock(); -} - - void Foam::pointZone::resetAddressing(pointZone&& zn) { if (this == &zn) @@ -277,6 +276,13 @@ void Foam::pointZone::resetAddressing(labelList&& addr) } +void Foam::pointZone::write(Ostream& os) const +{ + zone::write(os); + labelList::writeEntry(pointZone::labelsName(), os); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // void Foam::pointZone::operator=(const pointZone& zn) diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H index 987080dea2..0ed7aabf85 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZone.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -77,8 +77,7 @@ public: // Static Data Members //- The name associated with the zone-labels dictionary entry - //- ("pointLabels") - static const char * const labelsName; + static constexpr const char* labelsName() { return "pointLabels"; } //- Runtime type information @@ -145,13 +144,23 @@ public: const pointZoneMesh& zm ); - //- Construct empty with original zone information (name, index, groups) - //- and mesh reference. Optionally specify a new index. + //- Copy construct with new mesh reference. pointZone ( const pointZone& originalZone, - const Foam::zero, const pointZoneMesh& zm, + //! The new index (optional. -1 retains the original value) + const label newIndex = -1 + ); + + //- Construct empty with original zone information (name, index, groups) + //- and mesh reference. + pointZone + ( + const pointZone& originalZone, + Foam::zero, + const pointZoneMesh& zm, + //! The new index (optional. -1 retains the original value) const label newIndex = -1 ); @@ -160,7 +169,8 @@ public: pointZone ( const pointZone& originalZone, - const Foam::zero, + Foam::zero, + //! The new index (-1 retains the original value) const label index, const pointZoneMesh& zm ); @@ -171,6 +181,7 @@ public: ( const pointZone& originalZone, const labelUList& addr, + //! The new index (-1 retains the original value) const label index, const pointZoneMesh& zm ); @@ -181,22 +192,29 @@ public: ( const pointZone& originalZone, labelList&& addr, + //! The new index (-1 retains the original value) const label index, const pointZoneMesh& zm ); //- Construct and return a clone, resetting the zone mesh - virtual autoPtr clone(const pointZoneMesh& zm) const - { - return autoPtr::New(*this, *this, index(), zm); - } - - //- Construct and return a clone, resetting the point list - //- and zone mesh virtual autoPtr clone ( const pointZoneMesh& zm, + //! The new index (optional. -1 retains the original value) + const label newIndex = -1 + ) const + { + return autoPtr::New(*this, zm, newIndex); + } + + //- Construct and return a clone, + //- resetting the point list and zone mesh + virtual autoPtr clone + ( + const pointZoneMesh& zm, + //! The new index (-1 retains the original value) const label index, const labelUList& addr ) const @@ -224,33 +242,35 @@ public: // Member Functions + //- The maximum index the zone may contain == mesh nPoints() + label max_index() const noexcept; + //- Return reference to the zone mesh const pointZoneMesh& zoneMesh() const noexcept { return zoneMesh_; } //- The addressing (point IDs) used for the zone - const labelList& addressing() const noexcept + using zone::addressing; + + //- The local index of the given mesh point, -1 if not in the zone + label whichPoint(const label meshPointID) const { - return static_cast(*this); + return zone::localID(meshPointID); } - //- Helper function to re-direct to zone::localID(...) - label whichPoint(const label globalPointID) const; + // Checks - //- Check zone definition. Return true if in error. - virtual bool checkDefinition(const bool report = false) const; + //- Check zone definition. + // \return True if any errors. + virtual bool checkDefinition(const bool report = false) const + { + return zone::checkDefinition(max_index(), report); + } //- Check whether zone is synchronised across coupled boundaries. // \return True if any errors. virtual bool checkParallelSync(const bool report = false) const; - //- Correct patch after moving points - virtual void movePoints(const pointField&) - {} - - //- Write dictionary - virtual void writeDict(Ostream& os) const; - // Assign addressing @@ -276,10 +296,31 @@ public: void operator=(labelList&& addr); + // Mesh Changes + + //- Nothing to correct after moving points + virtual void movePoints(const pointField&) + {} + + // I-O + //- Write (dictionary entries) + virtual void write(Ostream& os) const; + //- Ostream Operator friend Ostream& operator<<(Ostream& os, const pointZone& zn); + + + // Housekeeping + + //- Deprecated(2025-09) Write dictionary + // \deprecated(2025-09) Write dictionary + FOAM_DEPRECATED_FOR(2025-09, "write() or operator<<") + void writeDict(Ostream& os) const + { + os.beginBlock(name()); write(os); os.endBlock(); + } }; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZoneMesh.H similarity index 100% rename from src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMesh.H rename to src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZoneMesh.H diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZoneMeshFwd.H similarity index 96% rename from src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H rename to src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZoneMeshFwd.H index a15559d780..df1178cc45 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/pointZoneMeshFwd.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/pointZoneMeshFwd.H @@ -41,7 +41,7 @@ namespace Foam class pointZone; class polyMesh; - template class ZoneMesh; + template class ZoneMesh; typedef ZoneMesh pointZoneMesh; } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C index 28d017d11b..284d3d767f 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2025 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,17 +43,13 @@ namespace Foam Foam::zone::zone() : - zoneIdentifier(), - labelList(), - lookupMapPtr_(nullptr) + zoneIdentifier() {} Foam::zone::zone(const word& name, const label index) : - zoneIdentifier(name, index), - labelList(), - lookupMapPtr_(nullptr) + zoneIdentifier(name, index) {} @@ -91,9 +87,23 @@ Foam::zone::zone const label index ) : - zoneIdentifier(name, dict, index), - labelList(dict.get(labelsName)), - lookupMapPtr_(nullptr) + zoneIdentifier(name, dict, index) +{ + if (!labelsName.empty()) + { + dict.readEntry(labelsName, *this, keyType::LITERAL); + } +} + + +Foam::zone::zone +( + const zone& originalZone, + const label newIndex +) +: + zoneIdentifier(originalZone, newIndex), + labelList(originalZone) {} @@ -105,8 +115,7 @@ Foam::zone::zone ) : zoneIdentifier(originalZone, newIndex), - labelList(addr), - lookupMapPtr_(nullptr) + labelList(addr) {} @@ -118,8 +127,7 @@ Foam::zone::zone ) : zoneIdentifier(originalZone, newIndex), - labelList(std::move(addr)), - lookupMapPtr_(nullptr) + labelList(std::move(addr)) {} @@ -131,8 +139,9 @@ const Foam::Map& Foam::zone::lookupMap() const { const labelList& addr = *this; - lookupMapPtr_.reset(new Map