1#ifndef DUNE_FEM_SPACE_LAGRANGE_GENERICGEOMETRY_HH 
    2#define DUNE_FEM_SPACE_LAGRANGE_GENERICGEOMETRY_HH 
   13#include <dune/fem/misc/metaprogramming.hh> 
   68      template< 
unsigned int codim >
 
   71        static_assert( (codim <= 
dimension), 
"Codimension must be less or equal to dimension." );
 
   80        return ((codim == 0) ? 1 : 0);
 
   90    template< 
class BaseGeometry >
 
   98      static const unsigned int dimension = BaseGeometryType::dimension + 1;
 
  100      template< 
unsigned int codim >
 
  103        static_assert( (codim <= 
dimension), 
"Codimension must be less or equal to dimension." );
 
  107          = MetaIf< (codim > 0),
 
  108                    MetaPlus< MetaInt< Protect< BaseGeometryType::template Codim, codim-1, PointGeometry::template 
Codim< 0 >, 0 >
::numSubEntities >,
 
  110                    MetaInt< 1 > >::value;
 
  118          const unsigned int sameCodimCount = BaseGeometryType::numSubEntities( codim-1 );
 
  120            return sameCodimCount + BaseGeometryType::numSubEntities( codim );
 
  122            return (codim == 
dimension ? sameCodimCount+1 : 0);
 
  135    template< 
class FirstGeometry, 
class SecondGeometry >
 
  145      static const unsigned int dimension = FirstGeometryType::dimension + SecondGeometryType::dimension;
 
  147      template< 
unsigned int codim >
 
  150        static_assert( (codim <= 
dimension), 
"Codimension must be less or equal to dimension." );
 
  152        template< 
unsigned int i >
 
  153        struct NumSubEntities
 
  154        : 
public MetaInt< FirstGeometryType::template Codim< codim-i >::numSubEntities * SecondGeometryType::template Codim< i >::numSubEntities >
 
  158        static const unsigned int numSubEntities = Loop< MetaPlus, NumSubEntities, codim >::value;
 
  164        unsigned int cnt = 0;
 
  165        for( 
unsigned int i = 0; i <= codim; ++i )
 
  166          cnt += FirstGeometryType::numSubEntities( codim - i ) * SecondGeometryType::numSubEntities( i );
 
  173    template< 
unsigned int id, 
unsigned int dim >
 
  174    class GeometryWrapper
 
  176      static_assert( (
id < (1 << dim)), 
"id too large." );
 
  178      static const bool isPrism = ((
id >> (dim-1)) != 0);
 
  180      typedef GeometryWrapper< (
id & ~(1 << (dim-1))), dim-1 > DimensionReductionType;
 
  185        typedef GeometryWrapper< (
id & 1), 1 > LineGeometryType;
 
  186        typedef ProductGeometry< typename DimensionReductionType::ImplType, typename LineGeometryType::ImplType >
 
  193        typedef PyramidGeometry< typename DimensionReductionType::ImplType >
 
  198      static const unsigned int dimension = dim;
 
  200      typedef typename std::conditional< isPrism, Prism< true >, Pyramid< false > >::type::ImplType
 
  204    template< 
unsigned int id >
 
  205    class GeometryWrapper< id, 1 >
 
  207      static_assert( (
id < 2), 
"id too large." );
 
  210      static const unsigned int dimension = 1;
 
  212      typedef PyramidGeometry< PointGeometry > ImplType;
 
  215    template< 
unsigned int id >
 
  216    class GeometryWrapper< id, 0 >
 
  218      static_assert( (
id < 1), 
"id too large." );
 
  221      static const unsigned int dimension = 0;
 
  223      typedef PointGeometry ImplType;
 
  231    template< 
class Geometry, 
class Field, 
unsigned int offset = 0 >
 
  232    class LocalCoordinate;
 
  236    template< 
