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