Zone: New templated replacement for zone

This allows more functionality from the cellZone, faceZone and pointZone derived
classes to be moved into the base class.
This commit is contained in:
Henry Weller
2024-03-26 12:25:42 +00:00
parent a833a81560
commit ca2cae8c38
22 changed files with 285 additions and 271 deletions

View File

@ -19,7 +19,7 @@ Notes for fluentMeshToFoam with zone preservation
- Zones are simple lists of label lists that can be accessed from polyMesh
with the cellZones(), faceZones() and pointZones() member functions
- Example (Members from polyMesh.H and MeshZones.H):
- Example (Members from polyMesh.H and Zones.H):
const labelList& thisCellZone = mesh.cellZones()["thisZoneName"];
- Zone integrity is preserved during mesh modification and decompomposition.

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -61,7 +61,7 @@ void printMesh(const Time& runTime, const polyMesh& mesh)
template<class ZoneType>
void removeZone
(
MeshZones<ZoneType, polyMesh>& zones,
Zones<ZoneType, polyMesh>& zones,
const word& setName
)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -366,7 +366,7 @@ class vtkPVFoam
template<class ZoneType>
wordList getZoneNames
(
const MeshZones<ZoneType, polyMesh>&
const Zones<ZoneType, polyMesh>&
) const;
//- Add objects of Type to paraview array selection

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -77,12 +77,12 @@ void Foam::vtkPVFoam::convertSurfaceField
// For interior faces: average owner/neighbour
// For boundary faces: owner
forAll(faceLabels, facei)
forAll(faceLabels, i)
{
const label faceNo = faceLabels[facei];
if (faceNo < nInternalFaces)
const label facei = faceLabels[i];
if (facei < nInternalFaces)
{
Type t = 0.5*(tf[faceOwner[faceNo]] + tf[faceNeigh[faceNo]]);
const Type t = 0.5*(tf[faceOwner[facei]] + tf[faceNeigh[facei]]);
for (direction d=0; d<nComp; ++d)
{
@ -91,7 +91,10 @@ void Foam::vtkPVFoam::convertSurfaceField
}
else
{
const Type& t = tf[faceOwner[faceNo]];
const label patchi = mesh.boundaryMesh().whichPatch(facei);
const label pFacei = mesh.boundaryMesh()[patchi].whichFace(facei);
const Type& t = tf.boundaryField()[patchi][pFacei];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(t, d);
@ -99,7 +102,7 @@ void Foam::vtkPVFoam::convertSurfaceField
}
vtkOpenFOAMTupleRemap<Type>(vec);
cellData->InsertTuple(facei, vec);
cellData->InsertTuple(i, vec);
}
@ -157,21 +160,18 @@ void Foam::vtkPVFoam::convertSurfaceField
) = fvs;
}
// For interior faces: average owner/neighbour
// For boundary faces: owner
forAll(faceLabels, facei)
forAll(faceLabels, i)
{
const label faceNo = faceLabels[facei];
const label facei = faceLabels[i];
float vec[nComp];
for (direction d=0; d<nComp; ++d)
{
vec[d] = component(flatFld[faceNo], d);
vec[d] = component(flatFld[facei], d);
}
vtkOpenFOAMTupleRemap<Type>(vec);
cellData->InsertTuple(facei, vec);
cellData->InsertTuple(i, vec);
}
vtkPolyData::SafeDownCast

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -84,7 +84,7 @@ public:
template<class ZoneType>
Foam::wordList Foam::vtkPVFoam::getZoneNames
(
const MeshZones<ZoneType, polyMesh>& zmesh
const Zones<ZoneType, polyMesh>& zmesh
) const
{
wordList names(zmesh.size());

View File

@ -511,7 +511,6 @@ $(polyMesh)/polyMeshTetDecomposition/polyMeshTetDecomposition.C
$(polyMesh)/polyMeshTetDecomposition/tetIndices.C
zone = $(polyMesh)/zones/zone
$(zone)/zone.C
cellZone = $(polyMesh)/zones/cellZone
$(cellZone)/cellZone.C

View File

@ -23,22 +23,15 @@ License
\*---------------------------------------------------------------------------*/
#include "zone.H"
#include "Zone.H"
#include "IOstream.H"
#include "demandDrivenData.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(zone, 0);
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
const Foam::Map<Foam::label>& Foam::zone::lookupMap() const
template<class ZoneType, class ZonesType>
const Foam::Map<Foam::label>& Foam::Zone<ZoneType, ZonesType>::lookupMap() const
{
if (!lookupMapPtr_)
{
@ -49,13 +42,9 @@ const Foam::Map<Foam::label>& Foam::zone::lookupMap() const
}
void Foam::zone::calcLookupMap() const
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::calcLookupMap() const
{
if (debug)
{
InfoInFunction << "Calculating lookup map" << endl;
}
if (lookupMapPtr_)
{
FatalErrorInFunction
@ -72,80 +61,91 @@ void Foam::zone::calcLookupMap() const
{
lm.insert(indices[i], i);
}
if (debug)
{
InfoInFunction << "Finished calculating lookup map" << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::zone::zone
template<class ZoneType, class ZonesType>
Foam::Zone<ZoneType, ZonesType>::Zone
(
const word& name,
const labelUList& indices
const labelUList& indices,
const ZonesType& zones
)
:
labelList(indices),
name_(name),
zones_(zones),
lookupMapPtr_(nullptr)
{}
Foam::zone::zone
template<class ZoneType, class ZonesType>
Foam::Zone<ZoneType, ZonesType>::Zone
(
const word& name,
labelList&& indices
labelList&& indices,
const ZonesType& zones
)
:
labelList(move(indices)),
name_(name),
zones_(zones),
lookupMapPtr_(nullptr)
{}
Foam::zone::zone
template<class ZoneType, class ZonesType>
Foam::Zone<ZoneType, ZonesType>::Zone
(
const word& name,
const dictionary& dict,
const word& labelsName
const word& labelsName,
const ZonesType& zones
)
:
labelList(dict.lookup(labelsName)),
name_(name),
zones_(zones),
lookupMapPtr_(nullptr)
{}
Foam::zone::zone
template<class ZoneType, class ZonesType>
Foam::Zone<ZoneType, ZonesType>::Zone
(
const zone& z,
const labelUList& indices
const Zone& z,
const labelUList& indices,
const ZonesType& zones
)
:
labelList(indices),
name_(z.name()),
zones_(zones),
lookupMapPtr_(nullptr)
{}
Foam::zone::zone
template<class ZoneType, class ZonesType>
Foam::Zone<ZoneType, ZonesType>::Zone
(
const zone& z,
labelList&& indices
const Zone& z,
labelList&& indices,
const ZonesType& zones
)
:
labelList(move(indices)),
name_(z.name()),
zones_(zones),
lookupMapPtr_(nullptr)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::zone::~zone()
template<class ZoneType, class ZonesType>
Foam::Zone<ZoneType, ZonesType>::~Zone()
{
clearAddressing();
}
@ -153,7 +153,18 @@ Foam::zone::~zone()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::zone::localIndex(const label globalIndex) const
template<class ZoneType, class ZonesType>
const ZonesType& Foam::Zone<ZoneType, ZonesType>::meshZones() const
{
return zones_;
}
template<class ZoneType, class ZonesType>
Foam::label Foam::Zone<ZoneType, ZonesType>::localIndex
(
const label globalIndex
) const
{
const Map<label>& lm = lookupMap();
@ -170,13 +181,19 @@ Foam::label Foam::zone::localIndex(const label globalIndex) const
}
void Foam::zone::clearAddressing()
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::clearAddressing()
{
deleteDemandDrivenData(lookupMapPtr_);
}
bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
template<class ZoneType, class ZonesType>
bool Foam::Zone<ZoneType, ZonesType>::checkDefinition
(
const label maxSize,
const bool report
) const
{
const labelList& indices = *this;
@ -220,7 +237,8 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
}
void Foam::zone::insert(const labelHashSet& newIndices)
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::insert(const labelHashSet& newIndices)
{
labelHashSet indices(*this);
indices.insert(newIndices);
@ -228,26 +246,30 @@ void Foam::zone::insert(const labelHashSet& newIndices)
}
void Foam::zone::swap(zone& z)
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::swap(Zone& z)
{
clearAddressing();
labelList::swap(z);
}
void Foam::zone::mapMesh(const polyMeshMap&)
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::mapMesh(const polyMeshMap&)
{
clearAddressing();
}
void Foam::zone::distribute(const polyDistributionMap&)
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::distribute(const polyDistributionMap&)
{
clearAddressing();
}
void Foam::zone::write(Ostream& os) const
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::write(Ostream& os) const
{
os << nl << name_
<< nl << static_cast<const labelList&>(*this);
@ -256,28 +278,32 @@ void Foam::zone::write(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::zone::operator=(const zone& zn)
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::operator=(const Zone& zn)
{
clearAddressing();
labelList::operator=(zn);
}
void Foam::zone::operator=(zone&& zn)
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::operator=(Zone&& zn)
{
clearAddressing();
labelList::operator=(move(zn));
}
void Foam::zone::operator=(const labelUList& indices)
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::operator=(const labelUList& indices)
{
clearAddressing();
labelList::operator=(indices);
}
void Foam::zone::operator=(labelList&& indices)
template<class ZoneType, class ZonesType>
void Foam::Zone<ZoneType, ZonesType>::operator=(labelList&& indices)
{
clearAddressing();
labelList::operator=(move(indices));
@ -286,10 +312,11 @@ void Foam::zone::operator=(labelList&& indices)
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const zone& z)
template<class ZoneType, class ZonesType>
Foam::Ostream& Foam::operator<<(Ostream& os, const Zone<ZoneType, ZonesType>& z)
{
z.write(os);
os.check("Ostream& operator<<(Ostream& f, const zone& z");
os.check("Ostream& operator<<(Ostream& f, const Zone& z");
return os;
}

View File

@ -22,18 +22,18 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::zone
Foam::Zone
Description
Base class for zones
SourceFiles
zone.C
Zone.C
\*---------------------------------------------------------------------------*/
#ifndef zone_H
#define zone_H
#ifndef Zone_H
#define Zone_H
#include "labelList.H"
#include "typeInfo.H"
@ -52,14 +52,17 @@ class polyTopoChangeMap;
class polyMeshMap;
class polyDistributionMap;
class zone;
Ostream& operator<<(Ostream&, const zone&);
template<class ZoneType, class ZonesType> class Zone;
template<class ZoneType, class ZonesType>
Ostream& operator<<(Ostream&, const Zone<ZoneType, ZonesType>&);
/*---------------------------------------------------------------------------*\
Class zone Declaration
Class Zone Declaration
\*---------------------------------------------------------------------------*/
class zone
template<class ZoneType, class ZonesType>
class Zone
:
public labelList
{
@ -71,6 +74,9 @@ protected:
//- Name of zone
word name_;
//- Reference to zone list
const ZonesType& zones_;
// Demand-driven private data
@ -86,56 +92,57 @@ protected:
public:
//- Runtime type information
TypeName("zone");
// Constructors
//- Construct from components
zone
Zone
(
const word& name,
const labelUList& indices
const labelUList& indices,
const ZonesType& zones
);
//- Construct from components, moving contents
zone
Zone
(
const word& name,
labelList&& indices
labelList&& indices,
const ZonesType& zones
);
//- Construct from dictionary
zone
Zone
(
const word& name,
const dictionary&,
const word& labelsName
const word& labelsName,
const ZonesType& zones
);
//- Construct given the original zone and resetting the
// cell list and mesh zones information
zone
Zone
(
const zone&,
const labelUList& indices
const Zone&,
const labelUList& indices,
const ZonesType& zones
);
//- Construct given the original zone, resetting the
// cell list and mesh zones information
zone
Zone
(
const zone&,
labelList&& indices
const Zone&,
labelList&& indices,
const ZonesType& zones
);
//- Disallow default bitwise copy construction
zone(const zone&) = delete;
Zone(const Zone&) = delete;
//- Destructor
virtual ~zone();
virtual ~Zone();
// Member Functions
@ -146,6 +153,9 @@ public:
return name_;
}
//- Return ZonesType reference
const ZonesType& meshZones() const;
//- Map storing the local index for every global index. Used to find
// the index of the item in the zone from the known global index. If
// the item is not in the zone, returns -1
@ -171,7 +181,7 @@ public:
void insert(const labelHashSet& newIndices);
//- Swap two zones
void swap(zone&);
void swap(Zone&);
//- Correct patch after moving points
virtual void movePoints(const pointField&)
@ -196,10 +206,10 @@ public:
// Member Operators
//- Assignment operator
void operator=(const zone&);
void operator=(const Zone&);
//- Move assignment operator
void operator=(zone&&);
void operator=(Zone&&);
//- Assignment operator to indices
void operator=(const labelUList&);
@ -211,7 +221,11 @@ public:
// I-O
//- Ostream Operator
friend Ostream& operator<<(Ostream&, const zone&);
friend Ostream& operator<< <ZoneType, ZonesType>
(
Ostream&,
const Zone<ZoneType, ZonesType>&
);
};
@ -221,6 +235,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "Zone.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,14 +23,14 @@ License
\*---------------------------------------------------------------------------*/
#include "MeshZones.H"
#include "Zones.H"
#include "Pstream.H"
#include "demandDrivenData.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ZoneType, class MeshType>
bool Foam::MeshZones<ZoneType, MeshType>::read()
bool Foam::Zones<ZoneType, MeshType>::read()
{
if
(
@ -72,7 +72,7 @@ bool Foam::MeshZones<ZoneType, MeshType>::read()
// Check state of IOstream
is.check
(
"MeshZones::MeshZones"
"Zones::Zones"
"(const IOobject&, const MeshType&)"
);
@ -91,7 +91,7 @@ bool Foam::MeshZones<ZoneType, MeshType>::read()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ZoneType, class MeshType>
Foam::MeshZones<ZoneType, MeshType>::MeshZones
Foam::Zones<ZoneType, MeshType>::Zones
(
const IOobject& io,
const MeshType& mesh
@ -106,7 +106,7 @@ Foam::MeshZones<ZoneType, MeshType>::MeshZones
template<class ZoneType, class MeshType>
Foam::MeshZones<ZoneType, MeshType>::MeshZones
Foam::Zones<ZoneType, MeshType>::Zones
(
const IOobject& io,
const MeshType& mesh,
@ -123,7 +123,7 @@ Foam::MeshZones<ZoneType, MeshType>::MeshZones
template<class ZoneType, class MeshType>
Foam::MeshZones<ZoneType, MeshType>::MeshZones
Foam::Zones<ZoneType, MeshType>::Zones
(
const IOobject& io,
const MeshType& mesh,
@ -150,7 +150,7 @@ Foam::MeshZones<ZoneType, MeshType>::MeshZones
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ZoneType, class MeshType>
Foam::MeshZones<ZoneType, MeshType>::~MeshZones()
Foam::Zones<ZoneType, MeshType>::~Zones()
{
clearAddressing();
}
@ -159,7 +159,7 @@ Foam::MeshZones<ZoneType, MeshType>::~MeshZones()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ZoneType, class MeshType>
bool Foam::MeshZones<ZoneType, MeshType>::found(const label objectIndex) const
bool Foam::Zones<ZoneType, MeshType>::found(const label objectIndex) const
{
forAll(*this, zi)
{
@ -174,7 +174,7 @@ bool Foam::MeshZones<ZoneType, MeshType>::found(const label objectIndex) const
template<class ZoneType, class MeshType>
Foam::labelList Foam::MeshZones<ZoneType, MeshType>::whichZones
Foam::labelList Foam::Zones<ZoneType, MeshType>::whichZones
(
const label objectIndex
) const
@ -194,7 +194,7 @@ Foam::labelList Foam::MeshZones<ZoneType, MeshType>::whichZones
template<class ZoneType, class MeshType>
Foam::boolList Foam::MeshZones<ZoneType, MeshType>::zonesFlipFace
Foam::boolList Foam::Zones<ZoneType, MeshType>::zonesFlipFace
(
const label facei,
const labelList& faceiZones
@ -214,7 +214,7 @@ Foam::boolList Foam::MeshZones<ZoneType, MeshType>::zonesFlipFace
template<class ZoneType, class MeshType>
Foam::wordList Foam::MeshZones<ZoneType, MeshType>::types() const
Foam::wordList Foam::Zones<ZoneType, MeshType>::types() const
{
const PtrList<ZoneType>& zones = *this;
@ -230,7 +230,7 @@ Foam::wordList Foam::MeshZones<ZoneType, MeshType>::types() const
template<class ZoneType, class MeshType>
Foam::wordList Foam::MeshZones<ZoneType, MeshType>::names() const
Foam::wordList Foam::Zones<ZoneType, MeshType>::names() const
{
const PtrList<ZoneType>& zones = *this;
@ -246,7 +246,7 @@ Foam::wordList Foam::MeshZones<ZoneType, MeshType>::names() const
template<class ZoneType, class MeshType>
bool Foam::MeshZones<ZoneType, MeshType>::found
bool Foam::Zones<ZoneType, MeshType>::found
(
const word& zoneName
) const
@ -268,7 +268,7 @@ bool Foam::MeshZones<ZoneType, MeshType>::found
template<class ZoneType, class MeshType>
Foam::label Foam::MeshZones<ZoneType, MeshType>::findIndex
Foam::label Foam::Zones<ZoneType, MeshType>::findIndex
(
const word& zoneName
) const
@ -297,7 +297,7 @@ Foam::label Foam::MeshZones<ZoneType, MeshType>::findIndex
template<class ZoneType, class MeshType>
Foam::labelList Foam::MeshZones<ZoneType, MeshType>::findIndices
Foam::labelList Foam::Zones<ZoneType, MeshType>::findIndices
(
const wordRe& key
) const
@ -330,7 +330,7 @@ Foam::labelList Foam::MeshZones<ZoneType, MeshType>::findIndices
template<class ZoneType, class MeshType>
Foam::PackedBoolList Foam::MeshZones<ZoneType, MeshType>::findMatching
Foam::PackedBoolList Foam::Zones<ZoneType, MeshType>::findMatching
(
const wordRe& key
) const
@ -348,10 +348,10 @@ Foam::PackedBoolList Foam::MeshZones<ZoneType, MeshType>::findMatching
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::append(ZoneType* zonePtr) const
void Foam::Zones<ZoneType, MeshType>::append(ZoneType* zonePtr) const
{
MeshZones<ZoneType, MeshType>& zones =
const_cast<MeshZones<ZoneType, MeshType>&>(*this);
Zones<ZoneType, MeshType>& zones =
const_cast<Zones<ZoneType, MeshType>&>(*this);
if (found(zonePtr->name()))
{
@ -366,10 +366,10 @@ void Foam::MeshZones<ZoneType, MeshType>::append(ZoneType* zonePtr) const
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::append(const ZoneType& zone) const
void Foam::Zones<ZoneType, MeshType>::append(const ZoneType& zone) const
{
MeshZones<ZoneType, MeshType>& zones =
const_cast<MeshZones<ZoneType, MeshType>&>(*this);
Zones<ZoneType, MeshType>& zones =
const_cast<Zones<ZoneType, MeshType>&>(*this);
if (found(zone.name()))
{
@ -383,7 +383,7 @@ void Foam::MeshZones<ZoneType, MeshType>::append(const ZoneType& zone) const
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::clearAddressing()
void Foam::Zones<ZoneType, MeshType>::clearAddressing()
{
PtrList<ZoneType>& zones = *this;
@ -395,7 +395,7 @@ void Foam::MeshZones<ZoneType, MeshType>::clearAddressing()
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::clear()
void Foam::Zones<ZoneType, MeshType>::clear()
{
clearAddressing();
PtrList<ZoneType>::clear();
@ -403,7 +403,7 @@ void Foam::MeshZones<ZoneType, MeshType>::clear()
template<class ZoneType, class MeshType>
bool Foam::MeshZones<ZoneType, MeshType>::checkDefinition
bool Foam::Zones<ZoneType, MeshType>::checkDefinition
(
const bool report
) const
@ -421,7 +421,7 @@ bool Foam::MeshZones<ZoneType, MeshType>::checkDefinition
template<class ZoneType, class MeshType>
bool Foam::MeshZones<ZoneType, MeshType>::checkParallelSync
bool Foam::Zones<ZoneType, MeshType>::checkParallelSync
(
const bool report
) const
@ -499,7 +499,7 @@ bool Foam::MeshZones<ZoneType, MeshType>::checkParallelSync
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::movePoints(const pointField& p)
void Foam::Zones<ZoneType, MeshType>::movePoints(const pointField& p)
{
PtrList<ZoneType>& zones = *this;
@ -511,7 +511,7 @@ void Foam::MeshZones<ZoneType, MeshType>::movePoints(const pointField& p)
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::topoChange
void Foam::Zones<ZoneType, MeshType>::topoChange
(
const polyTopoChangeMap& map
)
@ -526,7 +526,7 @@ void Foam::MeshZones<ZoneType, MeshType>::topoChange
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::mapMesh(const polyMeshMap& map)
void Foam::Zones<ZoneType, MeshType>::mapMesh(const polyMeshMap& map)
{
PtrList<ZoneType>& zones = *this;
@ -538,7 +538,7 @@ void Foam::MeshZones<ZoneType, MeshType>::mapMesh(const polyMeshMap& map)
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::distribute
void Foam::Zones<ZoneType, MeshType>::distribute
(
const polyDistributionMap& map
)
@ -553,7 +553,7 @@ void Foam::MeshZones<ZoneType, MeshType>::distribute
template<class ZoneType, class MeshType>
void Foam::MeshZones<ZoneType, MeshType>::swap(MeshZones& otherZones)
void Foam::Zones<ZoneType, MeshType>::swap(Zones& otherZones)
{
clearAddressing();
otherZones.clearAddressing();
@ -602,7 +602,7 @@ void Foam::MeshZones<ZoneType, MeshType>::swap(MeshZones& otherZones)
template<class ZoneType, class MeshType>
bool Foam::MeshZones<ZoneType, MeshType>::writeData(Ostream& os) const
bool Foam::Zones<ZoneType, MeshType>::writeData(Ostream& os) const
{
os << *this;
return os.good();
@ -612,7 +612,7 @@ bool Foam::MeshZones<ZoneType, MeshType>::writeData(Ostream& os) const
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template<class ZoneType, class MeshType>
const ZoneType& Foam::MeshZones<ZoneType, MeshType>::operator[]
const ZoneType& Foam::Zones<ZoneType, MeshType>::operator[]
(
const word& zoneName
) const
@ -632,7 +632,7 @@ const ZoneType& Foam::MeshZones<ZoneType, MeshType>::operator[]
template<class ZoneType, class MeshType>
ZoneType& Foam::MeshZones<ZoneType, MeshType>::operator[]
ZoneType& Foam::Zones<ZoneType, MeshType>::operator[]
(
const word& zoneName
)
@ -657,7 +657,7 @@ template<class ZoneType, class MeshType>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const MeshZones<ZoneType, MeshType>& zones
const Zones<ZoneType, MeshType>& zones
)
{
os << zones.size() << nl << token::BEGIN_LIST;

View File

@ -22,18 +22,18 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::MeshZones
Foam::Zones
Description
A list of mesh zones.
SourceFiles
MeshZones.C
Zones.C
\*---------------------------------------------------------------------------*/
#ifndef MeshZones_H
#define MeshZones_H
#ifndef Zones_H
#define Zones_H
#include "regIOobject.H"
#include "pointField.H"
@ -54,17 +54,17 @@ class polyTopoChangeMap;
class polyMeshMap;
class polyDistributionMap;
template<class ZoneType, class MeshType> class MeshZones;
template<class ZoneType, class MeshType> class Zones;
template<class ZoneType, class MeshType>
Ostream& operator<<(Ostream&, const MeshZones<ZoneType, MeshType>&);
Ostream& operator<<(Ostream&, const Zones<ZoneType, MeshType>&);
/*---------------------------------------------------------------------------*\
Class MeshZones Declaration
Class Zones Declaration
\*---------------------------------------------------------------------------*/
template<class ZoneType, class MeshType>
class MeshZones
class Zones
:
public PtrList<ZoneType>,
public regIOobject
@ -86,14 +86,14 @@ public:
// Constructors
//- Read constructor given IOobject and a MeshType reference
MeshZones
Zones
(
const IOobject&,
const MeshType&
);
//- Construct given size
MeshZones
//- Read constructor if file present otherwise from size
Zones
(
const IOobject&,
const MeshType&,
@ -101,7 +101,7 @@ public:
);
//- Construct given a PtrList
MeshZones
Zones
(
const IOobject&,
const MeshType&,
@ -109,14 +109,14 @@ public:
);
//- Move constructor
MeshZones(MeshZones&&) = default;
Zones(Zones&&) = default;
//- Disallow default bitwise copy construction
MeshZones(const MeshZones&) = delete;
Zones(const Zones&) = delete;
//- Destructor
~MeshZones();
~Zones();
// Member Functions
@ -192,7 +192,7 @@ public:
//- Swap zones
// For run-time mesh replacement and mesh to mesh mapping
void swap(MeshZones&);
void swap(Zones&);
//- writeData member function required by regIOobject
bool writeData(Ostream&) const;
@ -210,7 +210,7 @@ public:
ZoneType& operator[](const word&);
//- Disallow default bitwise assignment
void operator=(const MeshZones<ZoneType, MeshType>&) = delete;
void operator=(const Zones<ZoneType, MeshType>&) = delete;
// Ostream operator
@ -218,7 +218,7 @@ public:
friend Ostream& operator<< <ZoneType, MeshType>
(
Ostream&,
const MeshZones<ZoneType, MeshType>&
const Zones<ZoneType, MeshType>&
);
};
@ -230,7 +230,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "MeshZones.C"
#include "Zones.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,7 +29,7 @@ Description
#ifndef meshCellZones_H
#define meshCellZones_H
#include "MeshZones.H"
#include "Zones.H"
#include "cellZone.H"
#include "meshCellZonesFwd.H"

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,7 +25,7 @@ Typedef
Foam::meshCellZones
Description
A MeshZones with the type cellZone
A Zones with the type cellZone
\*---------------------------------------------------------------------------*/
@ -36,11 +36,11 @@ Description
namespace Foam
{
template<class Zone, class MeshType> class MeshZones;
template<class Zone, class MeshType> class Zones;
class cellZone;
class polyMesh;
typedef MeshZones<cellZone, polyMesh> meshCellZones;
typedef Zones<cellZone, polyMesh> meshCellZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,7 +29,7 @@ Description
#ifndef meshFaceZones_H
#define meshFaceZones_H
#include "MeshZones.H"
#include "Zones.H"
#include "faceZone.H"
#include "meshFaceZonesFwd.H"

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,22 +25,33 @@ Typedef
Foam::meshFaceZones
Description
A MeshZones with the type faceZone
A Zones with the type faceZone
\*---------------------------------------------------------------------------*/
#ifndef meshFaceZonesFwd_H
#define meshFaceZonesFwd_H
#include "Zones.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Zone, class MeshType> class MeshZones;
template<class Zone, class MeshType> class Zones;
class faceZone;
class polyMesh;
typedef MeshZones<faceZone, polyMesh> meshFaceZones;
typedef Zones<faceZone, polyMesh> meshFaceZones;
// class meshFaceZones
// :
// public Zones<faceZone, polyMesh>
// {
// public:
// using Zones<faceZone, polyMesh>::Zones;
// };
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,7 +29,7 @@ Description
#ifndef meshPointZones_H
#define meshPointZones_H
#include "MeshZones.H"
#include "Zones.H"
#include "pointZone.H"
#include "meshPointZonesFwd.H"

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,7 +25,7 @@ Typedef
Foam::meshPointZones
Description
A MeshZones with the type pointZone
A Zones with the type pointZone
\*---------------------------------------------------------------------------*/
@ -36,11 +36,11 @@ Description
namespace Foam
{
template<class Zone, class MeshType> class MeshZones;
template<class Zone, class MeshType> class Zones;
class pointZone;
class polyMesh;
typedef MeshZones<pointZone, polyMesh> meshPointZones;
typedef Zones<pointZone, polyMesh> meshPointZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -49,8 +49,7 @@ Foam::cellZone::cellZone
const meshCellZones& mz
)
:
zone(name, addr),
meshZones_(mz)
Zone<cellZone, meshCellZones>(name, addr, mz)
{}
@ -61,8 +60,7 @@ Foam::cellZone::cellZone
const meshCellZones& mz
)
:
zone(name, move(addr)),
meshZones_(mz)
Zone<cellZone, meshCellZones>(name, move(addr), mz)
{}
@ -73,8 +71,7 @@ Foam::cellZone::cellZone
const meshCellZones& mz
)
:
zone(name, dict, this->labelsName),
meshZones_(mz)
Zone<cellZone, meshCellZones>(name, dict, this->labelsName, mz)
{}
@ -85,8 +82,7 @@ Foam::cellZone::cellZone
const meshCellZones& mz
)
:
zone(cz, addr),
meshZones_(mz)
Zone<cellZone, meshCellZones>(cz, addr, mz)
{}
@ -97,8 +93,7 @@ Foam::cellZone::cellZone
const meshCellZones& mz
)
:
zone(cz, move(addr)),
meshZones_(mz)
Zone<cellZone, meshCellZones>(cz, move(addr), mz)
{}
@ -112,19 +107,17 @@ Foam::cellZone::~cellZone()
Foam::label Foam::cellZone::whichCell(const label globalCellID) const
{
return zone::localIndex(globalCellID);
}
const Foam::meshCellZones& Foam::cellZone::meshZones() const
{
return meshZones_;
return Zone<cellZone, meshCellZones>::localIndex(globalCellID);
}
bool Foam::cellZone::checkDefinition(const bool report) const
{
return zone::checkDefinition(meshZones_.mesh().nCells(), report);
return Zone<cellZone, meshCellZones>::checkDefinition
(
zones_.mesh().nCells(),
report
);
}
@ -171,13 +164,13 @@ void Foam::cellZone::writeDict(Ostream& os) const
void Foam::cellZone::operator=(const cellZone& zn)
{
zone::operator=(zn);
Zone<cellZone, meshCellZones>::operator=(zn);
}
void Foam::cellZone::operator=(cellZone&& zn)
{
zone::operator=(move(zn));
Zone<cellZone, meshCellZones>::operator=(move(zn));
}

View File

@ -41,7 +41,7 @@ SourceFiles
#ifndef cellZone_H
#define cellZone_H
#include "zone.H"
#include "Zone.H"
#include "meshCellZonesFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,19 +55,13 @@ namespace Foam
class cellZone
:
public zone
public Zone<cellZone, meshCellZones>
{
protected:
// Protected data
//- Reference to zone list
const meshCellZones& meshZones_;
public:
typedef meshCellZones ZonesType;
// Static Data Members
//- The name associated with the zone-labels dictionary entry
@ -187,9 +181,6 @@ public:
//- Convenient renaming of zone::localIndex(globalIndex)
label whichCell(const label globalIndex) const;
//- Return meshZones reference
const meshCellZones& meshZones() const;
//- Check zone definition. Return true if in error.
virtual bool checkDefinition(const bool report = false) const;
@ -209,7 +200,7 @@ public:
// Member Operators
using zone::operator=;
using Zone<cellZone, meshCellZones>::operator=;
//- Assignment to zone, clearing demand-driven data
void operator=(const cellZone&);

View File

@ -205,9 +205,8 @@ Foam::faceZone::faceZone
const meshFaceZones& mz
)
:
zone(name, addr),
Zone<faceZone, meshFaceZones>(name, addr, mz),
flipMap_(fm),
meshZones_(mz),
patchPtr_(nullptr),
masterCellsPtr_(nullptr),
slaveCellsPtr_(nullptr),
@ -225,9 +224,8 @@ Foam::faceZone::faceZone
const meshFaceZones& mz
)
:
zone(name, move(addr)),
Zone<faceZone, meshFaceZones>(name, move(addr), mz),
flipMap_(move(fm)),
meshZones_(mz),
patchPtr_(nullptr),
masterCellsPtr_(nullptr),
slaveCellsPtr_(nullptr),
@ -244,9 +242,8 @@ Foam::faceZone::faceZone
const meshFaceZones& mz
)
:
zone(name, dict, this->labelsName),
Zone<faceZone, meshFaceZones>(name, dict, this->labelsName, mz),
flipMap_(dict.lookup("flipMap")),
meshZones_(mz),
patchPtr_(nullptr),
masterCellsPtr_(nullptr),
slaveCellsPtr_(nullptr),
@ -264,9 +261,8 @@ Foam::faceZone::faceZone
const meshFaceZones& mz
)
:
zone(fz, addr),
Zone<faceZone, meshFaceZones>(fz, addr, mz),
flipMap_(fm),
meshZones_(mz),
patchPtr_(nullptr),
masterCellsPtr_(nullptr),
slaveCellsPtr_(nullptr),
@ -284,9 +280,8 @@ Foam::faceZone::faceZone
const meshFaceZones& mz
)
:
zone(fz, move(addr)),
Zone<faceZone, meshFaceZones>(fz, move(addr), mz),
flipMap_(move(fm)),
meshZones_(mz),
patchPtr_(nullptr),
masterCellsPtr_(nullptr),
slaveCellsPtr_(nullptr),
@ -306,15 +301,9 @@ Foam::faceZone::~faceZone()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::meshFaceZones& Foam::faceZone::meshZones() const
{
return meshZones_;
}
Foam::label Foam::faceZone::whichFace(const label globalFaceID) const
{
return zone::localIndex(globalFaceID);
return Zone<faceZone, meshFaceZones>::localIndex(globalFaceID);
}
@ -372,7 +361,7 @@ const Foam::labelList& Foam::faceZone::meshEdges() const
void Foam::faceZone::clearAddressing()
{
zone::clearAddressing();
Zone<faceZone, meshFaceZones>::clearAddressing();
deleteDemandDrivenData(patchPtr_);
@ -397,7 +386,11 @@ void Foam::faceZone::resetAddressing
bool Foam::faceZone::checkDefinition(const bool report) const
{
return zone::checkDefinition(meshZones().mesh().faces().size(), report);
return Zone<faceZone, meshFaceZones>::checkDefinition
(
meshZones().mesh().faces().size(),
report
);
}
@ -498,7 +491,7 @@ void Foam::faceZone::insert(const Map<bool>& newIndices)
void Foam::faceZone::swap(faceZone& fz)
{
zone::swap(fz);
Zone<faceZone, meshFaceZones>::swap(fz);
flipMap_.swap(fz.flipMap_);
}
@ -577,14 +570,14 @@ void Foam::faceZone::writeDict(Ostream& os) const
void Foam::faceZone::operator=(const faceZone& zn)
{
zone::operator=(zn);
Zone<faceZone, meshFaceZones>::operator=(zn);
flipMap_ = zn.flipMap_;
}
void Foam::faceZone::operator=(faceZone&& zn)
{
zone::operator=(move(zn));
Zone<faceZone, meshFaceZones>::operator=(move(zn));
flipMap_ = move(zn.flipMap_);
}

View File

@ -40,7 +40,7 @@ SourceFiles
#ifndef faceZone_H
#define faceZone_H
#include "zone.H"
#include "Zone.H"
#include "meshFaceZonesFwd.H"
#include "boolList.H"
#include "primitiveFacePatch.H"
@ -62,7 +62,7 @@ Ostream& operator<<(Ostream&, const faceZone&);
class faceZone
:
public zone
public Zone<faceZone, meshFaceZones>
{
// Private Data
@ -78,9 +78,6 @@ protected:
// face needs to be flipped to achieve the correct orientation.
boolList flipMap_;
//- Reference to zone list
const meshFaceZones& meshZones_;
// Demand-driven private data
@ -117,6 +114,8 @@ protected:
public:
typedef meshFaceZones ZonesType;
// Static Data Members
//- The name associated with the zone-labels dictionary entry
@ -250,9 +249,6 @@ public:
//- Return reference to primitive patch
const primitiveFacePatch& operator()() const;
//- Return meshZones reference
const meshFaceZones& meshZones() const;
// Addressing into mesh

View File

@ -50,8 +50,7 @@ Foam::pointZone::pointZone
const meshPointZones& mz
)
:
zone(name, addr),
meshZones_(mz)
Zone<pointZone, meshPointZones>(name, addr, mz)
{}
@ -62,8 +61,7 @@ Foam::pointZone::pointZone
const meshPointZones& mz
)
:
zone(name, move(addr)),
meshZones_(mz)
Zone<pointZone, meshPointZones>(name, move(addr), mz)
{}
@ -74,8 +72,7 @@ Foam::pointZone::pointZone
const meshPointZones& mz
)
:
zone(name, dict, this->labelsName),
meshZones_(mz)
Zone<pointZone, meshPointZones>(name, dict, this->labelsName, mz)
{}
@ -86,8 +83,7 @@ Foam::pointZone::pointZone
const meshPointZones& mz
)
:
zone(pz, addr),
meshZones_(mz)
Zone<pointZone, meshPointZones>(pz, addr, mz)
{}
@ -98,8 +94,7 @@ Foam::pointZone::pointZone
const meshPointZones& mz
)
:
zone(pz, move(addr)),
meshZones_(mz)
Zone<pointZone, meshPointZones>(pz, move(addr), mz)
{}
@ -111,21 +106,19 @@ Foam::pointZone::~pointZone()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::meshPointZones& Foam::pointZone::meshZones() const
{
return meshZones_;
}
Foam::label Foam::pointZone::whichPoint(const label globalPointID) const
{
return zone::localIndex(globalPointID);
return Zone<pointZone, meshPointZones>::localIndex(globalPointID);
}
bool Foam::pointZone::checkDefinition(const bool report) const
{
return zone::checkDefinition(meshZones_.mesh().points().size(), report);
return Zone<pointZone, meshPointZones>::checkDefinition
(
zones_.mesh().points().size(),
report
);
}
@ -133,7 +126,7 @@ bool Foam::pointZone::checkParallelSync(const bool report) const
{
const polyMesh& mesh = meshZones().mesh();
const label index = meshZones_.findIndex(name());
const label index = zones_.findIndex(name());
labelList maxZone(mesh.nPoints(), -1);
labelList minZone(mesh.nPoints(), labelMax);
@ -224,13 +217,13 @@ void Foam::pointZone::writeDict(Ostream& os) const
void Foam::pointZone::operator=(const pointZone& zn)
{
zone::operator=(zn);
Zone<pointZone, meshPointZones>::operator=(zn);
}
void Foam::pointZone::operator=(pointZone&& zn)
{
zone::operator=(move(zn));
Zone<pointZone, meshPointZones>::operator=(move(zn));
}

View File

@ -42,7 +42,7 @@ SourceFiles
#ifndef pointZone_H
#define pointZone_H
#include "zone.H"
#include "Zone.H"
#include "meshPointZonesFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -56,19 +56,13 @@ namespace Foam
class pointZone
:
public zone
public Zone<pointZone, meshPointZones>
{
protected:
// Protected data
//- Reference to zone list
const meshPointZones& meshZones_;
public:
typedef meshPointZones ZonesType;
// Static Data Members
//- The name associated with the zone-labels dictionary entry
@ -185,9 +179,6 @@ public:
// Member Functions
//- Return meshZones reference
const meshPointZones& meshZones() const;
//- Convenient renaming of zone::localIndex(globalIndex)
label whichPoint(const label globalIndex) const;
@ -207,7 +198,7 @@ public:
// Member Operators
using zone::operator=;
using Zone<pointZone, meshPointZones>::operator=;
//- Assignment to zone, clearing demand-driven data
void operator=(const pointZone&);