3#ifndef DUNE_GEOMETRY_GENERICGEOMETRY_HYBRIDMAPPING_HH
4#define DUNE_GEOMETRY_GENERICGEOMETRY_HYBRIDMAPPING_HH
10#include <dune/geometry/genericgeometry/cachedmapping.hh>
11#include <dune/geometry/genericgeometry/geometrytraits.hh>
12#include <dune/geometry/genericgeometry/traceprovider.hh>
17 namespace GenericGeometry
23 template<
unsigned int dim,
class GeometryTraits >
26 template<
class Topology,
class GeometryTraits >
35 template<
unsigned int dim,
class GeometryTraits,
unsigned int codim = dim >
36 class HybridMappingBase;
38 template<
unsigned int dim,
class GeometryTraits,
unsigned int codim >
39 class HybridMappingBase
40 :
public virtual HybridMappingBase< dim, GeometryTraits, codim-1 >
42 typedef HybridMapping< dim, GeometryTraits > Mapping;
45 virtual ~HybridMappingBase() {}
48 using HybridMappingBase< dim, GeometryTraits, codim-1 >::trace;
50 virtual HybridMapping< dim - codim, GeometryTraits > *
51 trace ( integral_constant< int, codim >,
unsigned int i,
char *mappingStorage )
const = 0;
54 template<
unsigned int dim,
class GeometryTraits >
55 class HybridMappingBase< dim, GeometryTraits, 0 >
57 typedef HybridMapping< dim, GeometryTraits > Mapping;
60 virtual ~HybridMappingBase() {}
63 virtual HybridMapping< dim, GeometryTraits > *
64 trace ( integral_constant< int, 0 >,
unsigned int i,
char *mappingStorage )
const = 0;
80 template<
unsigned int dim,
class GeometryTraits >
83 :
public virtual HybridMappingBase< dim, GeometryTraits >
92 static const unsigned int dimension = Traits::dimension;
93 static const unsigned int dimWorld = Traits::dimWorld;
95 typedef typename Traits::FieldType FieldType;
96 typedef typename Traits::LocalCoordinate LocalCoordinate;
97 typedef typename Traits::GlobalCoordinate GlobalCoordinate;
99 typedef CachedJacobianTransposed< dimension, GeometryTraits > JacobianTransposed;
100 typedef CachedJacobianInverseTransposed< dimension, GeometryTraits > JacobianInverseTransposed;
102 template<
int codim >
105 typedef HybridMapping< dimension - codim, GeometryTraits > Trace;
108 typedef typename GeometryTraits::Caching Caching;
109 typedef typename GeometryTraits::UserData UserData;
122 virtual GlobalCoordinate
corner (
int i )
const = 0;
124 virtual GlobalCoordinate
center ()
const = 0;
132 virtual GlobalCoordinate
global (
const LocalCoordinate &x )
const = 0;
144 virtual LocalCoordinate local (
const GlobalCoordinate &y )
const = 0;
199 using HybridMappingBase< dim, GeometryTraits >::trace;
202 virtual This *clone ()
const = 0;
203 virtual This *clone (
char *mappingStorage )
const = 0;
205 template<
int codim >
209 return trace( codimVariable, i, mappingStorage );
212 const UserData &userData ()
const {
return userData_; }
213 UserData &userData () {
return userData_; }
225 template<
class Topology,
class GeometryTraits,
unsigned int codim = Topology::dimension >
226 class VirtualMappingBase;
228 template<
class Topology,
class GeometryTraits,
unsigned int codim >
229 class VirtualMappingBase
230 :
public VirtualMappingBase< Topology, GeometryTraits, codim-1 >,
231 public virtual HybridMappingBase< Topology::dimension, GeometryTraits, codim >
233 typedef GenericGeometry::VirtualMapping< Topology, GeometryTraits >
237 using VirtualMappingBase< Topology, GeometryTraits, codim-1 >::trace;
239 virtual HybridMapping< Topology::dimension - codim, GeometryTraits > *
240 trace ( integral_constant< int, codim >,
unsigned int i,
char *mappingStorage )
const
242 return static_cast< const VirtualMapping &
>( *this ).template trace< codim >( i, mappingStorage );
246 template<
class Topology,
class GeometryTraits >
247 class VirtualMappingBase< Topology, GeometryTraits, 0 >
248 :
public virtual HybridMappingBase< Topology::dimension, GeometryTraits, 0 >
250 typedef GenericGeometry::VirtualMapping< Topology, GeometryTraits >
255 trace ( integral_constant< int, 0 >,
unsigned int i,
char *mappingStorage )
const
257 return static_cast< const VirtualMapping &
>( *this ).template trace< 0 >( i, mappingStorage );
264 template<
class Topology,
class GeometryTraits >
266 :
public HybridMapping< Topology::dimension, GeometryTraits >,
268 public VirtualMappingBase< Topology, GeometryTraits >
272 typedef VirtualMapping< Topology, GeometryTraits > This;
274 typedef typename Base::Traits Traits;
276 typedef CachedMapping< Topology, GeometryTraits > Mapping;
279 static const unsigned int dimension = Traits::dimension;
280 static const unsigned int dimWorld = Traits::dimWorld;
282 typedef typename Traits::FieldType FieldType;
283 typedef typename Traits::LocalCoordinate LocalCoordinate;
284 typedef typename Traits::GlobalCoordinate GlobalCoordinate;
286 typedef typename Base::JacobianTransposed JacobianTransposed;
287 typedef typename Base::JacobianInverseTransposed JacobianInverseTransposed;
289 typedef typename Mapping::ReferenceElement ReferenceElement;
291 template<
unsigned int codim >
294 typedef typename TraceProvider< Topology, GeometryTraits, codim, true >::Trace Trace;
297 typedef typename GeometryTraits::Caching Caching;
299 template<
class CoordVector >
300 explicit VirtualMapping (
const CoordVector &coordVector )
301 : mapping_( coordVector )
304 virtual bool affine ()
const {
return mapping_.affine(); }
307 virtual int numCorners ()
const {
return mapping_.numCorners(); }
308 virtual GlobalCoordinate corner (
int i )
const {
return mapping_.corner( i ); }
309 virtual GlobalCoordinate center ()
const {
return mapping_.center(); }
311 virtual GlobalCoordinate global (
const LocalCoordinate &local )
const {
return mapping_.global( local ); }
312 virtual LocalCoordinate local (
const GlobalCoordinate &global )
const {
return mapping_.local( global ); }
314 virtual bool checkInside (
const LocalCoordinate &local )
const {
return mapping_.checkInside( local ); }
316 virtual FieldType integrationElement (
const LocalCoordinate &local )
const {
return mapping_.integrationElement( local ); }
317 virtual FieldType volume ()
const {
return mapping_.volume(); }
319 virtual const JacobianTransposed &jacobianTransposed (
const LocalCoordinate &local )
const {
return mapping_.jacobianTransposed( local ); }
320 virtual const JacobianInverseTransposed &jacobianInverseTransposed (
const LocalCoordinate &local )
const {
return mapping_.jacobianInverseTransposed( local ); }
322 virtual Base *clone ()
const {
return new This( *
this ); }
323 virtual Base* clone (
char *mappingStorage )
const {
return new( mappingStorage ) This( *
this ); }
325 template<
int codim >
326 typename Codim< codim >::Trace *trace (
unsigned int i,
char *mappingStorage )
const
328 return TraceProvider< Topology, GeometryTraits, codim, true >::construct( mapping_.mapping(), i, mappingStorage );
332 using VirtualMappingBase< Topology, GeometryTraits >::trace;
350 template<
class Topology,
class GeometryTraits >
358 typedef CachedMapping< Topology, GeometryTraits > Mapping;
361 static const unsigned int dimension = Traits::dimension;
362 static const unsigned int dimWorld = Traits::dimWorld;
364 typedef typename Traits::FieldType FieldType;
365 typedef typename Traits::LocalCoordinate LocalCoordinate;
366 typedef typename Traits::GlobalCoordinate GlobalCoordinate;
368 typedef CachedJacobianTransposed< dimension, GeometryTraits > JacobianTransposed;
369 typedef CachedJacobianInverseTransposed< dimension, GeometryTraits > JacobianInverseTransposed;
371 typedef typename Mapping::ReferenceElement ReferenceElement;
373 template<
unsigned int codim >
376 typedef typename TraceProvider< Topology, GeometryTraits, codim, false >::Trace Trace;
379 typedef typename GeometryTraits::Caching Caching;
380 typedef typename GeometryTraits::UserData UserData;
382 template<
class CoordVector >
384 : mapping_( coordVector )
388 bool affine ()
const {
return mapping_.affine(); }
395 GlobalCoordinate
corner (
int i )
const {
return mapping_.corner( i ); }
397 GlobalCoordinate
center ()
const {
return mapping_.center(); }
405 GlobalCoordinate
global (
const LocalCoordinate &local )
const {
return mapping_.global( local ); }
417 LocalCoordinate local (
const GlobalCoordinate &
global )
const {
return mapping_.local(
global ); }
426 bool checkInside (
const LocalCoordinate &local )
const {
return mapping_.checkInside( local ); }
442 FieldType
integrationElement (
const LocalCoordinate &local )
const {
return mapping_.integrationElement( local ); }
451 FieldType
volume ()
const {
return mapping_.volume(); }
462 const JacobianTransposed &
jacobianTransposed (
const LocalCoordinate &local )
const {
return mapping_.jacobianTransposed( local ); }
469 const JacobianInverseTransposed &
jacobianInverseTransposed (
const LocalCoordinate &local )
const {
return mapping_.jacobianInverseTransposed( local ); }
471 This *clone ()
const {
return new This( *
this ); }
472 This *clone (
char *mappingStorage )
const {
return new( mappingStorage ) This( *
this ); }
474 template<
int codim >
475 typename Codim< codim >::Trace *trace (
unsigned int i,
char *mappingStorage )
const
477 return TraceProvider< Topology, GeometryTraits, codim, false >::construct( mapping_.mapping(), i, mappingStorage );
480 const UserData &userData ()
const {
return userData_; }
481 UserData &userData () {
return userData_; }
abstract base class for generic mapping
Definition: hybridmapping.hh:85
virtual const JacobianInverseTransposed & jacobianInverseTransposed(const LocalCoordinate &x) const =0
obtain the transposed of the Jacobian's inverse
virtual bool checkInside(const LocalCoordinate &x) const =0
check whether a point lies within the reference element
virtual FieldType volume() const =0
obtain the volume of the mapping's image
virtual GlobalCoordinate center() const =0
obtain the centroid of the mapping's image
virtual GlobalCoordinate corner(int i) const =0
obtain coordinates of the i-th corner
virtual int numCorners() const =0
obtain number of corners of the corresponding reference element
virtual GlobalCoordinate global(const LocalCoordinate &x) const =0
evaluate the mapping
virtual bool affine() const =0
is this mapping affine?
virtual FieldType integrationElement(const LocalCoordinate &x) const =0
obtain the integration element
virtual Dune::GeometryType type() const =0
obtain the name of the reference element
virtual const JacobianTransposed & jacobianTransposed(const LocalCoordinate &x) const =0
obtain the transposed of the Jacobian
non-virtual geometric mapping
Definition: hybridmapping.hh:352
bool checkInside(const LocalCoordinate &local) const
check whether a point lies within the reference element
Definition: hybridmapping.hh:426
const JacobianTransposed & jacobianTransposed(const LocalCoordinate &local) const
obtain the transposed of the Jacobian
Definition: hybridmapping.hh:462
FieldType volume() const
obtain the volume of the mapping's image
Definition: hybridmapping.hh:451
const JacobianInverseTransposed & jacobianInverseTransposed(const LocalCoordinate &local) const
obtain the transposed of the Jacobian's inverse
Definition: hybridmapping.hh:469
FieldType integrationElement(const LocalCoordinate &local) const
obtain the integration element
Definition: hybridmapping.hh:442
GlobalCoordinate center() const
obtain the centroid of the mapping's image
Definition: hybridmapping.hh:397
GlobalCoordinate corner(int i) const
obtain coordinates of the i-th corner
Definition: hybridmapping.hh:395
Dune::GeometryType type() const
obtain the name of the reference element
Definition: hybridmapping.hh:390
GlobalCoordinate global(const LocalCoordinate &local) const
evaluate the mapping
Definition: hybridmapping.hh:405
bool affine() const
is this mapping affine?
Definition: hybridmapping.hh:388
int numCorners() const
obtain number of corners of the corresponding reference element
Definition: hybridmapping.hh:393
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Dune namespace.
Definition: alignment.hh:14
Default mapping traits using Dune::FieldVector and Dune::FieldMatrix.
Definition: geometrytraits.hh:53
Generate a type for a given integral constant.
Definition: typetraits.hh:457
Traits for type conversions and type information.