DUNE-ACFEM (2.5.1)

restrictprolongtuple.hh
Go to the documentation of this file.
1
6#ifndef __DUNE_ACFEM_RESTRICT_PROLONG_TUPLE_HH__
7#define __DUNE_ACFEM_RESTRICT_PROLONG_TUPLE_HH__
8
9#if HAVE_DUNE_FEM_SPACE_COMMON_RESTRICTPROLONGTUPLE_HH
10
11# include <dune/fem/space/common/restrictprolongtuple.hh>
12
13namespace Dune {
14
15 namespace ACFem {
16 // ? does this work ?
18 using Fem::RestrictProlongDefaultTraits;
19
20#warning Using <dune/acfem/operators/restrictprolongtuple.hh> is deprecated, redirecting to <dune/fem/space/common/restrictprolongtuple.hh>
21 }
22}
23
24#else
25
26#include <dune/fem/space/common/restrictprolonginterface.hh>
27#include <dune/fem/function/common/function.hh>
28#include <dune/common/tuples.hh>
29
30namespace Dune {
31
32 namespace ACFem {
33
51 template<class RP1, class RP2>
53 : public Fem::RestrictProlongInterface<
54 Fem::RestrictProlongTraits<RestrictProlongPair<RP1, RP2>,
55 typename RP1::DomainFieldType> >,
56 public std::pair<RP1, RP2>
57 {
58 typedef std::pair<RP1, RP2> StorageType;
59 typedef Fem::RestrictProlongInterface<
60 Fem::RestrictProlongTraits<RestrictProlongPair<RP1, RP2>,
61 typename RP1::DomainFieldType> >
62 InterfaceType;
63
64 using StorageType::first;
65 using StorageType::second;
66
67 public:
68 typedef typename RP1::DomainFieldType DomainFieldType; // do we really need to check that ...
69
70 RestrictProlongPair(const RP1& rp1, const RP2& rp2)
71 : StorageType(rp1, rp2)
72 {}
73
74 void setFatherChildWeight(const DomainFieldType &weight) const {
75 first.setFatherChildWeight(weight);
76 second.setFatherChildWeight(weight);
77 }
78
79 template<class Entity>
80 void restrictLocal(const Entity &father, const Entity &son, bool initialize) const {
81 first.restrictLocal(father, son, initialize);
82 second.restrictLocal(father, son, initialize);
83 }
84
85 template<class Entity, class LocalGeometry>
86 void restrictLocal(const Entity &father, const Entity &son,
87 const LocalGeometry &geometryInFather,
88 bool initialize) const {
89 first.restrictLocal(father, son, geometryInFather, initialize);
90 second.restrictLocal(father, son, geometryInFather, initialize);
91 }
92
93 template<class Entity>
94 void prolongLocal(const Entity &father, const Entity &son, bool initialize) const {
95 first.prolongLocal(father, son, initialize);
96 second.prolongLocal(father, son, initialize);
97 }
98
99 template<class Entity, class LocalGeometry>
100 void prolongLocal(const Entity &father, const Entity &son,
101 const LocalGeometry &geometryInFather,
102 bool initialize) const {
103 first.prolongLocal(father, son, geometryInFather, initialize);
104 second.prolongLocal(father, son, geometryInFather, initialize);
105 }
106
107 template<class Communicator>
108 void addToList(Communicator &comm) {
109 first.addToList(comm);
110 second.addToList(comm);
111 }
112
113 template<class LoadBalancer>
114 void addToLoadBalancer(LoadBalancer &lb) {
115 first.addToLoadBalancer(lb);
116 second.addToLoadBalancer(lb);
117 }
118 };
119
124 template<class DiscreteFunction, class... Rest>
126 {
127 typedef DiscreteFunction FirstDiscreteFunctionType;
128 typedef Fem::RestrictProlongDefault<FirstDiscreteFunctionType> FirstRestrictProlongType;
129 typedef RestrictProlongPair<FirstRestrictProlongType, typename RestrictProlongDefaultTraits<Rest...>::Type> Type;
130 };
131
133 template<class DiscreteFunction>
134 struct RestrictProlongDefaultTraits<DiscreteFunction>
135 {
136 typedef DiscreteFunction FirstDiscreteFunctionType;
137 typedef Fem::RestrictProlongDefault<FirstDiscreteFunctionType> FirstRestrictProlongType;
138 typedef FirstRestrictProlongType Type;
139 };
140
144 template<class DF>
145 static inline
146 Fem::RestrictProlongDefault<DF>
147 makeRestrictProlongDefault(Fem::Function<typename DF::FunctionSpaceType, DF>& df_)
148 {
149 DF& df(static_cast<DF&>(df_));
150
151 return Fem::RestrictProlongDefault<DF>(df);
152 }
153
158 template<class DF1, class DF2, class... Rest>
159 static inline
160 typename RestrictProlongDefaultTraits<DF1, DF2, Rest...>::Type
161 makeRestrictProlongDefault(DF1& df1, DF2& df2, Rest&... rest)
162 {
163 typedef typename RestrictProlongDefaultTraits<DF1, DF2, Rest...>::Type ResultType;
164
165 return ResultType(makeRestrictProlongDefault(df1), makeRestrictProlongDefault(df2, rest...));
166 }
167
175 template<class Tuple, class Index = std::integral_constant<size_t, 0> >
177 {
178 enum { index = Index::value };
179 typedef std::integral_constant<size_t, index+1> NextIndexType;
180 typedef typename remove_reference<typename tuple_element<index, Tuple>::type>::type DiscreteFunctionType;
181 typedef Fem::RestrictProlongDefault<DiscreteFunctionType> RestrictProlongType;
184
185 static Type construct(const Tuple& arg)
186 {
187 return Type(RestrictProlongType(get<index>(arg)), NextHelperType::construct(arg));
188 }
189 };
190
192 template<class Tuple>
193 struct RestrictProlongDefaultTupleHelper<Tuple, std::integral_constant<size_t, std::tuple_size<Tuple>::value-1> >
194 {
195 enum { index = tuple_size<Tuple>::value - 1 };
196 typedef typename remove_reference<typename tuple_element<index, Tuple>::type>::type DiscreteFunctionType;
197 typedef Fem::RestrictProlongDefault<DiscreteFunctionType> RestrictProlongType;
198 typedef RestrictProlongType Type;
199
200 static Type construct(const Tuple& arg)
201 {
202 return Type(get<index>(arg));
203 }
204 };
205
206 template<class... Args>
207 struct RestrictProlongDefaultTraits<tuple<Args...> >
208 {
209 typedef
210 typename RestrictProlongDefaultTupleHelper<tuple<Args...> >::Type
211 Type;
212 };
213
224 template<class... Rest>
225 static inline
226 typename RestrictProlongDefaultTraits<Rest...>::Type
227 makeRestrictProlongDefault(const tuple<Rest&...>& arg)
228 {
229 typedef tuple<Rest&...> TupleType;
231 }
232
234
236
237 } // ACFem
238
239} // Dune
240
241#endif // HAVE_DUNE_FEM_SPACE_COMMON_RESTRICTPROLONGTUPLE_HH
242
243#endif // __DUNE_ACFEM_RESTRICT_PROLONG_TUPLE_HH__
244
Chain two RestrictProlong implementations together.
Definition: restrictprolongtuple.hh:57
static RestrictProlongDefaultTraits< Rest... >::Type makeRestrictProlongDefault(const tuple< Rest &... > &arg)
Conveniently form a compound RestrictProlong-implementation which conforms to RestrictProlongInterfac...
Definition: restrictprolongtuple.hh:227
static Fem::RestrictProlongDefault< DF > makeRestrictProlongDefault(Fem::Function< typename DF::FunctionSpaceType, DF > &df_)
Endpoint for the makeRestrictProlongDefault recursion.
Definition: restrictprolongtuple.hh:147
A helper class which defines the proper RestrictProlong compound data-type for tuples of Fem::Discret...
Definition: restrictprolongtuple.hh:126
AFAIK, C++11 is not capable of expanding tuples into parameter packs, so this recursive helper functi...
Definition: restrictprolongtuple.hh:177
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Aug 13, 22:30, 2024)