DUNE-FEM (unstable)

localrestrictprolong.hh
1#ifndef DUNE_FEM_LOCALRESTRICTPROLONG_HH
2#define DUNE_FEM_LOCALRESTRICTPROLONG_HH
3
4#include <dune/fem/function/localfunction/localfunction.hh>
5
6namespace Dune
7{
8
9 namespace Fem
10 {
11
12 // DefaultLocalRestrictProlong
13 // ---------------------------
14
15 template< class DiscreteFunctionSpace >
16 class DefaultLocalRestrictProlong;
17
18
19
20 // ConstantLocalRestrictProlong
21 // ----------------------------
22
23 template< class DiscreteFunctionSpace >
24 class ConstantLocalRestrictProlong
25 {
26 typedef ConstantLocalRestrictProlong< DiscreteFunctionSpace > ThisType;
27
28 public:
29 typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
30
31 typedef typename DiscreteFunctionSpaceType::DomainFieldType DomainFieldType;
32
33 ConstantLocalRestrictProlong ()
34 : weight_( -1 )
35 {}
36
43 void setFatherChildWeight ( const DomainFieldType &weight )
44 {
45 weight_ = weight;
46 }
47
49 template< class LFFather, class LFSon, class LocalGeometry >
50 void restrictLocal ( LFFather &lfFather, const LFSon &lfSon,
51 const LocalGeometry &geometryInFather, bool initialize ) const
52 {
53 const DomainFieldType weight = (weight_ < DomainFieldType( 0 ) ? calcWeight( lfFather.entity(), lfSon.entity() ) : weight_);
54
55 assert( weight > 0.0 );
56 //assert( std::abs( geometryInFather.volume() - weight ) < 1e-8 );
57
58 const int size = lfFather.size();
59 assert( lfFather.size() == lfSon.size() );
60 if( initialize )
61 {
62 for( int i = 0; i < size; ++i )
63 lfFather[ i ] = weight * lfSon[ i ];
64 }
65 else
66 {
67 for( int i = 0; i < size; ++i )
68 lfFather[ i ] += weight * lfSon[ i ];
69 }
70 }
71 template< class LFFather >
72 void restrictFinalize ( LFFather &lfFather ) const
73 {}
74
76 template< class LFFather, class LFSon, class LocalGeometry >
77 void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
78 const LocalGeometry &geometryInFather, bool initialize ) const
79 {
80 const int size = lfFather.size();
81 assert( lfFather.size() == lfSon.size() );
82 for( int i = 0; i < size; ++i )
83 lfSon[ i ] = lfFather[ i ];
84 }
85
87 bool needCommunication () const { return true; }
88
89
90 template< class Entity >
91 static DomainFieldType calcWeight ( const Entity &father, const Entity &son )
92 {
93 return son.geometry().volume() / father.geometry().volume();
94 }
95
96 protected:
97 DomainFieldType weight_;
98 };
99
100
101
102 // EmptyLocalRestrictProlong
103 // -------------------------
104
105 template< class DiscreteFunctionSpace >
106 class EmptyLocalRestrictProlong
107 {
108 typedef EmptyLocalRestrictProlong< DiscreteFunctionSpace > ThisType;
109
110 public:
111 typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
112
113 typedef typename DiscreteFunctionSpaceType::DomainFieldType DomainFieldType;
114
121 void setFatherChildWeight ( const DomainFieldType &weight ) {}
122
124 template< class LFFather, class LFSon, class LocalGeometry >
125 void restrictLocal ( LFFather &lfFather, const LFSon &lfSon,
126 const LocalGeometry &geometryInFather, bool initialize ) const
127 {}
128 template< class LFFather >
129 void restrictFinalize ( LFFather &lfFather ) const
130 {}
131
133 template< class LFFather, class LFSon, class LocalGeometry >
134 void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
135 const LocalGeometry &geometryInFather, bool initialize ) const
136 {}
137
139 bool needCommunication () const { return false; }
140 };
141
142 } // namespace Fem
143
144} // namespace Dune
145
146#endif // #ifndef DUNE_FEM_LOCALRESTRICTPROLONG_HH
discrete function space
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)