class Field, 
unsigned int offset >
 
  237    class LocalCoordinate< PointGeometry, Field, offset >
 
  239      typedef LocalCoordinate< PointGeometry, Field, offset > ThisType;
 
  244      static const unsigned int dimension = GeometryType::dimension;
 
  246      typedef Field FieldType;
 
  248      inline LocalCoordinate ()
 
  252      explicit LocalCoordinate ( 
const FieldVector< FieldType, sz > &x )
 
  254        static_assert( (sz >= offset + dimension), 
"Invalid vector size" );
 
  257      ThisType &operator= ( 
const FieldType s )
 
  263      ThisType &operator= ( 
const FieldVector< FieldType, sz > &x )
 
  265        static_assert( (sz >= offset + dimension), 
"Invalid vector size" );
 
  269      ThisType &operator= ( 
const ThisType &v )
 
  274      ThisType &operator*= ( 
const FieldType s )
 
  279      ThisType &operator+= ( 
const ThisType &v )
 
  284      ThisType &operator-= ( 
const ThisType &v )
 
  289      const FieldType &operator[] ( 
const unsigned int i )
 const 
  291        DUNE_THROW( RangeError, 
"LocalCoordinate: No such index." );
 
  294      FieldType &operator[] ( 
const unsigned int i )
 
  296        DUNE_THROW( RangeError, 
"LocalCoordinate: No such index." );
 
  302    template< 
class BaseGeometry, 
class Field, 
unsigned int offset >
 
  303    class LocalCoordinate< PyramidGeometry< BaseGeometry >, Field, offset >
 
  305      typedef LocalCoordinate< PyramidGeometry< BaseGeometry >, Field, offset > ThisType;
 
  308      typedef BaseGeometry BaseGeometryType;
 
  310      typedef PyramidGeometry< BaseGeometryType > 
GeometryType;
 
  312      static const unsigned int dimension = GeometryType::dimension;
 
  314      typedef Field FieldType;
 
  316      typedef LocalCoordinate< BaseGeometry, FieldType, offset > BaseCoordinateType;
 
  318      static const unsigned int index = offset + BaseGeometryType::dimension;
 
  323      LocalCoordinate (
const LocalCoordinate& ) = 
default;
 
  326      explicit LocalCoordinate ( 
const FieldVector< FieldType, sz > &x )
 
  327      : myCoordinate_( x[ index ] ),
 
  330        static_assert( (sz >= offset + dimension), 
"Invalid vector size" );
 
  333      ThisType &operator= ( 
const FieldType s )
 
  341      ThisType &operator= ( 
const FieldVector< FieldType, sz > &x )
 
  343        static_assert( (sz >= offset + dimension), 
"Invalid vector size" );
 
  345        myCoordinate_ = x[ index ];
 
  350      ThisType &operator= ( 
const ThisType &v )
 
  352        myCoordinate_ = v.myCoordinate_;
 
  353        baseCoordinate_ = v.baseCoordinate_;
 
  357      ThisType &operator*= ( 
const FieldType s )
 
  360        baseCoordinate_ *= s;
 
  364      ThisType &operator+= ( 
const ThisType &v )
 
  366        myCoordinate_ += v.myCoordinate_;
 
  367        baseCoordinate_ += v.baseCoordinate_;
 
  371      ThisType &operator-= ( 
const ThisType &v )
 
  373        myCoordinate_ -= v.myCoordinate_;
 
  374        baseCoordinate_ -= v.baseCoordinate_;
 
  378      const FieldType &operator[] ( 
const unsigned int i )
 const 
  381          return myCoordinate_;
 
  383          return baseCoordinate_[ i ];
 
  386      FieldType &operator[] ( 
const unsigned int i )
 
  389          return myCoordinate_;
 
  391          return baseCoordinate_[ i ];
 
  394      const FieldType &operator* ()
 const 
  396        return myCoordinate_;
 
  399      FieldType &operator* ()
 
  401        return myCoordinate_;
 
  404      const BaseCoordinateType &base ()
 const 
  406        return baseCoordinate_;
 
  409      BaseCoordinateType &base ()
 
  411        return baseCoordinate_;
 
  415      FieldType myCoordinate_;
 
  416      BaseCoordinateType baseCoordinate_;
 
  421    template< 
class FirstGeometry, 
class SecondGeometry, 
class Field, 
unsigned int offset >
 
  422    class LocalCoordinate< ProductGeometry< FirstGeometry, SecondGeometry >, Field, offset >
 
  424      typedef LocalCoordinate< ProductGeometry< FirstGeometry, SecondGeometry >, Field, offset > ThisType;
 
  427      typedef FirstGeometry FirstGeometryType;
 
  428      typedef SecondGeometry SecondGeometryType;
 
  429      typedef ProductGeometry< FirstGeometryType, SecondGeometryType > 
