ENH: align zones writing pattern with polyBoundaryMesh, patchField etc.

STYLE: output the zone meta data (names) as an undecorated wordList

ENH: extra safety check in reorderZones to avoid any possible leaking
This commit is contained in:
Mark Olesen
2025-09-01 14:48:12 +02:00
parent c378893bcb
commit ac1c41a51b
32 changed files with 1236 additions and 357 deletions

View File

@ -152,7 +152,7 @@ Description
if if
( (
!cleanupPatches.found(patchName) !cleanupPatches.contains(patchName)
|| returnReduceOr(oldPatches[patchi].size()) || returnReduceOr(oldPatches[patchi].size())
) )
{ {
@ -188,8 +188,9 @@ Description
// Cleanup empty merged point zones // Cleanup empty merged point zones
{ {
PtrList<pointZone>& zones = mesh.pointZones(); auto& zmesh = mesh.pointZones();
mesh.pointZones().clearAddressing(); zmesh.clearAddressing();
PtrList<pointZone>& zones = zmesh;
wordHashSet removedZones(2*zones.size()); wordHashSet removedZones(2*zones.size());
@ -198,12 +199,11 @@ Description
{ {
if if
( (
!cleanupPointZones.found(zones[zonei].name()) !cleanupPointZones.contains(zones[zonei].name())
|| returnReduceOr(zones[zonei].size()) || returnReduceOr(zones[zonei].size())
) )
{ {
zones.set(nZones, zones.release(zonei)); zones.set(nZones, zones.release(zonei));
zones[nZones].index() = nZones; // re-index
++nZones; ++nZones;
} }
else else
@ -212,6 +212,7 @@ Description
} }
} }
zones.resize(nZones); zones.resize(nZones);
zmesh.reindex();
if (removedZones.size()) if (removedZones.size())
{ {
@ -223,8 +224,9 @@ Description
// Cleanup empty merged face zones // Cleanup empty merged face zones
{ {
PtrList<faceZone>& zones = mesh.faceZones(); auto& zmesh = mesh.faceZones();
mesh.faceZones().clearAddressing(); zmesh.clearAddressing();
PtrList<faceZone>& zones = zmesh;
wordHashSet removedZones(2*zones.size()); wordHashSet removedZones(2*zones.size());
@ -233,12 +235,11 @@ Description
{ {
if if
( (
!cleanupFaceZones.found(zones[zonei].name()) !cleanupFaceZones.contains(zones[zonei].name())
|| returnReduceOr(zones[zonei].size()) || returnReduceOr(zones[zonei].size())
) )
{ {
zones.set(nZones, zones.release(zonei)); zones.set(nZones, zones.release(zonei));
zones[nZones].index() = nZones; // re-index
++nZones; ++nZones;
} }
else else
@ -247,6 +248,7 @@ Description
} }
} }
zones.resize(nZones); zones.resize(nZones);
zmesh.reindex();
if (removedZones.size()) if (removedZones.size())
{ {

View File

@ -33,7 +33,6 @@ License
Foam::patchIdentifier::patchIdentifier() Foam::patchIdentifier::patchIdentifier()
: :
name_(),
index_(0) index_(0)
{} {}

View File

@ -33,15 +33,15 @@ License
Foam::geometricSurfacePatch::geometricSurfacePatch() Foam::geometricSurfacePatch::geometricSurfacePatch()
: :
geometricSurfacePatch(0) name_("patch"),
index_(0)
{} {}
Foam::geometricSurfacePatch::geometricSurfacePatch(const label index) Foam::geometricSurfacePatch::geometricSurfacePatch(const label index)
: :
name_("patch"), name_("patch"),
index_(index), index_(index)
geometricType_()
{} {}
@ -52,8 +52,7 @@ Foam::geometricSurfacePatch::geometricSurfacePatch
) )
: :
name_(name), name_(name),
index_(index), index_(index)
geometricType_()
{} {}

View File

@ -36,8 +36,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef geometricSurfacePatch_H #ifndef Foam_geometricSurfacePatch_H
#define geometricSurfacePatch_H #define Foam_geometricSurfacePatch_H
#include "surfZoneIdentifier.H" #include "surfZoneIdentifier.H"
#include "stdFoam.H" #include "stdFoam.H"
@ -106,9 +106,16 @@ public:
//- Copy construct //- Copy construct
geometricSurfacePatch(const geometricSurfacePatch&) = default; geometricSurfacePatch(const geometricSurfacePatch&) = default;
//- Move construct
geometricSurfacePatch(geometricSurfacePatch&&) = default;
//- Copy assignment //- Copy assignment
geometricSurfacePatch& geometricSurfacePatch&
operator=(const geometricSurfacePatch&) = default; operator=(const geometricSurfacePatch&) = default;
//- Move assignment
geometricSurfacePatch&
operator=(geometricSurfacePatch&&) = default;
// Constructors // Constructors
@ -147,40 +154,22 @@ public:
// Member Functions // Member Functions
//- The patch/zone name //- The patch/zone name
const word& name() const noexcept const word& name() const noexcept { return name_; }
{
return name_;
}
//- Modifiable patch/zone name //- Modifiable patch/zone name
word& name() noexcept word& name() noexcept { return name_; }
{
return name_;
}
//- The index of this patch/zone in the surface mesh //- The index of this patch/zone in the surface mesh
label index() const noexcept label index() const noexcept { return index_; }
{
return index_;
}
//- Modifiable index of this patch/zone in the surface mesh //- Modifiable index of this patch/zone in the surface mesh
label& index() noexcept label& index() noexcept { return index_; }
{
return index_;
}
//- The geometric type of the patch/zone //- The geometric type of the patch/zone
const word& geometricType() const noexcept const word& geometricType() const noexcept { return geometricType_; }
{
return geometricType_;
}
//- Modifiable geometric type of the patch/zone //- Modifiable geometric type of the patch/zone
word& geometricType() noexcept word& geometricType() noexcept { return geometricType_; }
{
return geometricType_;
}
//- Write (geometricType) dictionary entry //- Write (geometricType) dictionary entry
//- (without surrounding braces) //- (without surrounding braces)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,15 +33,13 @@ License
Foam::surfZoneIdentifier::surfZoneIdentifier() Foam::surfZoneIdentifier::surfZoneIdentifier()
: :
surfZoneIdentifier(0) index_(0)
{} {}
Foam::surfZoneIdentifier::surfZoneIdentifier(const label index) Foam::surfZoneIdentifier::surfZoneIdentifier(const label index)
: :
name_(), index_(index)
index_(index),
geometricType_()
{} {}
@ -52,8 +50,7 @@ Foam::surfZoneIdentifier::surfZoneIdentifier
) )
: :
name_(name), name_(name),
index_(index), index_(index)
geometricType_()
{} {}
@ -77,9 +74,7 @@ Foam::surfZoneIdentifier::surfZoneIdentifier
const label index const label index
) )
: :
name_(name), surfZoneIdentifier(name, index)
index_(index),
geometricType_()
{ {
dict.readIfPresent("geometricType", geometricType_); dict.readIfPresent("geometricType", geometricType_);
} }
@ -88,13 +83,31 @@ Foam::surfZoneIdentifier::surfZoneIdentifier
Foam::surfZoneIdentifier::surfZoneIdentifier Foam::surfZoneIdentifier::surfZoneIdentifier
( (
const surfZoneIdentifier& ident, const surfZoneIdentifier& ident,
const label index const label newIndex
) )
: :
name_(ident.name_), surfZoneIdentifier(ident)
index_(index), {
geometricType_(ident.geometricType_) if (newIndex >= 0)
{} {
index_ = newIndex;
}
}
Foam::surfZoneIdentifier::surfZoneIdentifier
(
surfZoneIdentifier&& ident,
const label newIndex
)
:
surfZoneIdentifier(std::move(ident))
{
if (newIndex >= 0)
{
index_ = newIndex;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -39,8 +39,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef surfZoneIdentifier_H #ifndef Foam_surfZoneIdentifier_H
#define surfZoneIdentifier_H #define Foam_surfZoneIdentifier_H
#include "word.H" #include "word.H"
#include "label.H" #include "label.H"
@ -97,16 +97,22 @@ public:
//- Copy construct //- Copy construct
surfZoneIdentifier(const surfZoneIdentifier&) = default; surfZoneIdentifier(const surfZoneIdentifier&) = default;
//- Move construct
surfZoneIdentifier(surfZoneIdentifier&&) = default;
//- Copy assignment //- Copy assignment
surfZoneIdentifier& operator=(const surfZoneIdentifier&) = default; surfZoneIdentifier& operator=(const surfZoneIdentifier&) = default;
//- Move assignment
surfZoneIdentifier& operator=(surfZoneIdentifier&&) = default;
// Constructors // Constructors
//- Default construct. Uses name="", index=0 //- Default construct. Uses name="", index=0
surfZoneIdentifier(); surfZoneIdentifier();
//- Construct null with specified index //- Construct with name="" and specified index
explicit surfZoneIdentifier(const label index); explicit surfZoneIdentifier(const label index);
//- Construct from mandatory components //- Construct from mandatory components
@ -128,51 +134,40 @@ public:
const label index const label index
); );
//- Copy construct, resetting the index //- Copy construct, resetting the index (if non-negative)
surfZoneIdentifier surfZoneIdentifier
( (
const surfZoneIdentifier& ident, 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 // Member Functions
//- The patch/zone name //- The patch/zone name
const word& name() const const word& name() const noexcept { return name_; }
{
return name_;
}
//- Modifiable patch/zone name //- Modifiable patch/zone name
word& name() word& name() noexcept { return name_; }
{
return name_;
}
//- The geometric type of the patch/zone //- The (optional) geometric type of the patch/zone
const word& geometricType() const const word& geometricType() const noexcept { return geometricType_; }
{
return geometricType_;
}
//- Modifiable geometric type of the patch/zone //- Modifiable (optional) geometric type of the patch/zone
word& geometricType() word& geometricType() noexcept { return geometricType_; }
{
return geometricType_;
}
//- The index of this patch/zone in the surface mesh //- The index of this patch/zone in the surface mesh
label index() const label index() const noexcept { return index_; }
{
return index_;
}
//- Modifiable index of this patch/zone in the surface mesh //- Modifiable index of this patch/zone in the surface mesh
label& index() label& index() noexcept { return index_; }
{
return index_;
}
//- Write (geometricType) dictionary entry //- Write (geometricType) dictionary entry
//- (without surrounding braces) //- (without surrounding braces)

View File

@ -32,7 +32,6 @@ License
Foam::zoneIdentifier::zoneIdentifier() Foam::zoneIdentifier::zoneIdentifier()
: :
name_(),
index_(0) index_(0)
{} {}

View File

@ -1506,7 +1506,10 @@ void Foam::polyBoundaryMesh::writeEntry
if (!keyword.empty()) if (!keyword.empty())
{ {
os.write(keyword); os.write(keyword);
os << (entries.empty() ? token::SPACE : token::NL); if (entries.empty())
{
os << token::SPACE;
}
} }
writeEntry(os); writeEntry(os);

View File

@ -530,6 +530,32 @@ const
} }
template<class ZoneType, class MeshType>
bool Foam::ZoneMesh<ZoneType, MeshType>::reindex()
{
PtrList<ZoneType>& 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<class ZoneType, class MeshType> template<class ZoneType, class MeshType>
Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::indices Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::indices
( (
@ -1069,16 +1095,76 @@ void Foam::ZoneMesh<ZoneType, MeshType>::updateMetaData()
} }
else else
{ {
dictionary& meta = this->getMetaData(); // Save as a list of names without the leading size
meta.set("names", zoneNames); 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<class ZoneType, class MeshType>
void Foam::ZoneMesh<ZoneType, MeshType>::writeEntry(Ostream& os) const
{
const PtrList<ZoneType>& 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<class ZoneType, class MeshType>
void Foam::ZoneMesh<ZoneType, MeshType>::writeEntry
(
const word& keyword,
Ostream& os
) const
{
const PtrList<ZoneType>& entries = *this;
if (!keyword.empty())
{
os.write(keyword);
if (entries.empty())
{
os << token::SPACE;
}
}
writeEntry(os);
if (!keyword.empty()) os.endEntry();
}
template<class ZoneType, class MeshType> template<class ZoneType, class MeshType>
bool Foam::ZoneMesh<ZoneType, MeshType>::writeData(Ostream& os) const bool Foam::ZoneMesh<ZoneType, MeshType>::writeData(Ostream& os) const
{ {
os << *this; writeEntry(os);
return os.good(); return os.good();
} }
@ -1163,24 +1249,7 @@ Foam::Ostream& Foam::operator<<
const ZoneMesh<ZoneType, MeshType>& zones const ZoneMesh<ZoneType, MeshType>& zones
) )
{ {
const label sz = zones.size(); zones.writeEntry(os);
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;
}
return os; return os;
} }

View File

@ -113,6 +113,9 @@ public:
// Public Typedefs // Public Typedefs
//- The referenced mesh type
typedef MeshType mesh_type;
//- The zone type. Same as PtrList<ZoneType>::value_type //- The zone type. Same as PtrList<ZoneType>::value_type
typedef ZoneType zone_type; typedef ZoneType zone_type;
@ -226,6 +229,11 @@ public:
//- Sorted list of zone names satisfying the input matchers //- Sorted list of zone names satisfying the input matchers
wordList sortedNames(const wordRes& matcher) const; 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, //- The (sorted) patch indices for all matches,
//- optionally matching zone groups. //- optionally matching zone groups.
@ -380,8 +388,15 @@ public:
//- Update internal meta-data (eg, prior to writing) //- Update internal meta-data (eg, prior to writing)
void updateMetaData(); 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 //- The writeData member function required by regIOobject
bool writeData(Ostream& os) const; virtual bool writeData(Ostream& os) const;
// Ostream Operator // Ostream Operator

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,11 +27,10 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "cellZone.H" #include "cellZone.H"
#include "addToRunTimeSelectionTable.H"
#include "cellZoneMesh.H" #include "cellZoneMesh.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "primitiveMesh.H"
#include "IOstream.H" #include "IOstream.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -42,14 +41,12 @@ namespace Foam
addToRunTimeSelectionTable(cellZone, cellZone, dictionary); addToRunTimeSelectionTable(cellZone, cellZone, dictionary);
} }
const char * const Foam::cellZone::labelsName = "cellLabels";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cellZone::cellZone(const cellZoneMesh& zm) Foam::cellZone::cellZone(const cellZoneMesh& zm)
: :
cellZone(word::null, 0, zm) zone(),
zoneMesh_(zm)
{} {}
@ -99,7 +96,7 @@ Foam::cellZone::cellZone
const cellZoneMesh& zm const cellZoneMesh& zm
) )
: :
zone(name, dict, this->labelsName, index), zone(name, dict, cellZone::labelsName(), index),
zoneMesh_(zm) zoneMesh_(zm)
{} {}
@ -107,7 +104,19 @@ Foam::cellZone::cellZone
Foam::cellZone::cellZone Foam::cellZone::cellZone
( (
const cellZone& originalZone, 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 cellZoneMesh& zm,
const label newIndex const label newIndex
) )
@ -120,7 +129,7 @@ Foam::cellZone::cellZone
Foam::cellZone::cellZone Foam::cellZone::cellZone
( (
const cellZone& originalZone, const cellZone& originalZone,
const Foam::zero, Foam::zero,
const label index, const label index,
const cellZoneMesh& zm const cellZoneMesh& zm
) )
@ -160,28 +169,17 @@ Foam::cellZone::cellZone
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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 // void Foam::cellZone::sort()
{ // {
return zone::checkDefinition(zoneMesh_.mesh().nCells(), report); // clearAddressing();
} // Foam::sort(static_cast<labelList&>(*this));
// }
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::resetAddressing(cellZone&& zn) 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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::cellZone::operator=(const cellZone& zn) void Foam::cellZone::operator=(const cellZone& zn)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -75,8 +75,7 @@ public:
// Static Data Members // Static Data Members
//- The name associated with the zone-labels dictionary entry //- The name associated with the zone-labels dictionary entry
//- ("cellLabels") static constexpr const char* labelsName() { return "cellLabels"; }
static const char * const labelsName;
//- Runtime type information //- Runtime type information
@ -143,13 +142,23 @@ public:
const cellZoneMesh& zm const cellZoneMesh& zm
); );
//- Construct empty with original zone information (name, index, groups) //- Copy construct with new mesh reference.
//- and mesh reference. Optionally specify a new index.
cellZone cellZone
( (
const cellZone& originalZone, const cellZone& originalZone,
const Foam::zero,
const cellZoneMesh& zm, 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 const label newIndex = -1
); );
@ -158,7 +167,8 @@ public:
cellZone cellZone
( (
const cellZone& originalZone, const cellZone& originalZone,
const Foam::zero, Foam::zero,
//! The new index (-1 retains the original value)
const label index, const label index,
const cellZoneMesh& zm const cellZoneMesh& zm
); );
@ -169,6 +179,7 @@ public:
( (
const cellZone& originalZone, const cellZone& originalZone,
const labelUList& addr, const labelUList& addr,
//! The new index (-1 retains the original value)
const label index, const label index,
const cellZoneMesh& zm const cellZoneMesh& zm
); );
@ -179,15 +190,21 @@ public:
( (
const cellZone& originalZone, const cellZone& originalZone,
labelList&& addr, labelList&& addr,
//! The new index (-1 retains the original value)
const label index, const label index,
const cellZoneMesh& zm const cellZoneMesh& zm
); );
//- Construct and return a clone, resetting the zone mesh //- Construct and return a clone, resetting the zone mesh
virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const virtual autoPtr<cellZone> clone
(
const cellZoneMesh& zm,
//! The new index (optional. -1 retains the original value)
const label newIndex = -1
) const
{ {
return autoPtr<cellZone>::New(*this, *this, index(), zm); return autoPtr<cellZone>::New(*this, zm, newIndex);
} }
//- Construct and return a clone, //- Construct and return a clone,
@ -195,6 +212,7 @@ public:
virtual autoPtr<cellZone> clone virtual autoPtr<cellZone> clone
( (
const labelUList& addr, const labelUList& addr,
//! The new index (-1 retains the original value)
const label index, const label index,
const cellZoneMesh& zm const cellZoneMesh& zm
) const ) const
@ -222,21 +240,30 @@ public:
// Member Functions // Member Functions
//- The maximum index the zone may contain == mesh nCells()
label max_index() const noexcept;
//- Return reference to the zone mesh //- Return reference to the zone mesh
const cellZoneMesh& zoneMesh() const noexcept { return zoneMesh_; } const cellZoneMesh& zoneMesh() const noexcept { return zoneMesh_; }
//- The addressing (cell IDs) used for the zone //- 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<const labelList&>(*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. //- Check zone definition.
virtual bool checkDefinition(const bool report = false) const; // \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. //- Check whether zone is synchronised across coupled boundaries.
// \return True if any errors. // \return True if any errors.
@ -245,9 +272,6 @@ public:
return false; return false;
} }
//- Write dictionary
virtual void writeDict(Ostream& os) const;
// Assign addressing // Assign addressing
@ -275,8 +299,22 @@ public:
// I-O // I-O
//- Write (dictionary entries)
virtual void write(Ostream& os) const;
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream& os, const cellZone& zn); 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();
}
}; };

