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