DUNE-FEM (unstable)

dofmappercode.hh
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>
8
9// dune-fem includes
10#include <dune/fem/space/mapper/code.hh>
11#include <dune/fem/space/mapper/compile.hh>
12
13
14namespace Dune
15{
16
17 namespace Fem
18 {
19
20 // LagrangeDofMapperCodeFactory
21 // ----------------------------
22
23 template< class LagrangePointSetContainer >
24 struct LagrangeDofMapperCodeFactory
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 >
57 class LagrangeLocalDofMapping
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 {
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
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Dune namespace.
Definition: alignedallocator.hh:13
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:156
A unique label for each type of element that can occur in a grid.
Helper classes to provide indices for geometrytypes for use in a vector.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)