OpenFOAM logo
Open Source CFD Toolkit

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-2005 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     polyPatchID
00027 
00028 Description
00029     A class holds the data needed to identify a patch in a dynamic
00030     mesh.  The patch is identified by name and its index in the
00031     boundary mesh is updated if the mesh has changed.
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef polyPatchID_H
00036 #define polyPatchID_H
00037 
00038 #include "polyBoundaryMesh.H"
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 namespace Foam
00043 {
00044 
00045 /*---------------------------------------------------------------------------*\
00046                            Class polyPatchID Declaration
00047 \*---------------------------------------------------------------------------*/
00048 
00049 class polyPatchID
00050 {
00051     // Private data
00052 
00053         //- Patch name
00054         word name_;
00055 
00056         //- Patch index
00057         label index_;
00058 
00059 
00060 public:
00061 
00062     // Constructors
00063 
00064         //- Construct from name
00065         polyPatchID(const word& name, const polyBoundaryMesh& bm)
00066         :
00067             name_(name),
00068             index_(bm.findPatchID(name))
00069         {}
00070 
00071         //- Construct from Istream
00072         polyPatchID(Istream& is, const polyBoundaryMesh& bm)
00073         :
00074             name_(is),
00075             index_(bm.findPatchID(name_))
00076         {}
00077 
00078 
00079     // Member Functions
00080 
00081         // Access
00082 
00083             //- Return name
00084             const word& name() const
00085             {
00086                 return name_;
00087             }
00088 
00089             //- Return index
00090             label index() const
00091             {
00092                 return index_;
00093             }
00094 
00095             //- Has the patch been found
00096             bool active() const
00097             {
00098                 return index_ > -1;
00099             }
00100 
00101 
00102         // Edit
00103 
00104             //- Update
00105             void update(const polyBoundaryMesh& bm)
00106             {
00107                 index_ = bm.findPatchID(name_);
00108             }
00109             
00110 
00111     // Ostream Operator
00112 
00113         friend Ostream& operator<<(Ostream& os, const polyPatchID& p)
00114         {
00115             os  << token::BEGIN_LIST
00116                 << p.name_ << token::SPACE
00117                 << p.index_
00118                 << token::END_LIST;
00119 
00120             // Check state of Ostream
00121             os.check("Ostream& operator<<(Ostream&, const polyPatchID&)");
00122 
00123             return os;
00124         }
00125 };
00126 
00127 
00128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00129 
00130 } // End namespace Foam
00131 
00132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00133 
00134 #endif
00135 
00136 // ************************************************************************* //
For further information go to www.openfoam.org