mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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<pointZone>& zones = mesh.pointZones();
|
||||
mesh.pointZones().clearAddressing();
|
||||
auto& zmesh = mesh.pointZones();
|
||||
zmesh.clearAddressing();
|
||||
PtrList<pointZone>& 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<faceZone>& zones = mesh.faceZones();
|
||||
mesh.faceZones().clearAddressing();
|
||||
auto& zmesh = mesh.faceZones();
|
||||
zmesh.clearAddressing();
|
||||
PtrList<faceZone>& 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())
|
||||
{
|
||||
|
||||
@ -33,7 +33,6 @@ License
|
||||
|
||||
Foam::patchIdentifier::patchIdentifier()
|
||||
:
|
||||
name_(),
|
||||
index_(0)
|
||||
{}
|
||||
|
||||
|
||||
@ -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)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 * * * * * * * * * * * * * //
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -32,7 +32,6 @@ License
|
||||
|
||||
Foam::zoneIdentifier::zoneIdentifier()
|
||||
:
|
||||
name_(),
|
||||
index_(0)
|
||||
{}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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>
|
||||
Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::indices
|
||||
(
|
||||
@ -1069,16 +1095,76 @@ void Foam::ZoneMesh<ZoneType, MeshType>::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<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>
|
||||
bool Foam::ZoneMesh<ZoneType, MeshType>::writeData(Ostream& os) const
|
||||
{
|
||||
os << *this;
|
||||
writeEntry(os);
|
||||
return os.good();
|
||||
}
|
||||
|
||||
@ -1163,24 +1249,7 @@ Foam::Ostream& Foam::operator<<
|
||||
const ZoneMesh<ZoneType, MeshType>& 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;
|
||||
}
|
||||
|
||||
|
||||
@ -113,6 +113,9 @@ public:
|
||||
|
||||
// Public Typedefs
|
||||
|
||||
//- The referenced mesh type
|
||||
typedef MeshType mesh_type;
|
||||
|
||||
//- The zone type. Same as PtrList<ZoneType>::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
|
||||
|
||||
@ -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<labelList&>(*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)
|
||||
|
||||
@ -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<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,
|
||||
@ -195,6 +212,7 @@ public:
|
||||
virtual autoPtr<cellZone> 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<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.
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ namespace Foam
|
||||
class cellZone;
|
||||
class polyMesh;
|
||||
|
||||
template<class Zone, class MeshType> class ZoneMesh;
|
||||
template<class ZoneType, class MeshType> class ZoneMesh;
|
||||
typedef ZoneMesh<cellZone, polyMesh> cellZoneMesh;
|
||||
}
|
||||
|
||||
@ -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<boolList>("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<labelList&>(*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<const labelList&>(*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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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<primitiveFacePatch> 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<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,
|
||||
@ -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<const labelList&>(*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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ namespace Foam
|
||||
class faceZone;
|
||||
class polyMesh;
|
||||
|
||||
template<class Zone, class MeshType> class ZoneMesh;
|
||||
template<class ZoneType, class MeshType> class ZoneMesh;
|
||||
typedef ZoneMesh<faceZone, polyMesh> faceZoneMesh;
|
||||
}
|
||||
|
||||
@ -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<labelList&>(*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)
|
||||
|
||||
@ -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<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
|
||||
(
|
||||
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 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<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.
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ namespace Foam
|
||||
class pointZone;
|
||||
class polyMesh;
|
||||
|
||||
template<class Zone, class MeshType> class ZoneMesh;
|
||||
template<class ZoneType, class MeshType> class ZoneMesh;
|
||||
typedef ZoneMesh<pointZone, polyMesh> pointZoneMesh;
|
||||
}
|
||||
|
||||
@ -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<labelList>(labelsName)),
|
||||
lookupMapPtr_(nullptr)
|
||||
zoneIdentifier(name, dict, index)
|
||||
{
|
||||
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),
|
||||
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::label>& Foam::zone::lookupMap() const
|
||||
{
|
||||
const labelList& addr = *this;
|
||||
|
||||
lookupMapPtr_.reset(new Map<label>(2*addr.size()));
|
||||
lookupMapPtr_.reset(new Map<label>());
|
||||
auto& map = *lookupMapPtr_;
|
||||
map.reserve(addr.size());
|
||||
|
||||
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()
|
||||
{
|
||||
lookupMapPtr_.reset(nullptr);
|
||||
@ -169,7 +185,8 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
|
||||
bool hasError = false;
|
||||
|
||||
// To check for duplicate entries
|
||||
labelHashSet elems(2*size());
|
||||
labelHashSet elems;
|
||||
elems.reserve(addr.size());
|
||||
|
||||
for (const label id : addr)
|
||||
{
|
||||
@ -182,8 +199,7 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
|
||||
SeriousErrorInFunction
|
||||
<< "Zone " << this->name()
|
||||
<< " contains invalid index label " << id << nl
|
||||
<< "Valid index labels are 0.."
|
||||
<< maxSize-1 << endl;
|
||||
<< "Valid index labels are 0.." << (maxSize-1) << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -208,8 +224,8 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
|
||||
|
||||
void Foam::zone::write(Ostream& os) const
|
||||
{
|
||||
os << nl << this->name()
|
||||
<< nl << static_cast<const labelList&>(*this);
|
||||
os.writeEntry("type", type());
|
||||
zoneIdentifier::write(os);
|
||||
}
|
||||
|
||||
|
||||
@ -217,7 +233,9 @@ void Foam::zone::write(Ostream& os) const
|
||||
|
||||
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);
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -80,7 +80,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct
|
||||
//- Default construct: empty zone with name="", index=0
|
||||
zone();
|
||||
|
||||
//- Construct an empty zone with specified name and index
|
||||
@ -107,25 +107,36 @@ public:
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
//! The lookup name for the labelList. Ignored if empty
|
||||
const word& labelsName,
|
||||
const label index
|
||||
);
|
||||
|
||||
//- Construct given the name of the original zone (name is used)
|
||||
//- with new addressing and index (-ve: retain zone index).
|
||||
//- Copy construct with new 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 (-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
|
||||
(
|
||||
const zone& originalZone,
|
||||
labelList&& addr,
|
||||
//! The new index (-1 retains the original value)
|
||||
const label index
|
||||
);
|
||||
|
||||
@ -166,19 +177,19 @@ public:
|
||||
const bool report = false
|
||||
) 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
|
||||
|
||||
//- Write (dictionary entries)
|
||||
virtual void write(Ostream& os) const;
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<<(Ostream& os, const zone& zn);
|
||||
};
|
||||
|
||||
@ -1949,13 +1949,13 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
|
||||
// Note that this is not necessary for redistributePar since that already
|
||||
// checks for it. However other use (e.g. mesh generators) might not.
|
||||
const wordList pointZoneNames(mergeWordList(mesh_.pointZones().names()));
|
||||
reorderZones<pointZone>(pointZoneNames, mesh_.pointZones());
|
||||
reorderZones(pointZoneNames, mesh_.pointZones());
|
||||
|
||||
const wordList faceZoneNames(mergeWordList(mesh_.faceZones().names()));
|
||||
reorderZones<faceZone>(faceZoneNames, mesh_.faceZones());
|
||||
reorderZones(faceZoneNames, mesh_.faceZones());
|
||||
|
||||
const wordList cellZoneNames(mergeWordList(mesh_.cellZones().names()));
|
||||
reorderZones<cellZone>(cellZoneNames, mesh_.cellZones());
|
||||
reorderZones(cellZoneNames, mesh_.cellZones());
|
||||
|
||||
|
||||
// Local environment of all boundary faces
|
||||
|
||||
@ -98,12 +98,8 @@ class fvMeshDistribute
|
||||
static wordList mergeWordList(const wordList&);
|
||||
|
||||
//- Reorder zones according to names
|
||||
template<class ZoneType, class ZoneMesh>
|
||||
void reorderZones
|
||||
(
|
||||
const wordList& zoneNames,
|
||||
ZoneMesh& zones
|
||||
);
|
||||
template<class ZoneMesh>
|
||||
void reorderZones(const wordList& zoneNames, ZoneMesh& zones);
|
||||
|
||||
|
||||
// Patch handling
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,7 +30,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class ZoneType, class ZoneMesh>
|
||||
template<class ZoneMesh>
|
||||
void Foam::fvMeshDistribute::reorderZones
|
||||
(
|
||||
const wordList& zoneNames,
|
||||
@ -39,41 +39,50 @@ void Foam::fvMeshDistribute::reorderZones
|
||||
{
|
||||
zones.clearAddressing();
|
||||
|
||||
typedef typename ZoneMesh::zone_type zone_type;
|
||||
|
||||
// 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)
|
||||
{
|
||||
auto* zonePtr = zones.get(zonei);
|
||||
if (!zonePtr)
|
||||
if (!zones.get(zonei))
|
||||
{
|
||||
FatalErrorInFunction << "Problem with zones " << zones.names()
|
||||
FatalErrorInFunction
|
||||
<< "Problem with zone[" << zonei << "] " << zones.names()
|
||||
<< 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
|
||||
forAll(newZonePtrs, i)
|
||||
forAll(newPtrs, i)
|
||||
{
|
||||
if (!newZonePtrs.get(i))
|
||||
if (!newPtrs.get(i))
|
||||
{
|
||||
newZonePtrs.set
|
||||
(
|
||||
i,
|
||||
new ZoneType
|
||||
(
|
||||
zoneNames[i],
|
||||
i,
|
||||
zones
|
||||
)
|
||||
);
|
||||
newPtrs.emplace_set(i, zoneNames[i], i, zones);
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer
|
||||
zones.swap(newZonePtrs);
|
||||
oldPtrs = std::move(newPtrs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -11,6 +11,8 @@ faMesh/faMeshBoundaryHalo.C
|
||||
faMesh/faBoundaryMesh/faBoundaryMesh.C
|
||||
faMesh/faBoundaryMesh/faBoundaryMeshEntries.C
|
||||
|
||||
faceZone = faMesh/zones/faceZone/faFaceZone.cxx
|
||||
|
||||
faMesh/faMeshSubset/faMeshSubset.C
|
||||
faMesh/faMeshTools/faMeshTools.C
|
||||
faMesh/faMeshTools/faMeshToolsChecks.C
|
||||
|
||||
280
src/finiteArea/faMesh/zones/faceZone/faFaceZone.H
Normal file
280
src/finiteArea/faMesh/zones/faceZone/faFaceZone.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
259
src/finiteArea/faMesh/zones/faceZone/faFaceZone.cxx
Normal file
259
src/finiteArea/faMesh/zones/faceZone/faFaceZone.cxx
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
40
src/finiteArea/faMesh/zones/faceZone/faFaceZoneMesh.H
Normal file
40
src/finiteArea/faMesh/zones/faceZone/faFaceZoneMesh.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
52
src/finiteArea/faMesh/zones/faceZone/faFaceZoneMeshFwd.H
Normal file
52
src/finiteArea/faMesh/zones/faceZone/faFaceZoneMeshFwd.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user