FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

polyPatchID.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::polyPatchID
00026 
00027 Description
00028     A class holds the data needed to identify a patch in a dynamic mesh.
00029 
00030     The patch is identified by name and its index in the boundary mesh
00031     is updated if the mesh has changed.
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef polyPatchID_H
00036 #define polyPatchID_H
00037 
00038 #include <OpenFOAM/polyBoundaryMesh.H>
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 namespace Foam
00043 {
00044 
00045 // Forward declaration of friend functions and operators
00046 
00047 class polyPatchID;
00048 Ostream& operator<<(Ostream& os, const polyPatchID& p);
00049 
00050 
00051 /*---------------------------------------------------------------------------*\
00052                            Class polyPatchID Declaration
00053 \*---------------------------------------------------------------------------*/
00054 
00055 class polyPatchID
00056 {
00057     // Private data
00058 
00059         //- Patch name
00060         word name_;
00061 
00062         //- Patch index
00063         label index_;
00064 
00065 
00066 public:
00067 
00068     // Constructors
00069 
00070         //- Construct from name
00071         polyPatchID(const word& name, const polyBoundaryMesh& bm)
00072         :
00073             name_(name),
00074             index_(bm.findPatchID(name))
00075         {}
00076 
00077         //- Construct from Istream
00078         polyPatchID(Istream& is, const polyBoundaryMesh& bm)
00079         :
00080             name_(is),
00081             index_(bm.findPatchID(name_))
00082         {}
00083 
00084 
00085     // Member Functions
00086 
00087         // Access
00088 
00089             //- Return name
00090             const word& name() const
00091             {
00092                 return name_;
00093             }
00094 
00095             //- Return index
00096             label index() const
00097             {
00098                 return index_;
00099             }
00100 
00101             //- Has the patch been found
00102             bool active() const
00103             {
00104                 return index_ > -1;
00105             }
00106 
00107 
00108         // Edit
00109 
00110             //- Update
00111             void update(const polyBoundaryMesh& bm)
00112             {
00113                 index_ = bm.findPatchID(name_);
00114             }
00115 
00116 
00117     // Ostream Operator
00118 
00119         friend Ostream& operator<<(Ostream& os, const polyPatchID& p)
00120         {
00121             os  << token::BEGIN_LIST
00122                 << p.name_ << token::SPACE
00123                 << p.index_
00124                 << token::END_LIST;
00125 
00126             // Check state of Ostream
00127             os.check("Ostream& operator<<(Ostream&, const polyPatchID&)");
00128 
00129             return os;
00130         }
00131 };
00132 
00133 
00134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00135 
00136 } // End namespace Foam
00137 
00138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00139 
00140 #endif
00141 
00142 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines