DUNE-FEM (unstable)

localinterpolation.hh
1#ifndef DUNE_FEM_SPACE_COMMON_LOCALINTERPOLATION_HH
2#define DUNE_FEM_SPACE_COMMON_LOCALINTERPOLATION_HH
3
4#include <optional>
5
6#include <dune/fem/common/bindguard.hh>
7
8namespace Dune
9{
10
11 namespace Fem
12 {
13
14 // Forward Declarations
15 // --------------------
16
17 template< class DiscreteFunctionSpace >
18 class LocalInterpolation;
19
20 template < class DiscreteFunctionSpace >
21 class LocalInterpolation
22 {
23 // do not copy this class
24 LocalInterpolation( const LocalInterpolation& ) = delete;
25 typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
26
27 protected:
28 typedef typename DiscreteFunctionSpaceType :: InterpolationType InterpolationType;
29
30 public:
31 typedef typename DiscreteFunctionSpaceType :: EntityType EntityType;
32
33 LocalInterpolation( const DiscreteFunctionSpaceType& space )
34 : interpolation_( space.interpolation() )
35 {}
36
43 void bind ( const EntityType& entity )
44 {
45 interpolation_.bind( entity );
46 }
47
51 void unbind ()
52 {
53 interpolation_.unbind();
54 }
55
61 template< class LocalFunction, class LocalDofVector >
62 void operator () ( const LocalFunction &localFunction, LocalDofVector &dofs ) const
63 {
64 interpolation_( localFunction, dofs );
65 }
66
67 protected:
68 InterpolationType interpolation_;
69 };
70
71
72 template< class DiscreteFunctionSpace >
73 class LocalInterpolationWrapper
74 {
75 typedef typename DiscreteFunctionSpace :: InterpolationImplType
76 InterpolationImplType;
77
78 public:
79 typedef typename DiscreteFunctionSpace::EntityType EntityType;
80
81 LocalInterpolationWrapper( const DiscreteFunctionSpace& space )
82 : space_( space )
83 , interpolation_()
84 {}
85
86 void bind( const EntityType& entity )
87 {
88 interpolation_.emplace( space_.localInterpolation( entity ) );
89 }
90
91 void unbind()
92 {
93 interpolation().unbind();
94 }
95
97 template< class LocalFunction, class LocalDofVector >
98 void operator () ( const LocalFunction &localFunction, LocalDofVector &dofs ) const
99 {
100 interpolation()( localFunction, dofs );
101 }
102
103 protected:
104 const InterpolationImplType& interpolation() const
105 {
106 assert( interpolation_.has_value() );
107 return *interpolation_;
108 }
109 InterpolationImplType& interpolation()
110 {
111 assert( interpolation_.has_value() );
112 return *interpolation_;
113 }
114
115 const DiscreteFunctionSpace& space_;
116 std::optional< InterpolationImplType > interpolation_;
117 };
118
119
120 } // namespace Fem
121
122} // namespace Dune
123
124#endif // #ifndef DUNE_FEM_SPACE_COMMON_LOCALINTERPOLATION_HH
discrete function space
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)