GeometryType;
 
  431      static const unsigned int dimension = GeometryType::dimension;
 
  433      typedef Field FieldType;
 
  436      static const unsigned int firstOffset = offset;
 
  437      static const unsigned int secondOffset = offset + FirstGeometryType::dimension;
 
  440      typedef LocalCoordinate< FirstGeometryType, FieldType, firstOffset > FirstCoordinateType;
 
  441      typedef LocalCoordinate< SecondGeometryType, FieldType, secondOffset > SecondCoordinateType;
 
  446      LocalCoordinate( 
const LocalCoordinate& ) = 
default;
 
  449      explicit LocalCoordinate ( 
const FieldVector< FieldType, sz > &x )
 
  450      : firstCoordinate_( x ),
 
  451        secondCoordinate_( x )
 
  453        static_assert( (sz >= offset + dimension), 
"Invalid vector size" );
 
  456      ThisType &operator= ( 
const FieldType s )
 
  458        firstCoordinate_ = s;
 
  459        secondCoordinate_ = s;
 
  464      ThisType &operator= ( 
const FieldVector< FieldType, sz > &x )
 
  466        static_assert( (sz >= offset + dimension), 
"Invalid vector size" );
 
  468        firstCoordinate_ = x;
 
  469        secondCoordinate_ = x;
 
  473      ThisType &operator= ( 
const ThisType &v )
 
  475        firstCoordinate_ = v;
 
  476        secondCoordinate_ = v;
 
  480      ThisType &operator*= ( 
const FieldType s )
 
  482        firstCoordinate_ *= s;
 
  483        secondCoordinate_ *= s;
 
  487      ThisType &operator+= ( 
const ThisType &v )
 
  489        firstCoordinate_ += v;
 
  490        secondCoordinate_ += v;
 
  494      ThisType &operator-= ( 
const ThisType &v )
 
  496        firstCoordinate_ -= v;
 
  497        secondCoordinate_ -= v;
 
  501      const FieldType &operator[] ( 
const unsigned int i )
 const 
  503        if( i < secondOffset )
 
  504          return firstCoordinate_[ i ];
 
  506          return secondCoordinate_[ i ];
 
  509      FieldType &operator[] ( 
const unsigned int i )
 
  511        if( i < secondOffset )
 
  512          return firstCoordinate_[ i ];
 
  514          return secondCoordinate_[ i ];
 
  517      const FirstCoordinateType &first ()
 const 
  519        return firstCoordinate_;
 
  522      FirstCoordinateType &first ()
 
  524        return firstCoordinate_;
 
  527      const SecondCoordinateType &second ()
 const 
  529        return secondCoordinate_;
 
  532      SecondCoordinateType &second ()
 
  534        return secondCoordinate_;
 
  538      FirstCoordinateType firstCoordinate_;
 
  539      SecondCoordinateType secondCoordinate_;
 
generic geometry modelling a single point
Definition: genericgeometry.hh:63
 
static unsigned int numSubEntities(unsigned int codim)
number of subentites of a given codimension
Definition: genericgeometry.hh:78
 
static const unsigned int dimension
dimension of the geometry object
Definition: genericgeometry.hh:66
 
generic geometry modelling the product of two base geometries
Definition: genericgeometry.hh:137
 
static const unsigned int dimension
dimension of the geometry object
Definition: genericgeometry.hh:145
 
SecondGeometry SecondGeometryType
type of the second base geometry
Definition: genericgeometry.hh:142
 
static unsigned int numSubEntities(unsigned int codim)
number of subentites of a given codimension
Definition: genericgeometry.hh:162
 
FirstGeometry FirstGeometryType
type of the first base geometry
Definition: genericgeometry.hh:140
 
generic geometry modelling a pyramid over a base geometry
Definition: genericgeometry.hh:92
 
static unsigned int numSubEntities(unsigned int codim)
number of subentites of a given codimension
Definition: genericgeometry.hh:114
 
BaseGeometry BaseGeometryType
type of base geometry
Definition: genericgeometry.hh:95
 
static const unsigned int dimension
dimension of the geometry object
Definition: genericgeometry.hh:98
 
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
 
Implements a vector constructed from a given type representing a field and a compile-time given size.
 
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
 
Dune namespace.
Definition: alignedallocator.hh:13
 
A unique label for each type of element that can occur in a grid.