- Home
- About DUNE
- Download
- Documentation
- Community
- Development
00001 #ifndef DUNE_GEOGRID_COORDFUNCTION_HH 00002 #define DUNE_GEOGRID_COORDFUNCTION_HH 00003 00004 #include <dune/common/fvector.hh> 00005 00006 namespace Dune 00007 { 00008 00009 // Internal Forward Declarations 00010 // ----------------------------- 00011 00012 template< class ct, unsigned int dimD, unsigned int dimR, class Impl > 00013 class AnalyticalCoordFunction; 00014 00015 template< class ct, unsigned int dimR, class Impl > 00016 class DiscreteCoordFunction; 00017 00018 00019 00020 // AnalyticalCoordFunctionInterface 00021 // -------------------------------- 00022 00035 template< class ct, unsigned int dimD, unsigned int dimR, class Impl > 00036 class AnalyticalCoordFunctionInterface 00037 { 00038 typedef AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > This; 00039 00040 friend class AnalyticalCoordFunction< ct, dimD, dimR, Impl >; 00041 00042 public: 00043 typedef This Interface; 00044 typedef Impl Implementation; 00045 00047 typedef ct ctype; 00048 00050 static const unsigned int dimDomain = dimD; 00052 static const unsigned int dimRange = dimR; 00053 00055 typedef FieldVector< ctype, dimDomain > DomainVector; 00057 typedef FieldVector< ctype, dimRange > RangeVector; 00058 00059 private: 00060 AnalyticalCoordFunctionInterface () 00061 {} 00062 00063 AnalyticalCoordFunctionInterface ( const This & ); 00064 This &operator= ( const This & ); 00065 00066 public: 00068 void evaluate ( const DomainVector &x, RangeVector &y ) const 00069 { 00070 return asImp().evaluate( x, y ); 00071 } 00072 00073 protected: 00074 const Implementation &asImp () const 00075 { 00076 return static_cast< const Implementation & >( *this ); 00077 } 00078 00079 Implementation &asImp () 00080 { 00081 return static_cast< Implementation & >( *this ); 00082 } 00083 }; 00084 00085 00086 00087 // AnalyticalCoordFunction 00088 // ----------------------- 00092 template< class ct, unsigned int dimD, unsigned int dimR, class Impl > 00093 class AnalyticalCoordFunction 00094 : public AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > 00095 { 00096 typedef AnalyticalCoordFunction< ct, dimD, dimR, Impl > This; 00097 typedef AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > Base; 00098 00099 public: 00100 typedef typename Base :: DomainVector DomainVector; 00101 typedef typename Base :: RangeVector RangeVector; 00102 00103 protected: 00104 AnalyticalCoordFunction () 00105 {} 00106 00107 private: 00108 AnalyticalCoordFunction ( const This & ); 00109 This &operator= ( const This & ); 00110 00111 void evaluate ( const DomainVector &x, RangeVector &y ) const; 00112 }; 00113 00114 00115 00116 // DiscreteCoordFunctionInterface 00117 // ------------------------------ 00118 00133 template< class ct, unsigned int dimR, class Impl > 00134 class DiscreteCoordFunctionInterface 00135 { 00136 typedef DiscreteCoordFunctionInterface< ct, dimR, Impl > This; 00137 00138 friend class DiscreteCoordFunction< ct, dimR, Impl >; 00139 00140 public: 00141 typedef This Interface; 00142 typedef Impl Implementation; 00143 00145 typedef ct ctype; 00146 00148 static const unsigned int dimRange = dimR; 00149 00151 typedef FieldVector< ctype, dimRange > RangeVector; 00152 00153 private: 00154 DiscreteCoordFunctionInterface () 00155 {} 00156 00157 DiscreteCoordFunctionInterface ( const This & ); 00158 00159 This &operator= ( const This & ); 00160 00161 public: 00167 template< class HostEntity > 00168 void evaluate ( const HostEntity &hostEntity, unsigned int corner, 00169 RangeVector &y ) const 00170 { 00171 asImp().evaluate( hostEntity, corner, y ); 00172 } 00173 00177 void adapt () 00178 { 00179 asImp().adapt(); 00180 } 00181 00182 protected: 00183 const Implementation &asImp () const 00184 { 00185 return static_cast< const Implementation & >( *this ); 00186 } 00187 00188 Implementation &asImp () 00189 { 00190 return static_cast< Implementation & >( *this ); 00191 } 00192 }; 00193 00194 00195 00196 // DiscreteCoordFunction 00197 // --------------------- 00198 // 00202 template< class ct, unsigned int dimR, class Impl > 00203 class DiscreteCoordFunction 00204 : public DiscreteCoordFunctionInterface< ct, dimR, Impl > 00205 { 00206 typedef DiscreteCoordFunction< ct, dimR, Impl > This; 00207 typedef DiscreteCoordFunctionInterface< ct, dimR, Impl > Base; 00208 00209 public: 00210 typedef typename Base :: RangeVector RangeVector; 00211 00212 protected: 00213 DiscreteCoordFunction () 00214 {} 00215 00216 void adapt () 00217 {} 00218 00219 private: 00220 DiscreteCoordFunction ( const This & ); 00221 This &operator= ( const This & ); 00222 00223 template< class HostEntity > 00224 void evaluate ( const HostEntity &hostEntity, unsigned int corner, 00225 RangeVector &y ) const; 00226 }; 00227 00228 00229 00230 namespace GeoGrid 00231 { 00232 00233 // isCoordFunctionInterface 00234 // ------------------------ 00235 00236 template< class CoordFunctionInterface > 00237 struct isCoordFunctionInterface 00238 { 00239 static const bool value = false; 00240 }; 00241 00242 template< class ct, unsigned int dimD, unsigned int dimR, class Impl > 00243 struct isCoordFunctionInterface 00244 < AnalyticalCoordFunctionInterface< ct, dimD, dimR, Impl > > 00245 { 00246 static const bool value = true; 00247 }; 00248 00249 template< class ct, unsigned int dimR, class Impl > 00250 struct isCoordFunctionInterface 00251 < DiscreteCoordFunctionInterface< ct, dimR, Impl > > 00252 { 00253 static const bool value = true; 00254 }; 00255 00256 00257 00258 // isDiscreteCoordFunctionInterface 00259 // -------------------------------- 00260 00261 template< class CoordFunctionInterface > 00262 struct isDiscreteCoordFunctionInterface 00263 { 00264 static const bool value = false; 00265 }; 00266 00267 template< class ct, unsigned int dimR, class Impl > 00268 struct isDiscreteCoordFunctionInterface 00269 < DiscreteCoordFunctionInterface< ct, dimR, Impl > > 00270 { 00271 static const bool value = true; 00272 }; 00273 00274 00275 00276 // AdaptCoordFunction 00277 // ------------------ 00278 00279 template< class CoordFunctionInterface > 00280 struct AdaptCoordFunction 00281 { 00282 static void adapt ( CoordFunctionInterface &coordFunction ) 00283 {} 00284 }; 00285 00286 template< class ct, unsigned int dimR, class Impl > 00287 struct AdaptCoordFunction< DiscreteCoordFunctionInterface< ct, dimR, Impl > > 00288 { 00289 typedef DiscreteCoordFunctionInterface< ct, dimR, Impl > CoordFunctionInterface; 00290 00291 static void adapt ( CoordFunctionInterface &coordFunction ) 00292 { 00293 coordFunction.adapt(); 00294 } 00295 }; 00296 00297 } 00298 00299 } 00300 00301 #endif
Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].