View File

@ -41,7 +41,7 @@ namespace Foam
class cellZone; class cellZone;
class polyMesh; class polyMesh;
template<class Zone, class MeshType> class ZoneMesh; template<class ZoneType, class MeshType> class ZoneMesh;
typedef ZoneMesh<cellZone, polyMesh> cellZoneMesh; typedef ZoneMesh<cellZone, polyMesh> cellZoneMesh;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,12 +27,11 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "faceZone.H" #include "faceZone.H"
#include "addToRunTimeSelectionTable.H"
#include "faceZoneMesh.H" #include "faceZoneMesh.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "primitiveMesh.H"
#include "mapPolyMesh.H" #include "mapPolyMesh.H"
#include "syncTools.H" #include "syncTools.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -43,8 +42,6 @@ namespace Foam
addToRunTimeSelectionTable(faceZone, faceZone, dictionary); addToRunTimeSelectionTable(faceZone, faceZone, dictionary);
} }
const char* const Foam::faceZone::labelsName = "faceLabels";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -220,7 +217,8 @@ void Foam::faceZone::checkAddressing() const
Foam::faceZone::faceZone(const faceZoneMesh& zm) Foam::faceZone::faceZone(const faceZoneMesh& zm)
: :
faceZone(word::null, 0, zm) zone(),
zoneMesh_(zm)
{} {}
@ -329,10 +327,10 @@ Foam::faceZone::faceZone
const faceZoneMesh& zm const faceZoneMesh& zm
) )
: :
zone(name, dict, this->labelsName, index), zone(name, dict, faceZone::labelsName(), index),
flipMap_(dict.lookup("flipMap")), // OR: dict.get<boolList>("flipMap")
zoneMesh_(zm) zoneMesh_(zm)
{ {
dict.readEntry("flipMap", flipMap_, keyType::LITERAL);
checkAddressing(); checkAddressing();
} }
@ -340,7 +338,21 @@ Foam::faceZone::faceZone
Foam::faceZone::faceZone Foam::faceZone::faceZone
( (
const faceZone& originalZone, 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 faceZoneMesh& zm,
const label newIndex const label newIndex
) )
@ -353,7 +365,7 @@ Foam::faceZone::faceZone
Foam::faceZone::faceZone Foam::faceZone::faceZone
( (
const faceZone& originalZone, const faceZone& originalZone,
const Foam::zero, Foam::zero,
const label index, const label index,
const faceZoneMesh& zm const faceZoneMesh& zm
) )
@ -401,12 +413,23 @@ Foam::faceZone::faceZone
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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<labelList&>(*this);
//
// auto order = Foam::sortedOrder(addr);
// addr = labelList(addr, order);
// flipMap_ = boolList(flipMap_, order);
// }
const Foam::primitiveFacePatch& Foam::faceZone::patch() const const Foam::primitiveFacePatch& Foam::faceZone::patch() const
{ {
if (!patchPtr_) if (!patchPtr_)
@ -483,7 +506,6 @@ void Foam::faceZone::clearPrimitives()
void Foam::faceZone::resetAddressing(faceZone&& zn) void Foam::faceZone::resetAddressing(faceZone&& zn)
{ {
// TDB: clearGeom();
if (this == &zn) if (this == &zn)
{ {
return; // Self-assignment is a no-op return; // Self-assignment is a no-op
@ -498,7 +520,6 @@ void Foam::faceZone::resetAddressing(faceZone&& zn)
void Foam::faceZone::resetAddressing(const faceZone& zn) void Foam::faceZone::resetAddressing(const faceZone& zn)
{ {
// TDB: clearGeom();
if (this == &zn) if (this == &zn)
{ {
return; // Self-assignment is a no-op 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 bool Foam::faceZone::checkParallelSync(const bool report) const
{ {
const polyMesh& mesh = zoneMesh().mesh(); const polyMesh& mesh = zoneMesh().mesh();
@ -683,24 +698,12 @@ void Foam::faceZone::movePoints(const pointField& pts)
} }
} }
void Foam::faceZone::write(Ostream& os) const void Foam::faceZone::write(Ostream& os) const
{ {
os << nl << name() zone::write(os);
<< nl << static_cast<const labelList&>(*this) labelList::writeEntry(faceZone::labelsName(), os);
<< nl << flipMap(); flipMap_.writeEntry("flipMap", os);
}
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();
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -78,13 +78,13 @@ class faceZone
// Private Data // Private Data
//- Reference to zone list
const faceZoneMesh& zoneMesh_;
//- Flip map for all faces in the zone. //- Flip map for all faces in the zone.
// True if the face needs flipping for the correct orientation. // True if the face needs flipping for the correct orientation.
boolList flipMap_; boolList flipMap_;
//- Reference to zone list
const faceZoneMesh& zoneMesh_;
//- Demand-driven: Primitive patch of correctly flipped faces //- Demand-driven: Primitive patch of correctly flipped faces
mutable std::unique_ptr<primitiveFacePatch> patchPtr_; mutable std::unique_ptr<primitiveFacePatch> patchPtr_;
@ -120,8 +120,7 @@ public:
// Static Data Members // Static Data Members
//- The name associated with the zone-labels dictionary entry //- The name associated with the zone-labels dictionary entry
//- ("faceLabels") static constexpr const char* labelsName() { return "faceLabels"; }
static const char * const labelsName;
//- Runtime type information //- Runtime type information
@ -211,13 +210,23 @@ public:
const faceZoneMesh& zm const faceZoneMesh& zm
); );
//- Construct empty with original zone information (name, index, groups) //- Copy construct with new mesh reference.
//- and mesh reference. Optionally specify a new index.
faceZone faceZone
( (
const faceZone& originalZone, const faceZone& originalZone,
const Foam::zero,
const faceZoneMesh& zm, 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 const label newIndex = -1
); );
@ -226,7 +235,8 @@ public:
faceZone faceZone
( (
const faceZone& originalZone, const faceZone& originalZone,
const Foam::zero, Foam::zero,
//! The new index (-1 retains the original value)
const label index, const label index,
const faceZoneMesh& zm const faceZoneMesh& zm
); );
@ -239,6 +249,7 @@ public:
const faceZone& originalZone, const faceZone& originalZone,
const labelUList& addr, const labelUList& addr,
const boolUList& fm, const boolUList& fm,
//! The new index (-1 retains the original value)
const label index, const label index,
const faceZoneMesh& zm const faceZoneMesh& zm
); );
@ -251,14 +262,20 @@ public:
const faceZone& originalZone, const faceZone& originalZone,
labelList&& addr, labelList&& addr,
boolList&& fm, boolList&& fm,
//! The new index (-1 retains the original value)
const label index, const label index,
const faceZoneMesh& zm const faceZoneMesh& zm
); );
//- Construct and return a clone, resetting the zone mesh //- Construct and return a clone, resetting the zone mesh
virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const virtual autoPtr<faceZone> clone
(
const faceZoneMesh& zm,
//! The new index (optional. -1 retains the original value)
const label newIndex = -1
) const
{ {
return autoPtr<faceZone>::New(*this, *this, flipMap(), index(), zm); return autoPtr<faceZone>::New(*this, zm, newIndex);
} }
//- Construct and return a clone, //- Construct and return a clone,
@ -267,6 +284,7 @@ public:
( (
const labelUList& addr, const labelUList& addr,
const boolUList& fm, const boolUList& fm,
//! The new index (-1 retains the original value)
const label index, const label index,
const faceZoneMesh& zm const faceZoneMesh& zm
) const ) const
@ -294,26 +312,43 @@ public:
// Member Functions // Member Functions
//- The maximum index the zone may contain == mesh nFaces()
label max_index() const noexcept;
//- Return reference to the zone mesh //- Return reference to the zone mesh
const faceZoneMesh& zoneMesh() const noexcept { return zoneMesh_; } const faceZoneMesh& zoneMesh() const noexcept { return zoneMesh_; }
//- The addressing (face IDs) used for the zone //- The addressing (face IDs) used for the zone
const labelList& addressing() const noexcept using zone::addressing;
{
return static_cast<const labelList&>(*this);
}
//- Return face flip map //- Return face flip map
const boolList& flipMap() const noexcept { return flipMap_; } const boolList& flipMap() const noexcept { return flipMap_; }
//- Helper function to re-direct to zone::localID(...) //- The local index of the given mesh face, -1 if not in the zone
label whichFace(const label globalCellID) const; label whichFace(const label meshFaceID) const
{
return zone::localID(meshFaceID);
}
//- Return [demand-driven] reference to an equivalent primitive patch, //- Return [demand-driven] reference to an equivalent primitive patch,
//- with faces oriented according to flipMap() //- with faces oriented according to flipMap()
const primitiveFacePatch& patch() const; 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 // Addressing into mesh
//- The front cells layer. //- The front cells layer.
@ -329,25 +364,6 @@ public:
//- Return global edge index for local edges //- Return global edge index for local edges
const labelList& meshEdges() const; 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 // Assign addressing
@ -392,8 +408,20 @@ public:
void operator=(const faceZone& zn); 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 // I-O
//- Write (dictionary entries)
virtual void write(Ostream& os) const;
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream& os, const faceZone& zn); 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
// \deprecated(2023-09) same as backCells #1832 // \deprecated(2023-09) same as backCells #1832
const labelList& slaveCells() const { return backCells(); } 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();
}
}; };

