Skip to content
Snippets Groups Projects
Commit dc237f20 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: merge polyPatchID and ZoneID together into DynamicID

parent 2d93b5c2
Branches
Tags
No related merge requests found
...@@ -329,7 +329,7 @@ $(cellShape)/cellShapeEqual.C ...@@ -329,7 +329,7 @@ $(cellShape)/cellShapeEqual.C
$(cellShape)/cellShapeIO.C $(cellShape)/cellShapeIO.C
$(cellShape)/cellShapeIOList.C $(cellShape)/cellShapeIOList.C
meshes/patchIdentifier/patchIdentifier.C meshes/Identifiers/patch/patchIdentifier.C
polyMesh = meshes/polyMesh polyMesh = meshes/polyMesh
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -22,43 +22,40 @@ License ...@@ -22,43 +22,40 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::ZoneID Foam::DynamicID
Description Description
A class that holds the data needed to identify a zone in a dynamic mesh. A class that holds the data needed to identify things (zones, patches)
in a dynamic mesh.
The zone is identified by name. The thing is identified by name.
Its index in the zoneMesh is updated if the mesh has changed. Its indices are updated if the mesh has changed.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef ZoneID_H #ifndef DynamicID_H
#define ZoneID_H #define DynamicID_H
#include "keyType.H" #include "keyType.H"
#include "labelList.H" #include "labelList.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
template<class ZoneType, class MeshType> class ZoneMesh;
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
template<class> class DynamicID;
template<class ZoneType> class ZoneID; template<class ObjectType>
Ostream& operator<<(Ostream&, const DynamicID<ObjectType>&);
template<class ZoneType>
Ostream& operator<<(Ostream&, const ZoneID<ZoneType>&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ZoneID Declaration Class DynamicID Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class ZoneType> template<class ObjectType>
class ZoneID class DynamicID
{ {
// Private data // Private data
...@@ -74,17 +71,17 @@ public: ...@@ -74,17 +71,17 @@ public:
// Constructors // Constructors
//- Construct from name //- Construct from name
ZoneID(const keyType& key, const ZoneMesh<ZoneType, polyMesh>& zm) DynamicID(const keyType& key, const ObjectType& obj)
: :
key_(key), key_(key),
indices_(zm.findIndices(key_)) indices_(obj.findIndices(key_))
{} {}
//- Construct from Istream //- Construct from Istream
ZoneID(Istream& is, const ZoneMesh<ZoneType, polyMesh>& zm) DynamicID(Istream& is, const ObjectType& obj)
: :
key_(is), key_(is),
indices_(zm.findIndices(key_)) indices_(obj.findIndices(key_))
{} {}
...@@ -123,30 +120,30 @@ public: ...@@ -123,30 +120,30 @@ public:
// Edit // Edit
//- Update //- Update
void update(const ZoneMesh<ZoneType, polyMesh>& zm) void update(const ObjectType& obj)
{ {
indices_ = zm.findIndices(key_); indices_ = obj.findIndices(key_);
} }
// IOstream Operators // IOstream Operators
friend Ostream& operator<< <ZoneType> friend Ostream& operator<< <ObjectType>
(Ostream&, const ZoneID<ZoneType>&); (Ostream&, const DynamicID<ObjectType>&);
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class ZoneType> template<class ObjectType>
Ostream& operator<<(Ostream& os, const ZoneID<ZoneType>& p) Ostream& operator<<(Ostream& os, const DynamicID<ObjectType>& dynId)
{ {
os << token::BEGIN_LIST os << token::BEGIN_LIST
<< p.name() << token::SPACE << p.index() << dynId.name() << token::SPACE << dynId.index()
<< token::END_LIST; << token::END_LIST;
// Check state of Ostream // Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const ZoneID<ZoneType>&)"); os.check("Ostream& operator<<(Ostream&, const DynamicID<ObjectType>&)");
return os; return os;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -21,136 +21,22 @@ License ...@@ -21,136 +21,22 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::polyPatchID
Description
A class holds the data needed to identify a patch in a dynamic mesh.
The patch is identified by name and its index in the boundary mesh
is updated if the mesh has changed.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef polyPatchID_H #ifndef polyPatchID_H
#define polyPatchID_H #define polyPatchID_H
#include "keyType.H" #include "DynamicID.H"
#include "labelList.H"
#include "polyBoundaryMesh.H" #include "polyBoundaryMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
//- Foam::polyPatchID
// Forward declaration of friend functions and operators typedef DynamicID<polyBoundaryMesh> polyPatchID;
class polyPatchID;
Ostream& operator<<(Ostream&, const polyPatchID&);
/*---------------------------------------------------------------------------*\
Class polyPatchID Declaration
\*---------------------------------------------------------------------------*/
class polyPatchID
{
// Private data
//- Patch name
keyType key_;
//- Patch indices
labelList indices_;
public:
// Constructors
//- Construct from name
polyPatchID(const keyType& key, const polyBoundaryMesh& bm)
:
key_(key),
index_(bm.findIndices(key_))
{}
//- Construct from Istream
polyPatchID(Istream& is, const polyBoundaryMesh& bm)
:
key_(is),
index_(bm.findIndices(key_))
{}
// Destructor - default
// Member Functions
// Access
//- Return name
const keyType& name() const
{
return key_;
}
//- Return indices of matching patches
const labelList& indices() const
{
return indices_;
}
//- Return index of first matching patch
label index() const
{
return indices_.empty() ? -1 : indices_[0];
}
//- Has the patch been found
bool active() const
{
return !indices_.empty();
}
// Edit
//- Update
void update(const polyBoundaryMesh& bm)
{
indices_ = bm.findIndices(key_);
}
// Ostream Operator
friend Ostream& operator<<(Ostream&, const polyPatchID&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Ostream& operator<<(Ostream& os, const polyPatchID& p)
{
os << token::BEGIN_LIST
<< p.name() << token::SPACE << p.index()
<< token::END_LIST;
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const polyPatchID&)");
return os;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -26,21 +26,26 @@ License ...@@ -26,21 +26,26 @@ License
#ifndef ZoneIDs_H #ifndef ZoneIDs_H
#define ZoneIDs_H #define ZoneIDs_H
#include "ZoneID.H" #include "DynamicID.H"
#include "pointZone.H"
#include "faceZone.H" #include "cellZoneMeshFwd.H"
#include "cellZone.H" #include "faceZoneMeshFwd.H"
#include "pointZoneMeshFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
//- Foam::pointZoneID
typedef ZoneID<pointZone> pointZoneID;
//- Foam::faceZoneID
typedef ZoneID<faceZone> faceZoneID;
//- Foam::cellZoneID //- Foam::cellZoneID
typedef ZoneID<cellZone> cellZoneID; typedef DynamicID<cellZoneMesh> cellZoneID;
//- Foam::faceZoneID
typedef DynamicID<faceZoneMesh> faceZoneID;
//- Foam::pointZoneID
typedef DynamicID<pointZoneMesh> pointZoneID;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment