DUNE PDELab (2.7)

bindtime.hh
1//-*- tab-width: 4; c-basic-offset: 2; indent-tabs-mode: nil -*-
2#ifndef DUNE_PDELAB_FUNCTION_BINDTIME_HH
3#define DUNE_PDELAB_FUNCTION_BINDTIME_HH
4
5#include <dune/common/indices.hh>
6#include <dune/functions/common/signature.hh>
7
8namespace Dune {
9namespace PDELab {
10
11template<typename F, typename Placeholder>
12class SetTimeWrapper
13{
14public:
15 SetTimeWrapper(F&& f, Placeholder p)
16 : _f(f), _p(p)
17 {}
18 template<typename Domain>
19 auto operator()(const Domain & d) const
20 {
21 return swap_arguments(d,_t,_p);
22 }
23 void setTime(double t)
24 {
25 _t = t;
26 }
27private:
28 double _t;
29 F _f;
30 Placeholder _p;
31 template<typename Domain>
32 auto swap_arguments(const Domain& d, double t, const index_constant<1>&) const
33 {
34 return _f(t,d);
35 }
36 template<typename Domain>
37 auto swap_arguments(const Domain& d, double t, const index_constant<2>&) const
38 {
39 return _f(d,t);
40 }
41};
42
43template<typename F, typename Placeholder>
44SetTimeWrapper<F,Placeholder>
45bindTime(F&& f, Placeholder p)
46{
47 return SetTimeWrapper<F,Placeholder>(f,p);
48}
49
50} // end namespace PDELab
51} // end namespace Dune
52
53#endif // DUNE_PDELAB_FUNCTION_BINDTIME_HH
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)