dune-fem  2.8-git
dofmappercode.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_SPACE_LAGRANGE_DOFMAPPER_HH
2 #define DUNE_FEM_SPACE_LAGRANGE_DOFMAPPER_HH
3 
4 // dune-geometry includes
5 #include <dune/geometry/referenceelements.hh>
6 #include <dune/geometry/type.hh>
7 #include <dune/geometry/typeindex.hh>
8 
9 // dune-fem includes
12 
13 
14 namespace Dune
15 {
16 
17  namespace Fem
18  {
19 
20  // LagrangeDofMapperCodeFactory
21  // ----------------------------
22 
23  template< class LagrangePointSetContainer >
25  {
26  explicit LagrangeDofMapperCodeFactory ( const LagrangePointSetContainer &lagrangePointSets )
27  : lagrangePointSets_( lagrangePointSets )
28  {}
29 
30  template< class RefElement,
31  std::enable_if_t< std::is_same< std::decay_t< decltype( std::declval< const RefElement & >().size( 0 ) ) >, int >::value, int > = 0,
32  std::enable_if_t< std::is_same< std::decay_t< decltype( std::declval< const RefElement & >().type( 0, 0 ) ) >, GeometryType >::value, int > = 0 >
33  DofMapperCode operator() ( const RefElement &refElement ) const
34  {
35  const GeometryType type = refElement.type();
36  if( lagrangePointSets_.exists( type ) )
37  return compile( refElement, lagrangePointSets_[ type ] );
38  else
39  return DofMapperCode();
40  }
41 
42  private:
43  const LagrangePointSetContainer &lagrangePointSets_;
44  };
45 
46 
47 
48 
49  // LagrangeLocalDofMapping
50  // -----------------------
51 
52  // for non-Cartesian grids check edge twist and reverse DoF order
53  // in this case. This is the case for Lagrange Spaces with polOrder > 2.
54  //
55  // Notice: This is a purely 2-dimensional hack!
56  template< class GridPart >
58  {
59  static const int dimension = GridPart::dimension;
60 
61  struct Mapping
62  {
63  explicit Mapping ( bool reverse = false ) : reverse_( reverse ) {}
64 
65  template< class Iterator, class Functor >
66  void operator() ( std::size_t index, unsigned int numDofs, Iterator begin, Iterator end, Functor functor ) const
67  {
68  if( reverse_ )
69  {
70  index += numDofs;
71  while( begin != end )
72  functor( *(begin++), --index );
73  }
74  else
75  {
76  while( begin != end )
77  functor( *(begin++), index++ );
78  }
79  }
80 
81  bool reverse_;
82  };
83 
84  public:
85  LagrangeLocalDofMapping ( const GridPart &gridPart )
86  : localIdSet_( gridPart.grid().localIdSet() )
87  {}
88 
89  Mapping operator() ( const typename GridPart::template Codim< 0 >::EntityType &element, unsigned int subEntity, unsigned int codim ) const
90  {
91  if( codim == dimension-1 )
92  {
93  const auto &refElement = ReferenceElements< typename GridPart::ctype, GridPart::dimension >::general( element.type() );
94  assert( refElement.size( subEntity, codim, dimension ) == 2 );
95  const int vx[ 2 ] = { refElement.subEntity( subEntity, codim, 0, dimension ), refElement.subEntity( subEntity, codim, 1, dimension ) };
96  return Mapping( localIdSet_.subId( gridEntity( element ), vx[ 1 ], dimension ) < localIdSet_.subId( gridEntity( element ), vx[ 0 ], dimension ) );
97  }
98  else
99  return Mapping();
100  }
101 
102  private:
103  const typename GridPart::GridType::LocalIdSet &localIdSet_;
104  };
105 
106  } // namespace Fem
107 
108 } // namespace Dune
109 
110 #endif // #ifndef DUNE_FEM_SPACE_LAGRANGE_DOFMAPPER_HH
Definition: bindguard.hh:11
DofMapperCode compile(const RefElement &refElement, const LocalCoefficients &localCoefficients)
Definition: compile.hh:50
const GridEntityAccess< Entity >::GridEntityType & gridEntity(const Entity &entity)
Definition: gridpart.hh:412
Definition: dofmappercode.hh:25
LagrangeDofMapperCodeFactory(const LagrangePointSetContainer &lagrangePointSets)
Definition: dofmappercode.hh:26
Definition: dofmappercode.hh:58
LagrangeLocalDofMapping(const GridPart &gridPart)
Definition: dofmappercode.hh:85
Definition: code.hh:18