DUNE PDELab (2.7)

callswitch.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_PDELAB_LOCALOPERATOR_CALLSWITCH_HH
4#define DUNE_PDELAB_LOCALOPERATOR_CALLSWITCH_HH
5
8
9namespace Dune {
10 namespace PDELab {
11
12 namespace Impl {
13
16 // compile time switching of function call
17 template<typename LOP, bool doIt, bool isLinear = LOP::isLinear>
18 struct LocalAssemblerCallSwitchHelper
19 {
20 //================
21 // Pattern methods
22 //================
23 template<typename LFSU, typename LFSV, typename LocalPattern>
24 static void pattern_volume (const LOP& lop, const LFSU& lfsu, const LFSV& lfsv, LocalPattern& pattern)
25 {
26 }
27 template<typename LFSU, typename LFSV, typename LocalPattern>
28 static void pattern_volume_post_skeleton
29 ( const LOP& lop,
30 const LFSU& lfsu, const LFSV& lfsv,
31 LocalPattern& pattern)
32 {
33 }
34 template<typename LFSU, typename LFSV, typename LocalPattern>
35 static void pattern_skeleton (const LOP& lop, const LFSU& lfsu_s, const LFSV& lfsv_s,
36 const LFSU& lfsu_n, const LFSV& lfsv_n,
37 LocalPattern& pattern_sn,
38 LocalPattern& pattern_ns)
39 {
40 }
41 template<typename LFSU, typename LFSV, typename LocalPattern>
42 static void pattern_boundary(const LOP& lop,
43 const LFSU& lfsu_s, const LFSV& lfsv_s,
44 LocalPattern& pattern_ss)
45 {
46 }
47
48 //==============
49 // Alpha methods
50 //==============
51 template<typename EG, typename LFSU, typename X, typename LFSV, typename R>
52 static void alpha_volume (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const LFSV& lfsv, R& r)
53 {
54 }
55 template<typename EG, typename LFSU, typename X, typename LFSV, typename R>
56 static void alpha_volume_post_skeleton (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const LFSV& lfsv, R& r)
57 {
58 }
59 template<typename IG, typename LFSU, typename X, typename LFSV, typename R>
60 static void alpha_skeleton (const LOP& lop, const IG& ig,
61 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
62 const LFSU& lfsu_n, const X& x_n, const LFSV& lfsv_n,
63 R& r_s, R& r_n)
64 {
65 }
66 template<typename IG, typename LFSU, typename X, typename LFSV, typename R>
67 static void alpha_boundary (const LOP& lop, const IG& ig,
68 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
69 R& r_s)
70 {
71 }
72
73 //===============
74 // Lambda methods
75 //===============
76 template<typename EG, typename LFSV, typename R>
77 static void lambda_volume (const LOP& lop, const EG& eg, const LFSV& lfsv, R& r)
78 {
79 }
80 template<typename EG, typename LFSV, typename R>
81 static void lambda_volume_post_skeleton (const LOP& lop, const EG& eg, const LFSV& lfsv, R& r)
82 {
83 }
84 template<typename IG, typename LFSV, typename R>
85 static void lambda_skeleton(const LOP& lop, const IG& ig,
86 const LFSV& lfsv_s, const LFSV& lfsv_n,
87 R& r_s, R& r_n)
88 {
89 }
90 template<typename IG, typename LFSV, typename R>
91 static void lambda_boundary (const LOP& lop, const IG& ig, const LFSV& lfsv, R& r)
92 {
93 }
94
95 //=======================
96 // Jacobian apply methods
97 //=======================
98 template<typename EG, typename LFSU, typename X, typename LFSV, typename Y>
99 static void jacobian_apply_volume (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const X& z, const LFSV& lfsv, Y& y)
100 {
101 }
102 template<typename EG, typename LFSU, typename X, typename LFSV, typename Y>
103 static void jacobian_apply_volume_post_skeleton (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const X& z, const LFSV& lfsv, Y& y)
104 {
105 }
106 template<typename IG, typename LFSU, typename X, typename LFSV, typename Y>
107 static void jacobian_apply_skeleton (const LOP& lop, const IG& ig,
108 const LFSU& lfsu_s, const X& x_s, const X& z_s, const LFSV& lfsv_s,
109 const LFSU& lfsu_n, const X& x_n, const X& z_n, const LFSV& lfsv_n,
110 Y& y_s, Y& y_n)
111 {
112 }
113 template<typename IG, typename LFSU, typename X, typename LFSV, typename Y>
114 static void jacobian_apply_boundary (const LOP& lop, const IG& ig,
115 const LFSU& lfsu_s, const X& x_s, const X& z_s, const LFSV& lfsv_s,
116 Y& y_s)
117 {
118 }
119
120 //=================
121 // Jacobian methods
122 //=================
123 template<typename EG, typename LFSU, typename X, typename LFSV, typename M>
124 static void jacobian_volume (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const LFSV& lfsv, M & mat)
125 {
126 }
127 template<typename EG, typename LFSU, typename X, typename LFSV, typename M>
128 static void jacobian_volume_post_skeleton (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const LFSV& lfsv, M& mat)
129 {
130 }
131 template<typename IG, typename LFSU, typename X, typename LFSV, typename M>
132 static void jacobian_skeleton (const LOP& lop, const IG& ig,
133 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
134 const LFSU& lfsu_n, const X& x_n, const LFSV& lfsv_n,
135 M & mat_ss, M & mat_sn,
136 M & mat_ns, M & mat_nn)
137 {
138 }
139 template<typename IG, typename LFSU, typename X, typename LFSV, typename M>
140 static void jacobian_boundary (const LOP& lop, const IG& ig,
141 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
142 M & mat_ss)
143 {
144 }
145 };
146
147
148 template<typename LOP>
149 struct LocalAssemblerCallSwitchHelper<LOP,true,true>
150 {
151 //================
152 // Pattern methods
153 //================
154 template<typename LFSU, typename LFSV, typename LocalPattern>
155 static void pattern_volume (const LOP& lop, const LFSU& lfsu, const LFSV& lfsv, LocalPattern& pattern)
156 {
157 lop.pattern_volume(lfsu,lfsv,pattern);
158 }
159 template<typename LFSU, typename LFSV, typename LocalPattern>
160 static void pattern_volume_post_skeleton
161 ( const LOP& lop,
162 const LFSU& lfsu, const LFSV& lfsv,
163 LocalPattern& pattern)
164 {
165 lop.pattern_volume_post_skeleton(lfsu,lfsv,pattern);
166 }
167 template<typename LFSU, typename LFSV, typename LocalPattern>
168 static void pattern_skeleton (const LOP& lop, const LFSU& lfsu_s, const LFSV& lfsv_s,
169 const LFSU& lfsu_n, const LFSV& lfsv_n,
170 LocalPattern& pattern_sn,
171 LocalPattern& pattern_ns)
172 {
173 lop.pattern_skeleton(lfsu_s,lfsv_s,lfsu_n,lfsv_n,
174 pattern_sn, pattern_ns);
175 }
176 template<typename LFSU, typename LFSV, typename LocalPattern>
177 static void pattern_boundary(const LOP& lop,
178 const LFSU& lfsu_s, const LFSV& lfsv_s,
179 LocalPattern& pattern_ss)
180 {
181 lop.pattern_boundary(lfsu_s,lfsv_s,pattern_ss);
182 }
183
184 //==============
185 // Alpha methods
186 //==============
187 template<typename EG, typename LFSU, typename X, typename LFSV, typename R>
188 static void alpha_volume (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const LFSV& lfsv, R& r)
189 {
190 lop.alpha_volume(eg,lfsu,x,lfsv,r);
191 }
192 template<typename EG, typename LFSU, typename X, typename LFSV, typename R>
193 static void alpha_volume_post_skeleton (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const LFSV& lfsv, R& r)
194 {
195 lop.alpha_volume_post_skeleton(eg,lfsu,x,lfsv,r);
196 }
197 template<typename IG, typename LFSU, typename X, typename LFSV, typename R>
198 static void alpha_skeleton (const LOP& lop, const IG& ig,
199 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
200 const LFSU& lfsu_n, const X& x_n, const LFSV& lfsv_n,
201 R& r_s, R& r_n)
202 {
203 lop.alpha_skeleton(ig,lfsu_s,x_s,lfsv_s,lfsu_n,x_n,lfsv_n,r_s,r_n);
204 }
205 template<typename IG, typename LFSU, typename X, typename LFSV, typename R>
206 static void alpha_boundary (const LOP& lop, const IG& ig,
207 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
208 R& r_s)
209 {
210 lop.alpha_boundary(ig,lfsu_s,x_s,lfsv_s,r_s);
211 }
212
213 //===============
214 // Lambda methods
215 //===============
216 template<typename EG, typename LFSV, typename R>
217 static void lambda_volume (const LOP& lop, const EG& eg, const LFSV& lfsv, R& r)
218 {
219 lop.lambda_volume(eg,lfsv,r);
220 }
221 template<typename EG, typename LFSV, typename R>
222 static void lambda_volume_post_skeleton (const LOP& lop, const EG& eg, const LFSV& lfsv, R& r)
223 {
224 lop.lambda_volume_post_skeleton(eg,lfsv,r);
225 }
226 template<typename IG, typename LFSV, typename R>
227 static void lambda_skeleton(const LOP& lop, const IG& ig,
228 const LFSV& lfsv_s, const LFSV& lfsv_n,
229 R& r_s, R& r_n)
230 {
231 lop.lambda_skeleton(ig, lfsv_s, lfsv_n, r_s, r_n);
232 }
233 template<typename IG, typename LFSV, typename R>
234 static void lambda_boundary (const LOP& lop, const IG& ig, const LFSV& lfsv, R& r)
235 {
236 lop.lambda_boundary(ig,lfsv,r);
237 }
238
239 //=======================
240 // Jacobian apply methods
241 //=======================
242 template<typename EG, typename LFSU, typename X, typename LFSV, typename Y>
243 static auto jacobian_apply_volume (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const X& z, const LFSV& lfsv, Y& y)
244 {
245 lop.jacobian_apply_volume(eg,lfsu,z,lfsv,y);
246 }
247 template<typename EG, typename LFSU, typename X, typename LFSV, typename Y>
248 static void jacobian_apply_volume_post_skeleton (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const X& z, const LFSV& lfsv, Y& y)
249 {
250 lop.jacobian_apply_volume_post_skeleton(eg,lfsu,z,lfsv,y);
251 }
252 template<typename IG, typename LFSU, typename X, typename LFSV, typename Y>
253 static void jacobian_apply_skeleton (const LOP& lop, const IG& ig,
254 const LFSU& lfsu_s, const X& x_s, const X& z_s, const LFSV& lfsv_s,
255 const LFSU& lfsu_n, const X& x_n, const X& z_n, const LFSV& lfsv_n,
256 Y& y_s, Y& y_n)
257 {
258 lop.jacobian_apply_skeleton(ig,lfsu_s,z_s,lfsv_s,lfsu_n,z_n,lfsv_n,y_s,y_n);
259 }
260 template<typename IG, typename LFSU, typename X, typename LFSV, typename Y>
261 static void jacobian_apply_boundary (const LOP& lop, const IG& ig,
262 const LFSU& lfsu_s, const X& x_s, const X& z_s, const LFSV& lfsv_s,
263 Y& y_s)
264 {
265 lop.jacobian_apply_boundary(ig,lfsu_s,z_s,lfsv_s,y_s);
266 }
267
268 //=================
269 // Jacobian methods
270 //=================
271 template<typename EG, typename LFSU, typename X, typename LFSV, typename M>
272 static void jacobian_volume (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const LFSV& lfsv, M & mat)
273 {
274 lop.jacobian_volume(eg,lfsu,x,lfsv,mat);
275 }
276 template<typename EG, typename LFSU, typename X, typename LFSV, typename M>
277 static void jacobian_volume_post_skeleton (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const LFSV& lfsv, M & mat)
278 {
279 lop.jacobian_volume_post_skeleton(eg,lfsu,x,lfsv,mat);
280 }
281 template<typename IG, typename LFSU, typename X, typename LFSV, typename M>
282 static void jacobian_skeleton (const LOP& lop, const IG& ig,
283 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
284 const LFSU& lfsu_n, const X& x_n, const LFSV& lfsv_n,
285 M & mat_ss, M & mat_sn,
286 M & mat_ns, M & mat_nn)
287 {
288 lop.jacobian_skeleton(ig,lfsu_s,x_s,lfsv_s,lfsu_n,x_n,lfsv_n,
289 mat_ss, mat_sn, mat_ns, mat_nn);
290 }
291 template<typename IG, typename LFSU, typename X, typename LFSV, typename M>
292 static void jacobian_boundary (const LOP& lop, const IG& ig,
293 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
294 M & mat_ss)
295 {
296 lop.jacobian_boundary(ig,lfsu_s,x_s,lfsv_s,mat_ss);
297 }
298 };
299
305 template<typename LOP>
306 struct LocalAssemblerCallSwitchHelper<LOP,true,false> :
307 public LocalAssemblerCallSwitchHelper<LOP,true,true>
308 {
309 //=======================
310 // Jacobian apply methods
311 //=======================
312 template<typename EG, typename LFSU, typename X, typename LFSV, typename Y>
313 static auto jacobian_apply_volume (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const X& z, const LFSV& lfsv, Y& y)
314 {
315 lop.jacobian_apply_volume(eg,lfsu,x,z,lfsv,y);
316 }
317 template<typename EG, typename LFSU, typename X, typename LFSV, typename Y>
318 static void jacobian_apply_volume_post_skeleton (const LOP& lop, const EG& eg, const LFSU& lfsu, const X& x, const X& z, const LFSV& lfsv, Y& y)
319 {
320 lop.jacobian_apply_volume_post_skeleton(eg,lfsu,x,z,lfsv,y);
321 }
322 template<typename IG, typename LFSU, typename X, typename LFSV, typename Y>
323 static void jacobian_apply_skeleton (const LOP& lop, const IG& ig,
324 const LFSU& lfsu_s, const X& x_s, const X& z_s, const LFSV& lfsv_s,
325 const LFSU& lfsu_n, const X& x_n, const X& z_n, const LFSV& lfsv_n,
326 Y& y_s, Y& y_n)
327 {
328 lop.jacobian_apply_skeleton(ig,lfsu_s,x_s,z_s,lfsv_s,lfsu_n,x_n,z_n,lfsv_n,y_s,y_n);
329 }
330 template<typename IG, typename LFSU, typename X, typename LFSV, typename Y>
331 static void jacobian_apply_boundary (const LOP& lop, const IG& ig,
332 const LFSU& lfsu_s, const X& x_s, const X& z_s, const LFSV& lfsv_s,
333 Y& y_s)
334 {
335 lop.jacobian_apply_boundary(ig,lfsu_s,x_s,z_s,lfsv_s,y_s);
336 }
337 };
338
339 } // namespace Impl
340
342 template<typename LOP, bool doIt>
343 using LocalAssemblerCallSwitch =
344 Impl::LocalAssemblerCallSwitchHelper<LOP,doIt>;
345
346 namespace LocalOperatorApply {
347
348 auto patternVolume = [](const auto& lop, auto&... args)
349 {
350 using LOP = std::decay_t<decltype(lop)>;
351 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doPatternVolume>::
352 pattern_volume(lop, args...);
353 };
354
355 auto patternVolumePostSkeleton = [](const auto& lop, auto&... args)
356 {
357 using LOP = std::decay_t<decltype(lop)>;
358 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doPatternVolumePostSkeleton>::
359 pattern_volume_post_skeleton(lop, args...);
360 };
361
362 auto patternSkeleton = [](const auto& lop, auto&... args)
363 {
364 using LOP = std::decay_t<decltype(lop)>;
365 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doPatternSkeleton>::
366 pattern_skeleton(lop, args...);
367 };
368
369 auto patternBoundary = [](const auto& lop, auto&... args)
370 {
371 using LOP = std::decay_t<decltype(lop)>;
372 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doPatternBoundary>::
373 pattern_boundary(lop, args...);
374 };
375
377 auto alphaVolume = [](const auto& lop, auto&... args)
378 {
379 using LOP = std::decay_t<decltype(lop)>;
380 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaVolume>::
381 alpha_volume(lop, args...);
382 };
383
384 auto alphaVolumePostSkeleton = [](const auto& lop, auto&... args)
385 {
386 using LOP = std::decay_t<decltype(lop)>;
387 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaVolumePostSkeleton>::
388 alpha_volume_post_skeleton(lop, args...);
389 };
390
391 auto alphaSkeleton = [](const auto& lop, auto&... args)
392 {
393 using LOP = std::decay_t<decltype(lop)>;
394 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaSkeleton>::
395 alpha_skeleton(lop, args...);
396 };
397
398 auto alphaBoundary = [](const auto& lop, auto&... args)
399 {
400 using LOP = std::decay_t<decltype(lop)>;
401 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaBoundary>::
402 alpha_boundary(lop, args...);
403 };
404
405
407 auto lambdaVolume = [](const auto& lop, auto&... args)
408 {
409 using LOP = std::decay_t<decltype(lop)>;
410 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doLambdaVolume>::
411 lambda_volume(lop, args...);
412 };
413
414 auto lambdaVolumePostSkeleton = [](const auto& lop, auto&... args)
415 {
416 using LOP = std::decay_t<decltype(lop)>;
417 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doLambdaVolumePostSkeleton>::
418 lambda_volume_post_skeleton(lop, args...);
419 };
420
421 auto lambdaSkeleton = [](const auto& lop, auto&... args)
422 {
423 using LOP = std::decay_t<decltype(lop)>;
424 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doLambdaSkeleton>::
425 lambda_skeleton(lop, args...);
426 };
427
428 auto lambdaBoundary = [](const auto& lop, auto&... args)
429 {
430 using LOP = std::decay_t<decltype(lop)>;
431 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doLambdaBoundary>::
432 lambda_boundary(lop, args...);
433 };
434
435
437 auto jacobianVolume = [](const auto& lop, auto&... args)
438 {
439 using LOP = std::decay_t<decltype(lop)>;
440 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaVolume>::
441 jacobian_volume(lop, args...);
442 };
443
444 auto jacobianVolumePostSkeleton = [](const auto& lop, auto&... args)
445 {
446 using LOP = std::decay_t<decltype(lop)>;
447 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaVolumePostSkeleton>::
448 jacobian_volume_post_skeleton(lop, args...);
449 };
450
451 auto jacobianSkeleton = [](const auto& lop, auto&... args)
452 {
453 using LOP = std::decay_t<decltype(lop)>;
454 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaSkeleton>::
455 jacobian_skeleton(lop, args...);
456 };
457
458 auto jacobianBoundary = [](const auto& lop, auto&... args)
459 {
460 using LOP = std::decay_t<decltype(lop)>;
461 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaBoundary>::
462 jacobian_boundary(lop, args...);
463 };
464
465
467 auto jacobianApplyVolume = [](const auto& lop, auto&... args)
468 {
469 using LOP = std::decay_t<decltype(lop)>;
470 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaVolume>::
471 jacobian_apply_volume(lop, args...);
472 };
473
474 auto jacobianApplyVolumePostSkeleton = [](const auto& lop, auto&... args)
475 {
476 using LOP = std::decay_t<decltype(lop)>;
477 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaVolumePostSkeleton>::
478 jacobian_apply_volume_post_skeleton(lop, args...);
479 };
480
481 auto jacobianApplySkeleton = [](const auto& lop, auto&... args)
482 {
483 using LOP = std::decay_t<decltype(lop)>;
484 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaSkeleton>::
485 jacobian_apply_skeleton(lop, args...);
486 };
487
488 auto jacobianApplyBoundary = [](const auto& lop, auto&... args)
489 {
490 using LOP = std::decay_t<decltype(lop)>;
491 Impl::LocalAssemblerCallSwitchHelper<LOP,LOP::doAlphaBoundary>::
492 jacobian_apply_boundary(lop, args...);
493 };
494
495 } // namespace LocalOperatorApply
496
497 } // namespace PDELab
498} // namespace Dune
499
500#endif // DUNE_PDELAB_LOCALOPERATOR_CALLSWITCH_HH
Infrastructure for concepts.
Traits for type conversions and type information.
Dune namespace.
Definition: alignedallocator.hh:14
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)