View File

@ -41,7 +41,7 @@ namespace Foam
class faceZone; class faceZone;
class polyMesh; class polyMesh;
template<class Zone, class MeshType> class ZoneMesh; template<class ZoneType, class MeshType> class ZoneMesh;
typedef ZoneMesh<faceZone, polyMesh> faceZoneMesh; typedef ZoneMesh<faceZone, polyMesh> faceZoneMesh;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,11 +27,10 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "pointZone.H" #include "pointZone.H"
#include "addToRunTimeSelectionTable.H"
#include "pointZoneMesh.H" #include "pointZoneMesh.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "primitiveMesh.H"
#include "syncTools.H" #include "syncTools.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -42,14 +41,13 @@ namespace Foam
addToRunTimeSelectionTable(pointZone, pointZone, dictionary); addToRunTimeSelectionTable(pointZone, pointZone, dictionary);
} }
const char* const Foam::pointZone::labelsName = "pointLabels";
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pointZone::pointZone(const pointZoneMesh& zm) Foam::pointZone::pointZone(const pointZoneMesh& zm)
: :
pointZone(word::null, 0, zm) zone(),
zoneMesh_(zm)
{} {}
@ -99,7 +97,7 @@ Foam::pointZone::pointZone
const pointZoneMesh& zm const pointZoneMesh& zm
) )
: :
zone(name, dict, this->labelsName, index), zone(name, dict, pointZone::labelsName(), index),
zoneMesh_(zm) zoneMesh_(zm)
{} {}
@ -107,7 +105,19 @@ Foam::pointZone::pointZone
Foam::pointZone::pointZone Foam::pointZone::pointZone
( (
const pointZone& originalZone, 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 pointZoneMesh& zm,
const label newIndex const label newIndex
) )
@ -120,12 +130,12 @@ Foam::pointZone::pointZone
Foam::pointZone::pointZone Foam::pointZone::pointZone
( (
const pointZone& originalZone, const pointZone& originalZone,
const Foam::zero, Foam::zero,
const label index, const label newIndex,
const pointZoneMesh& zm const pointZoneMesh& zm
) )
: :
zone(originalZone, labelList(), index), zone(originalZone, labelList(), newIndex),
zoneMesh_(zm) zoneMesh_(zm)
{} {}
@ -160,16 +170,17 @@ Foam::pointZone::pointZone
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * 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 // void Foam::pointZone::sort()
{ // {
return zone::checkDefinition(zoneMesh_.mesh().points().size(), report); // clearAddressing();
} // Foam::sort(static_cast<labelList&>(*this));
// }
bool Foam::pointZone::checkParallelSync(const bool report) const 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) void Foam::pointZone::resetAddressing(pointZone&& zn)
{ {
if (this == &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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::pointZone::operator=(const pointZone& zn) void Foam::pointZone::operator=(const pointZone& zn)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -77,8 +77,7 @@ public:
// Static Data Members // Static Data Members
//- The name associated with the zone-labels dictionary entry //- The name associated with the zone-labels dictionary entry
//- ("pointLabels") static constexpr const char* labelsName() { return "pointLabels"; }
static const char * const labelsName;
//- Runtime type information //- Runtime type information
@ -145,13 +144,23 @@ public:
const pointZoneMesh& zm const pointZoneMesh& zm
); );
//- Construct empty with original zone information (name, index, groups) //- Copy construct with new mesh reference.
//- and mesh reference. Optionally specify a new index.
pointZone pointZone
( (
const pointZone& originalZone, const pointZone& originalZone,
const Foam::zero,
const pointZoneMesh& zm, 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 const label newIndex = -1
); );
@ -160,7 +169,8 @@ public:
pointZone pointZone
( (
const pointZone& originalZone, const pointZone& originalZone,
const Foam::zero, Foam::zero,
//! The new index (-1 retains the original value)
const label index, const label index,
const pointZoneMesh& zm const pointZoneMesh& zm
); );
@ -171,6 +181,7 @@ public:
( (
const pointZone& originalZone, const pointZone& originalZone,
const labelUList& addr, const labelUList& addr,
//! The new index (-1 retains the original value)
const label index, const label index,
const pointZoneMesh& zm const pointZoneMesh& zm
); );
@ -181,22 +192,29 @@ public:
( (
const pointZone& originalZone, const pointZone& originalZone,
labelList&& addr, labelList&& addr,
//! The new index (-1 retains the original value)
const label index, const label index,
const pointZoneMesh& zm const pointZoneMesh& zm
); );
//- Construct and return a clone, resetting the zone mesh //- Construct and return a clone, resetting the zone mesh
virtual autoPtr<pointZone> clone(const pointZoneMesh& zm) const
{
return autoPtr<pointZone>::New(*this, *this, index(), zm);
}
//- Construct and return a clone, resetting the point list
//- and zone mesh
virtual autoPtr<pointZone> clone virtual autoPtr<pointZone> clone
( (
const pointZoneMesh& zm, const pointZoneMesh& zm,
//! The new index (optional. -1 retains the original value)
const label newIndex = -1
) const
{
return autoPtr<pointZone>::New(*this, zm, newIndex);
}
//- Construct and return a clone,
//- resetting the point list and zone mesh
virtual autoPtr<pointZone> clone
(
const pointZoneMesh& zm,
//! The new index (-1 retains the original value)
const label index, const label index,
const labelUList& addr const labelUList& addr
) const ) const
@ -224,33 +242,35 @@ public:
// Member Functions // Member Functions
//- The maximum index the zone may contain == mesh nPoints()
label max_index() const noexcept;
//- Return reference to the zone mesh //- Return reference to the zone mesh
const pointZoneMesh& zoneMesh() const noexcept { return zoneMesh_; } const pointZoneMesh& zoneMesh() const noexcept { return zoneMesh_; }
//- The addressing (point IDs) used for the zone //- 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<const labelList&>(*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. //- Check zone definition.
virtual bool checkDefinition(const bool report = false) const; // \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. //- Check whether zone is synchronised across coupled boundaries.
// \return True if any errors. // \return True if any errors.
virtual bool checkParallelSync(const bool report = false) const; 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 // Assign addressing
@ -276,10 +296,31 @@ public:
void operator=(labelList&& addr); void operator=(labelList&& addr);
// Mesh Changes
//- Nothing to correct after moving points
virtual void movePoints(const pointField&)
{}
// I-O // I-O
//- Write (dictionary entries)
virtual void write(Ostream& os) const;
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream& os, const pointZone& zn); 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();
}
}; };

