initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / meshes / polyMesh / zones / ZoneID / polyPatchID.H
bloba2ac506684458094ffa19e5860e570e7ddf6a719
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::polyPatchID
28 Description
29     A class holds the data needed to identify a patch in a dynamic mesh.
31     The patch is identified by name and its index in the boundary mesh
32     is updated if the mesh has changed.
34 \*---------------------------------------------------------------------------*/
36 #ifndef polyPatchID_H
37 #define polyPatchID_H
39 #include "polyBoundaryMesh.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of friend functions and operators
48 class polyPatchID;
49 Ostream& operator<<(Ostream& os, const polyPatchID& p);
52 /*---------------------------------------------------------------------------*\
53                            Class polyPatchID Declaration
54 \*---------------------------------------------------------------------------*/
56 class polyPatchID
58     // Private data
60         //- Patch name
61         word name_;
63         //- Patch index
64         label index_;
67 public:
69     // Constructors
71         //- Construct from name
72         polyPatchID(const word& name, const polyBoundaryMesh& bm)
73         :
74             name_(name),
75             index_(bm.findPatchID(name))
76         {}
78         //- Construct from Istream
79         polyPatchID(Istream& is, const polyBoundaryMesh& bm)
80         :
81             name_(is),
82             index_(bm.findPatchID(name_))
83         {}
86     // Member Functions
88         // Access
90             //- Return name
91             const word& name() const
92             {
93                 return name_;
94             }
96             //- Return index
97             label index() const
98             {
99                 return index_;
100             }
102             //- Has the patch been found
103             bool active() const
104             {
105                 return index_ > -1;
106             }
109         // Edit
111             //- Update
112             void update(const polyBoundaryMesh& bm)
113             {
114                 index_ = bm.findPatchID(name_);
115             }
118     // Ostream Operator
120         friend Ostream& operator<<(Ostream& os, const polyPatchID& p)
121         {
122             os  << token::BEGIN_LIST
123                 << p.name_ << token::SPACE
124                 << p.index_
125                 << token::END_LIST;
127             // Check state of Ostream
128             os.check("Ostream& operator<<(Ostream&, const polyPatchID&)");
130             return os;
131         }
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 } // End namespace Foam
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 #endif
143 // ************************************************************************* //