00001 #ifndef DUNE_GENERICGEOMTRY_HYBRIDMAPPING_HH
00002 #define DUNE_GENERICGEOMTRY_HYBRIDMAPPING_HH
00003
00004 #include <dune/common/smallobject.hh>
00005
00006 #include <dune/grid/genericgeometry/geometrytraits.hh>
00007
00008 namespace Dune
00009 {
00010
00011 namespace GenericGeometry
00012 {
00013
00014
00015
00016
00017 template< class Topology, class GeometryTraits >
00018 class CachedMapping;
00019
00020
00021
00022
00023
00024
00025 template< unsigned int dim, class GeometryTraits >
00026 class HybridMapping;
00027
00028 template< class Topology, class GeometryTraits >
00029 class VirtualMapping;
00030
00031
00032
00033
00034
00035
00036 template< unsigned int dim, class GeometryTraits, unsigned int codim = dim >
00037 class HybridMappingBase;
00038
00039 template< unsigned int dim, class GeometryTraits, unsigned int codim >
00040 class HybridMappingBase
00041 : public virtual HybridMappingBase< dim, GeometryTraits, codim-1 >
00042 {
00043 typedef HybridMapping< dim, GeometryTraits > Mapping;
00044
00045 protected:
00046 using HybridMappingBase< dim, GeometryTraits, codim-1 > :: trace;
00047
00048 virtual HybridMapping< dim - codim, GeometryTraits > *
00049 trace ( Int2Type< codim >, unsigned int i ) const = 0;
00050 };
00051
00052 template< unsigned int dim, class GeometryTraits >
00053 class HybridMappingBase< dim, GeometryTraits, 0 >
00054 {
00055 typedef HybridMapping< dim, GeometryTraits > Mapping;
00056
00057 protected:
00058 virtual HybridMapping< dim, GeometryTraits > *
00059 trace ( Int2Type< 0 >, unsigned int i ) const = 0;
00060 };
00061
00062
00063
00064
00065
00066
00067 template< unsigned int dim, class GeometryTraits >
00068 class HybridMapping
00069 : public virtual HybridMappingBase< dim, GeometryTraits >,
00070 public SmallObject
00071 {
00072 typedef HybridMapping< dim, GeometryTraits > This;
00073
00074 protected:
00075 typedef MappingTraits
00076 < typename GeometryTraits :: CoordTraits, dim, GeometryTraits :: dimWorld >
00077 Traits;
00078
00079 public:
00080 static const unsigned int dimension = Traits :: dimension;
00081 static const unsigned int dimWorld = Traits :: dimWorld;
00082
00083 typedef typename Traits :: FieldType FieldType;
00084 typedef typename Traits :: LocalCoordType LocalCoordType;
00085 typedef typename Traits :: GlobalCoordType GlobalCoordType;
00086 typedef typename Traits :: JacobianType JacobianType;
00087
00088 template< int codim >
00089 struct Codim
00090 {
00091 typedef HybridMapping< dimension - codim, GeometryTraits > Trace;
00092 };
00093
00094 unsigned int referenceCount;
00095
00096 virtual ~HybridMapping ()
00097 {}
00098
00099 virtual unsigned int topologyId () const = 0;
00100
00101 virtual const GlobalCoordType &corner ( int i ) const = 0;
00102
00103 virtual int numCorners () const = 0;
00104
00105 virtual GlobalCoordType global ( const LocalCoordType &local ) const = 0;
00106
00107 virtual LocalCoordType local ( const GlobalCoordType &global ) const = 0;
00108
00109 virtual bool checkInside ( const LocalCoordType &local ) const = 0;
00110
00111 virtual bool affine () const = 0;
00112
00113 virtual FieldType integrationElement ( const LocalCoordType &local ) const = 0;
00114
00115 virtual FieldType volume () const = 0;
00116
00117 virtual const JacobianType &
00118 jacobianInverseTransposed ( const LocalCoordType &local ) const = 0;
00119
00120 virtual GlobalCoordType
00121 normal ( int face, const LocalCoordType &local ) const = 0;
00122
00123 template< int codim >
00124 typename Codim< codim > :: Trace *trace ( unsigned int i ) const
00125 {
00126 Int2Type< codim > codimVariable;
00127 return trace( codimVariable, i );
00128 }
00129
00130 protected:
00131 using HybridMappingBase< dim, GeometryTraits > :: trace;
00132 };
00133
00134
00135
00136
00137
00138
00139 template< class Topology, class GeometryTraits, unsigned int codim = Topology :: dimension >
00140 class VirtualMappingBase;
00141
00142 template< class Topology, class GeometryTraits, unsigned int codim >
00143 class VirtualMappingBase
00144 : public VirtualMappingBase< Topology, GeometryTraits, codim-1 >,
00145 public virtual HybridMappingBase< Topology :: dimension, GeometryTraits, codim >
00146 {
00147 typedef GenericGeometry :: VirtualMapping< Topology, GeometryTraits >
00148 VirtualMapping;
00149
00150 protected:
00151 using VirtualMappingBase< Topology, GeometryTraits, codim-1 > :: trace;
00152
00153 virtual HybridMapping< Topology :: dimension - codim, GeometryTraits > *
00154 trace ( Int2Type< codim >, unsigned int i ) const
00155 {
00156 const VirtualMapping &impl = static_cast< const VirtualMapping & >( *this );
00157 return impl.template trace< codim >( i );
00158 }
00159 };
00160
00161 template< class Topology, class GeometryTraits >
00162 class VirtualMappingBase< Topology, GeometryTraits, 0 >
00163 : public virtual HybridMappingBase< Topology :: dimension, GeometryTraits, 0 >
00164 {
00165 typedef GenericGeometry :: VirtualMapping< Topology, GeometryTraits >
00166 VirtualMapping;
00167
00168 protected:
00169 virtual HybridMapping< Topology :: dimension, GeometryTraits > *
00170 trace ( Int2Type< 0 >, unsigned int i ) const
00171 {
00172 const VirtualMapping &impl = static_cast< const VirtualMapping & >( *this );
00173 return impl.template trace< 0 >( i );
00174 }
00175 };
00176
00177
00178
00179 template< class Topology, class GeometryTraits >
00180 class VirtualMapping
00181 : public HybridMapping< Topology :: dimension, GeometryTraits >,
00182 public VirtualMappingBase< Topology, GeometryTraits >
00183 {
00184 typedef HybridMapping< Topology :: dimension, GeometryTraits > Base;
00185 typedef VirtualMapping< Topology, GeometryTraits > This;
00186
00187 typedef typename Base :: Traits Traits;
00188
00189 typedef CachedMapping< Topology, GeometryTraits > Mapping;
00190
00191 public:
00192 static const unsigned int dimension = Traits :: dimension;
00193 static const unsigned int dimWorld = Traits :: dimWorld;
00194
00195 typedef typename Traits :: FieldType FieldType;
00196 typedef typename Traits :: LocalCoordType LocalCoordType;
00197 typedef typename Traits :: GlobalCoordType GlobalCoordType;
00198 typedef typename Traits :: JacobianType JacobianType;
00199
00200 typedef typename Mapping :: ReferenceElement ReferenceElement;
00201
00202 template< int codim >
00203 struct Codim
00204 {
00205 typedef HybridMapping< dimension - codim, GeometryTraits > Trace;
00206 };
00207
00208 private:
00209 Mapping mapping_;
00210
00211 public:
00212 template< class CoordVector >
00213 explicit VirtualMapping ( const CoordVector &coordVector )
00214 : mapping_( coordVector )
00215 {}
00216
00217 virtual unsigned int topologyId () const
00218 {
00219 return mapping_.topologyId();
00220 }
00221
00222 virtual const GlobalCoordType &corner ( int i ) const
00223 {
00224 return mapping_.corner( i );
00225 }
00226
00227 virtual int numCorners () const
00228 {
00229 return mapping_.numCorners();
00230 }
00231
00232 virtual GlobalCoordType global ( const LocalCoordType &local ) const
00233 {
00234 return mapping_.global( local );
00235 }
00236
00237 virtual LocalCoordType local ( const GlobalCoordType &global ) const
00238 {
00239 return mapping_.local( global );
00240 }
00241
00242 virtual bool checkInside ( const LocalCoordType &local ) const
00243 {
00244 return mapping_.checkInside( local );
00245 }
00246
00247 virtual bool affine () const
00248 {
00249 return mapping_.affine();
00250 }
00251
00252 virtual FieldType integrationElement ( const LocalCoordType &local ) const
00253 {
00254 return mapping_.integrationElement( local );
00255 }
00256
00257 virtual FieldType volume () const
00258 {
00259 return mapping_.volume();
00260 }
00261
00262 virtual const JacobianType &
00263 jacobianInverseTransposed ( const LocalCoordType &local ) const
00264 {
00265 return mapping_.jacobianInverseTransposed( local );
00266 }
00267
00268 virtual GlobalCoordType normal ( int face, const LocalCoordType &local ) const
00269 {
00270 return mapping_.normal( face , local );
00271 }
00272
00273 template< int codim >
00274 typename Codim< codim > :: Trace *trace ( unsigned int i ) const
00275 {
00276 return mapping_.template trace< codim, true >( i );
00277 }
00278
00279 protected:
00280 using VirtualMappingBase< Topology, GeometryTraits > :: trace;
00281 };
00282
00283 }
00284
00285 }
00286
00287 #endif