View File

@ -41,7 +41,7 @@ namespace Foam
class pointZone; class pointZone;
class polyMesh; class polyMesh;
template<class Zone, class MeshType> class ZoneMesh; template<class ZoneType, class MeshType> class ZoneMesh;
typedef ZoneMesh<pointZone, polyMesh> pointZoneMesh; typedef ZoneMesh<pointZone, polyMesh> pointZoneMesh;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,17 +43,13 @@ namespace Foam
Foam::zone::zone() Foam::zone::zone()
: :
zoneIdentifier(), zoneIdentifier()
labelList(),
lookupMapPtr_(nullptr)
{} {}
Foam::zone::zone(const word& name, const label index) Foam::zone::zone(const word& name, const label index)
: :
zoneIdentifier(name, index), zoneIdentifier(name, index)
labelList(),
lookupMapPtr_(nullptr)
{} {}
@ -91,9 +87,23 @@ Foam::zone::zone
const label index const label index
) )
: :
zoneIdentifier(name, dict, index), zoneIdentifier(name, dict, index)
labelList(dict.get<labelList>(labelsName)), {
lookupMapPtr_(nullptr) if (!labelsName.empty())
{
dict.readEntry<labelList>(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), zoneIdentifier(originalZone, newIndex),
labelList(addr), labelList(addr)
lookupMapPtr_(nullptr)
{} {}
@ -118,8 +127,7 @@ Foam::zone::zone
) )
: :
zoneIdentifier(originalZone, newIndex), zoneIdentifier(originalZone, newIndex),
labelList(std::move(addr)), labelList(std::move(addr))
lookupMapPtr_(nullptr)
{} {}
@ -131,8 +139,9 @@ const Foam::Map<Foam::label>& Foam::zone::lookupMap() const
{ {
const labelList& addr = *this; const labelList& addr = *this;
lookupMapPtr_.reset(new Map<label>(2*addr.size())); lookupMapPtr_.reset(new Map<label>());
auto& map = *lookupMapPtr_; auto& map = *lookupMapPtr_;
map.reserve(addr.size());
for (const label id : addr) for (const label id : addr)
{ {
@ -150,6 +159,13 @@ Foam::label Foam::zone::localID(const label globalID) const
} }
// void Foam::zone::sort()
// {
// clearAddressing();
// Foam::sort(*this);
// }
void Foam::zone::clearAddressing() void Foam::zone::clearAddressing()
{ {
lookupMapPtr_.reset(nullptr); lookupMapPtr_.reset(nullptr);
@ -169,7 +185,8 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
bool hasError = false; bool hasError = false;
// To check for duplicate entries // To check for duplicate entries
labelHashSet elems(2*size()); labelHashSet elems;
elems.reserve(addr.size());
for (const label id : addr) for (const label id : addr)
{ {
@ -182,8 +199,7 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
SeriousErrorInFunction SeriousErrorInFunction
<< "Zone " << this->name() << "Zone " << this->name()
<< " contains invalid index label " << id << nl << " contains invalid index label " << id << nl
<< "Valid index labels are 0.." << "Valid index labels are 0.." << (maxSize-1) << endl;
<< maxSize-1 << endl;
} }
else else
{ {
@ -208,8 +224,8 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
void Foam::zone::write(Ostream& os) const void Foam::zone::write(Ostream& os) const
{ {
os << nl << this->name() os.writeEntry("type", type());
<< nl << static_cast<const labelList&>(*this); zoneIdentifier::write(os);
} }
@ -217,7 +233,9 @@ void Foam::zone::write(Ostream& os) const
Foam::Ostream& Foam::operator<<(Ostream& os, const zone& zn) Foam::Ostream& Foam::operator<<(Ostream& os, const zone& zn)
{ {
zn.write(os); os << nl << zn.name()
<< nl << static_cast<const labelList&>(zn);
os.check(FUNCTION_NAME); os.check(FUNCTION_NAME);
return os; return os;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -80,7 +80,7 @@ public:
// Constructors // Constructors
//- Default construct //- Default construct: empty zone with name="", index=0
zone(); zone();
//- Construct an empty zone with specified name and index //- Construct an empty zone with specified name and index
@ -107,25 +107,36 @@ public:
( (
const word& name, const word& name,
const dictionary& dict, const dictionary& dict,
//! The lookup name for the labelList. Ignored if empty
const word& labelsName, const word& labelsName,
const label index const label index
); );
//- Construct given the name of the original zone (name is used) //- Copy construct with new index
//- with new addressing and index (-ve: retain zone index).
zone zone
( (
const zone& originalZone, const zone& originalZone,
const labelUList& addr, //! The new index (-1 retains the original value)
const label index const label index
); );
//- Construct given the name of the original zone (name is used) //- Construct given the name of the original zone (name is used)
//- and (move) resetting addressing and index (-ve: retain zone index). //- with new addressing and index
zone
(
const zone& originalZone,
const labelUList& addr,
//! The new index (-1 retains the original value)
const label index
);
//- Construct given the name of the original zone (name is used)
//- and (move) resetting addressing and index
zone zone
( (
const zone& originalZone, const zone& originalZone,
labelList&& addr, labelList&& addr,
//! The new index (-1 retains the original value)
const label index const label index
); );
@ -166,19 +177,19 @@ public:
const bool report = false const bool report = false
) const; ) const;
//- Correct patch after moving points
virtual void movePoints(const pointField& pts) // Mesh Changes
//- Corrections after moving points
virtual void movePoints(const pointField&)
{} {}
//- Write
virtual void write(Ostream& os) const;
//- Write dictionary
virtual void writeDict(Ostream& os) const = 0;
// I-O // I-O
//- Write (dictionary entries)
virtual void write(Ostream& os) const;
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream& os, const zone& zn); friend Ostream& operator<<(Ostream& os, const zone& zn);
}; };

View File

@ -1949,13 +1949,13 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
// Note that this is not necessary for redistributePar since that already // Note that this is not necessary for redistributePar since that already
// checks for it. However other use (e.g. mesh generators) might not. // checks for it. However other use (e.g. mesh generators) might not.
const wordList pointZoneNames(mergeWordList(mesh_.pointZones().names())); const wordList pointZoneNames(mergeWordList(mesh_.pointZones().names()));
reorderZones<pointZone>(pointZoneNames, mesh_.pointZones()); reorderZones(pointZoneNames, mesh_.pointZones());
const wordList faceZoneNames(mergeWordList(mesh_.faceZones().names())); const wordList faceZoneNames(mergeWordList(mesh_.faceZones().names()));
reorderZones<faceZone>(faceZoneNames, mesh_.faceZones()); reorderZones(faceZoneNames, mesh_.faceZones());
const wordList cellZoneNames(mergeWordList(mesh_.cellZones().names())); const wordList cellZoneNames(mergeWordList(mesh_.cellZones().names()));
reorderZones<cellZone>(cellZoneNames, mesh_.cellZones()); reorderZones(cellZoneNames, mesh_.cellZones());
// Local environment of all boundary faces // Local environment of all boundary faces

View File

@ -98,12 +98,8 @@ class fvMeshDistribute
static wordList mergeWordList(const wordList&); static wordList mergeWordList(const wordList&);
//- Reorder zones according to names //- Reorder zones according to names
template<class ZoneType, class ZoneMesh> template<class ZoneMesh>
void reorderZones void reorderZones(const wordList& zoneNames, ZoneMesh& zones);
(
const wordList& zoneNames,
ZoneMesh& zones
);
// Patch handling // Patch handling

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2023 OpenCFD Ltd. Copyright (C) 2015-2025 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,7 +30,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ZoneType, class ZoneMesh> template<class ZoneMesh>
void Foam::fvMeshDistribute::reorderZones void Foam::fvMeshDistribute::reorderZones
( (
const wordList& zoneNames, const wordList& zoneNames,
@ -39,41 +39,50 @@ void Foam::fvMeshDistribute::reorderZones
{ {
zones.clearAddressing(); zones.clearAddressing();
typedef typename ZoneMesh::zone_type zone_type;
// Shift old ones to new position // Shift old ones to new position
UPtrList<ZoneType> newZonePtrs(zoneNames.size()); PtrList<zone_type>& oldPtrs = zones;
PtrList<zone_type> newPtrs(zoneNames.size());
forAll(zones, zonei) forAll(zones, zonei)
{ {
auto* zonePtr = zones.get(zonei); if (!zones.get(zonei))
if (!zonePtr)
{ {
FatalErrorInFunction << "Problem with zones " << zones.names() FatalErrorInFunction
<< "Problem with zone[" << zonei << "] " << zones.names()
<< exit(FatalError); << exit(FatalError);
} }
const label newIndex = zoneNames.find(zonePtr->name()); }
zonePtr->index() = newIndex;
newZonePtrs.set(newIndex, zonePtr); forAll(zones, zonei)
{
// Take ownership
auto ptr = oldPtrs.release(zonei);
if (!ptr)
{
FatalErrorInFunction
<< "Problem with zone[" << zonei << "] == nullptr" << nl
<< exit(FatalError);
}
const label newIndex = zoneNames.find(ptr->name());
// Check if not found?
ptr->index() = newIndex;
newPtrs.set(newIndex, std::move(ptr));
} }
// Add empty zones for unknown ones // Add empty zones for unknown ones
forAll(newZonePtrs, i) forAll(newPtrs, i)
{ {
if (!newZonePtrs.get(i)) if (!newPtrs.get(i))
{ {
newZonePtrs.set newPtrs.emplace_set(i, zoneNames[i], i, zones);
(
i,
new ZoneType
(
zoneNames[i],
i,
zones
)
);
} }
} }
// Transfer // Transfer
zones.swap(newZonePtrs); oldPtrs = std::move(newPtrs);
} }

View File

@ -11,6 +11,8 @@ faMesh/faMeshBoundaryHalo.C
faMesh/faBoundaryMesh/faBoundaryMesh.C faMesh/faBoundaryMesh/faBoundaryMesh.C
faMesh/faBoundaryMesh/faBoundaryMeshEntries.C faMesh/faBoundaryMesh/faBoundaryMeshEntries.C
faceZone = faMesh/zones/faceZone/faFaceZone.cxx
faMesh/faMeshSubset/faMeshSubset.C faMesh/faMeshSubset/faMeshSubset.C
faMesh/faMeshTools/faMeshTools.C faMesh/faMeshTools/faMeshTools.C
faMesh/faMeshTools/faMeshToolsChecks.C faMesh/faMeshTools/faMeshToolsChecks.C

View File

@ -0,0 +1,280 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2025 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/>.
Class
Foam::faFaceZone
Description
A subset of finite-area face elements.
SourceFiles
faFaceZone.C
\*---------------------------------------------------------------------------*/
#ifndef Foam_faFaceZone_H
#define Foam_faFaceZone_H
#include "zone.H"
#include "faFaceZoneMeshFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward Declarations
class faFaceZone;
Ostream& operator<<(Ostream& os, const faFaceZone& zn);
/*---------------------------------------------------------------------------*\
Class faFaceZone Declaration
\*---------------------------------------------------------------------------*/
class faFaceZone
:
public zone
{
// Private Data
//- Reference to zone list
const faFaceZoneMesh& zoneMesh_;
public:
// Static Data Members
//- The name associated with the zone-labels dictionary entry
static constexpr const char* labelsName() { return "faceLabels"; }
//- Runtime type information
TypeName("faFaceZone");
// Constructors
//- No copy construct
faFaceZone(const faFaceZone&) = delete;
//- Construct an empty zone - name="", index=0
explicit faFaceZone(const faFaceZoneMesh& zm);
//- Construct an empty zone with specified name and index
faFaceZone
(
const word& name,
const label index,
const faFaceZoneMesh& zm
);
//- Construct from components
faFaceZone
(
const word& name,
const labelUList& addr,
const label index,
const faFaceZoneMesh& zm
);
//- Construct from components, transferring addressing
faFaceZone
(
const word& name,
labelList&& addr,
const label index,
const faFaceZoneMesh& zm
);
//- Construct from dictionary
faFaceZone
(
const word& name,
const dictionary& dict,
const label index,
const faFaceZoneMesh& zm
);
//- Copy construct with a new mesh reference
faFaceZone
(
const faFaceZone& originalZone,
const faFaceZoneMesh& 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.
faFaceZone
(
const faFaceZone& originalZone,
Foam::zero,
const faFaceZoneMesh& zm,
//! The new index (optional. -1 retains the original value)
const label newIndex = -1
);
//- Construct empty with original zone information (name, groups),
//- resetting the index and zone mesh reference.
faFaceZone
(
const faFaceZone& originalZone,
Foam::zero,
//! The new index (-1 retains the original value)
const label index,
const faFaceZoneMesh& zm
);
//- Construct with original zone information (name, groups),
//- resetting the face list, the index and zone mesh reference.
faFaceZone
(
const faFaceZone& originalZone,
const labelUList& addr,
//! The new index (-1 retains the original value)
const label index,
const faFaceZoneMesh& zm
);
//- Construct with original zone information (name, groups),
//- resetting the face list, the index and zone mesh reference.
faFaceZone
(
const faFaceZone& originalZone,
labelList&& addr,
//! The new index (-1 retains the original value)
const label index,
const faFaceZoneMesh& zm
);
//- Construct and return a clone, resetting the zone mesh
virtual autoPtr<faFaceZone> clone
(
const faFaceZoneMesh& zm,
//! The new index (optional. -1 retains the original value)
const label newIndex = -1
) const
{
return autoPtr<faFaceZone>::New(*this, zm, newIndex);
}
//- Construct and return a clone,
//- resetting the face list and zone mesh
virtual autoPtr<faFaceZone> clone
(
const labelUList& addr,
//! The new index (-1 retains the original value)
const label index,
const faFaceZoneMesh& zm
) const
{
return autoPtr<faFaceZone>::New(*this, addr, index, zm);
}
//- Destructor
virtual ~faFaceZone() = default;
// Member Functions
//- The maximum index the zone may contain == mesh nFaces()
label max_index() const noexcept;
//- Return reference to the zone mesh
const faFaceZoneMesh& zoneMesh() const noexcept { return zoneMesh_; }
//- The addressing (face IDs) used for the zone
using zone::addressing;
//- The local index of the given mesh face, -1 if not in the zone
label whichFace(const label meshFaceID) const
{
return zone::localID(meshFaceID);
}
// Checks
//- Check zone definition. Return true if in error.
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
{
return false;
}
// Assign addressing
//- Move reset addressing from another zone
virtual void resetAddressing(faFaceZone&& zn);
//- Copy reset addressing from another zone
virtual void resetAddressing(const faFaceZone& zn);
//- Copy assign addressing
virtual void resetAddressing(const labelUList& addr);
//- Move assign addressing
virtual void resetAddressing(labelList&& addr);
//- Assign addressing, clearing demand-driven data
void operator=(const faFaceZone& zn);
//- Assign addressing, clearing demand-driven data
void operator=(const labelUList& addr);
//- Move assign addressing, clearing demand-driven data
void operator=(labelList&& addr);
// I-O
//- Write (dictionary entries)
virtual void write(Ostream& os) const;
//- Ostream Operator
friend Ostream& operator<<(Ostream& os, const faFaceZone& zn);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,259 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2025 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/>.
\*---------------------------------------------------------------------------*/
#include "faFaceZone.H"
#include "faFaceZoneMesh.H"
#include "faMesh.H"
#include "IOstream.H"
// #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(faFaceZone, 0);
// defineRunTimeSelectionTable(faFaceZone, dictionary);
// addToRunTimeSelectionTable(faFaceZone, faFaceZone, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faFaceZone::faFaceZone(const faFaceZoneMesh& zm)
:
zone(),
zoneMesh_(zm)
{}
Foam::faFaceZone::faFaceZone
(
const word& name,
const label index,
const faFaceZoneMesh& zm
)
:
zone(name, index),
zoneMesh_(zm)
{}
Foam::faFaceZone::faFaceZone
(
const word& name,
const labelUList& addr,
const label index,
const faFaceZoneMesh& zm
)
:
zone(name, addr, index),
zoneMesh_(zm)
{}
Foam::faFaceZone::faFaceZone
(
const word& name,
labelList&& addr,
const label index,
const faFaceZoneMesh& zm
)
:
zone(name, std::move(addr), index),
zoneMesh_(zm)
{}
Foam::faFaceZone::faFaceZone
(
const word& name,
const dictionary& dict,
const label index,
const faFaceZoneMesh& zm
)
:
zone(name, dict, faFaceZone::labelsName(), index),
zoneMesh_(zm)
{}
Foam::faFaceZone::faFaceZone
(
const faFaceZone& originalZone,
const faFaceZoneMesh& zm,
const label newIndex
)
:
zone(originalZone, newIndex),
zoneMesh_(zm)
{}
Foam::faFaceZone::faFaceZone
(
const faFaceZone& originalZone,
Foam::zero,
const faFaceZoneMesh& zm,
const label newIndex
)
:
zone(originalZone, labelList(), newIndex),
zoneMesh_(zm)
{}
Foam::faFaceZone::faFaceZone
(
const faFaceZone& originalZone,
Foam::zero,
const label index,
const faFaceZoneMesh& zm
)
:
zone(originalZone, labelList(), index),
zoneMesh_(zm)
{}
Foam::faFaceZone::faFaceZone
(
const faFaceZone& originalZone,
const labelUList& addr,
const label index,
const faFaceZoneMesh& zm
)
:
faFaceZone(originalZone, Foam::zero{}, index, zm)
{
labelList::operator=(addr);
}
Foam::faFaceZone::faFaceZone
(
const faFaceZone& originalZone,
labelList&& addr,
const label index,
const faFaceZoneMesh& zm
)
:
faFaceZone(originalZone, Foam::zero{}, index, zm)
{
labelList::transfer(addr);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::faceZonecellZone::max_index() const noexcept
{
return zoneMesh_.mesh().nFaces();
}
bool Foam::faFaceZone::checkDefinition(const bool report) const
{
return zone::checkDefinition(max_index(), report);
}
void Foam::faFaceZone::resetAddressing(faFaceZone&& zn)
{
if (this == &zn)
{
return; // Self-assignment is a no-op
}
clearAddressing();
labelList::transfer(static_cast<labelList&>(zn));
zn.clearAddressing();
}
void Foam::faFaceZone::resetAddressing(const faFaceZone& zn)
{
if (this == &zn)
{
return; // Self-assignment is a no-op
}
clearAddressing();
labelList::operator=(static_cast<const labelList&>(zn));
}
void Foam::faFaceZone::resetAddressing(const labelUList& addr)
{
clearAddressing();
labelList::operator=(addr);
}
void Foam::faFaceZone::resetAddressing(labelList&& addr)
{
clearAddressing();
labelList::transfer(addr);
}
void Foam::faFaceZone::write(Ostream& os) const
{
zone::write(os);
labelList::writeEntry(faFaceZone::labelsName(), os);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::faFaceZone::operator=(const faFaceZone& zn)
{
resetAddressing(zn);
}
void Foam::faFaceZone::operator=(const labelUList& addr)
{
resetAddressing(addr);
}
void Foam::faFaceZone::operator=(labelList&& addr)
{
resetAddressing(std::move(addr));
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const faFaceZone& zn)
{
zn.write(os);
os.check(FUNCTION_NAME);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2025 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/>.
Description
Foam::faFaceZoneMesh
\*---------------------------------------------------------------------------*/
#ifndef Foam_faFaceZoneMesh_H
#define Foam_faFaceZoneMesh_H
#include "ZoneMesh.H"
#include "faFaceZone.H"
#include "faFaceZoneMeshFwd.H"
#endif
// ************************************************************************* //

View File

@ -0,0 +1,52 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2025 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/>.
Typedef
Foam::faFaceZone
Description
A ZoneMesh with faFaceZone content on a faMesh
\*---------------------------------------------------------------------------*/
#ifndef Foam_faFaceZoneMeshFwd_H
#define Foam_faFaceZoneMeshFwd_H_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class faFaceZone;
class faMesh;
template<class ZoneType, class MeshType> class ZoneMesh;
typedef ZoneMesh<faFaceZone, faMesh> faFaceZoneMesh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //