![]() |
|
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 ZoneID 00027 00028 Description 00029 A class holds the data needed to identify a zone in a dynamic 00030 mesh. The zone is identified by name and its index in the 00031 zone mesh is updated if the mesh has changed. 00032 00033 00034 \*---------------------------------------------------------------------------*/ 00035 00036 #ifndef ZoneID_H 00037 #define ZoneID_H 00038 00039 #include "label.H" 00040 #include "word.H" 00041 #include "polyMesh.H" 00042 00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00044 00045 namespace Foam 00046 { 00047 00048 template<class ZoneType> class ZoneMesh; 00049 00050 // * * * * * * Forward declaration of template friend fuctions * * * * * * * // 00051 00052 template<class ZoneType> class ZoneID; 00053 00054 template<class ZoneType> 00055 Ostream& operator<<(Ostream&, const ZoneID<ZoneType>&); 00056 00057 /*---------------------------------------------------------------------------*\ 00058 Class ZoneID Declaration 00059 \*---------------------------------------------------------------------------*/ 00060 00061 template<class ZoneType> 00062 class ZoneID 00063 { 00064 // Private data 00065 00066 //- Zone name 00067 word name_; 00068 00069 //- Zone index 00070 label index_; 00071 00072 00073 public: 00074 00075 // Constructors 00076 00077 //- Construct from name 00078 ZoneID(const word& name, const ZoneMesh<ZoneType>& zm) 00079 : 00080 name_(name), 00081 index_(zm.findZoneID(name)) 00082 {} 00083 00084 //- Construct from Istream 00085 ZoneID(Istream& is, const ZoneMesh<ZoneType>& zm) 00086 : 00087 name_(is), 00088 index_(zm.findZoneID(name_)) 00089 {} 00090 00091 00092 // Destructor - default 00093 00094 00095 // Member Functions 00096 00097 // Access 00098 00099 //- Return name 00100 const word& name() const 00101 { 00102 return name_; 00103 } 00104 00105 //- Return index 00106 label index() const 00107 { 00108 return index_; 00109 } 00110 00111 //- Has the zone been found 00112 bool active() const 00113 { 00114 return index_ > -1; 00115 } 00116 00117 // Edit 00118 00119 //- Update 00120 void update(const ZoneMesh<ZoneType>& zm) 00121 { 00122 index_ = zm.findZoneID(name_); 00123 } 00124 00125 00126 // IOstream Operators 00127 00128 friend Ostream& operator<< <ZoneType> 00129 ( 00130 Ostream& os, const ZoneID<ZoneType>& p 00131 ); 00132 }; 00133 00134 00135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00136 00137 template<class ZoneType> 00138 Ostream& operator<< 00139 ( 00140 Ostream& os, const ZoneID<ZoneType>& p 00141 ) 00142 { 00143 os << token::BEGIN_LIST 00144 << p.name_ << token::SPACE 00145 << p.index_ 00146 << token::END_LIST; 00147 00148 // Check state of Ostream 00149 os.check("Ostream& operator<<(Ostream&, const ZoneID<ZoneType>&)"); 00150 00151 return os; 00152 } 00153 00154 00155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00156 00157 } // End namespace Foam 00158 00159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00160 00161 #endif 00162 00163 // ************************************************************************* //