1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=8 sw=4 sts=4:
3 
4 #ifndef DUNE_PDELAB_LOCALOPERATOR_JACOBIANAPPLYHELPER_HH
5 #define DUNE_PDELAB_LOCALOPERATOR_JACOBIANAPPLYHELPER_HH
6 
7 // This file implements helper functions to call the jacobian_apply_* methods
8 // on a local operator. Since the interface of linear and nonlinear operators
9 // looks different this helper functions are useful in some places.
10 //
11 // Note: This should be removed as soon as a good replacement is implemented in
12 // callswitch.hh! For this reason it is put into an impl namespace and it is
13 // not intended to be used in user code.
14 
15 namespace Dune{
16   namespace PDELab{
17     namespace impl{
18       //======================
19       // Jacobian Apply Volume
20       //======================
21 
22       template <typename LOP, typename EG, typename LFSU, typename X, typename LFSV, typename Y>
jacobianApplyVolume(const LOP & lop,const EG & eg,const LFSU & lfsu,const X & z,const LFSV & lfsv,Y & y)23       std::enable_if_t<LOP::isLinear> jacobianApplyVolume(
24           const LOP& lop,
25           const EG& eg,
26           const LFSU& lfsu, const X& z, const LFSV& lfsv,
27           Y& y)
28       {
29           lop.jacobian_apply_volume(eg, lfsu, z, lfsv, y);
30       }
31         template <typename LOP, typename EG, typename LFSU, typename X, typename Z, typename LFSV, typename Y>
jacobianApplyVolume(const LOP & lop,const EG & eg,const LFSU & lfsu,const X & x,const Z & z,const LFSV & lfsv,Y & y)32         std::enable_if_t<LOP::isLinear> jacobianApplyVolume(
33             const LOP& lop,
34             const EG& eg,
35             const LFSU& lfsu, const X& x, const Z& z, const LFSV& lfsv,
36             Y& y)
37         {
38             DUNE_THROW(Dune::Exception, "You try to call a nonlinear method on a linear operator");
39         }
40         template <typename LOP, typename EG, typename LFSU, typename X, typename LFSV, typename Y>
jacobianApplyVolume(const LOP & lop,const EG & eg,const LFSU & lfsu,const X & z,const LFSV & lfsv,Y & y)41         std::enable_if_t<not LOP::isLinear> jacobianApplyVolume(
42             const LOP& lop,
43             const EG& eg,
44             const LFSU& lfsu, const X& z, const LFSV& lfsv,
45             Y& y)
46         {
47             DUNE_THROW(Dune::Exception, "You try to call a linear method on a nonlinear operator");
48         }
49         template <typename LOP, typename EG, typename LFSU, typename X, typename Z, typename LFSV, typename Y>
jacobianApplyVolume(const LOP & lop,const EG & eg,const LFSU & lfsu,const X & x,const Z & z,const LFSV & lfsv,Y & y)50         std::enable_if_t<not LOP::isLinear> jacobianApplyVolume(
51             const LOP& lop,
52             const EG& eg,
53             const LFSU& lfsu, const X& x, const Z& z, const LFSV& lfsv,
54             Y& y)
55         {
56             lop.jacobian_apply_volume(eg, lfsu, x, z, lfsv, y);
57         }
58 
59         //========================
60         // Jacobian Apply Skeleton
61         //========================
62 
63         template <typename LOP, typename IG, typename LFSU, typename X, typename LFSV, typename Y>
jacobianApplySkeleton(const LOP & lop,const IG & ig,const LFSU & lfsu_s,const X & z_s,const LFSV & lfsv_s,const LFSU & lfsu_n,const X & z_n,const LFSV & lfsv_n,Y & y_s,Y & y_n)64         std::enable_if_t<LOP::isLinear> jacobianApplySkeleton(
65             const LOP& lop,
66             const IG& ig,
67             const LFSU& lfsu_s, const X& z_s, const LFSV& lfsv_s,
68             const LFSU& lfsu_n, const X& z_n, const LFSV& lfsv_n,
69             Y& y_s, Y& y_n)
70         {
71             lop.jacobian_apply_skeleton(ig, lfsu_s, z_s, lfsv_s, lfsu_n, z_n, lfsv_n, y_s, y_n);
72         }
73         template <typename LOP, typename IG, typename LFSU, typename X, typename Z, typename LFSV, typename Y>
jacobianApplySkeleton(const LOP & lop,const IG & ig,const LFSU & lfsu_s,const X & x_s,const Z & z_s,const LFSV & lfsv_s,const LFSU & lfsu_n,const X & x_n,const Z & z_n,const LFSV & lfsv_n,Y & y_s,Y & y_n)74         std::enable_if_t<LOP::isLinear> jacobianApplySkeleton(
75             const LOP& lop,
76             const IG& ig,
77             const LFSU& lfsu_s, const X& x_s, const Z& z_s, const LFSV& lfsv_s,
78             const LFSU& lfsu_n, const X& x_n, const Z& z_n, const LFSV& lfsv_n,
79             Y& y_s, Y& y_n)
80         {
81             DUNE_THROW(Dune::Exception, "You try to call a nonlinear method on a linear operator");
82         }
83         template <typename LOP, typename IG, typename LFSU, typename X, typename LFSV, typename Y>
jacobianApplySkeleton(const LOP & lop,const IG & ig,const LFSU & lfsu_s,const X & z_s,const LFSV & lfsv_s,const LFSU & lfsu_n,const X & z_n,const LFSV & lfsv_n,Y & y_s,Y & y_n)84         std::enable_if_t<not LOP::isLinear> jacobianApplySkeleton(
85             const LOP& lop,
86             const IG& ig,
87             const LFSU& lfsu_s, const X& z_s, const LFSV& lfsv_s,
88             const LFSU& lfsu_n, const X& z_n, const LFSV& lfsv_n,
89             Y& y_s, Y& y_n)
90         {
91             DUNE_THROW(Dune::Exception, "You try to call a nonlinear method on a linear operator");
92         }
93         template <typename LOP, typename IG, typename LFSU, typename X, typename Z, typename LFSV, typename Y>
jacobianApplySkeleton(const LOP & lop,const IG & ig,const LFSU & lfsu_s,const X & x_s,const Z & z_s,const LFSV & lfsv_s,const LFSU & lfsu_n,const X & x_n,const Z & z_n,const LFSV & lfsv_n,Y & y_s,Y & y_n)94         std::enable_if_t<not LOP::isLinear> jacobianApplySkeleton(
95             const LOP& lop,
96             const IG& ig,
97             const LFSU& lfsu_s, const X& x_s, const Z& z_s, const LFSV& lfsv_s,
98             const LFSU& lfsu_n, const X& x_n, const Z& z_n, const LFSV& lfsv_n,
99             Y& y_s, Y& y_n)
100         {
101             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);
102         }
103 
104         //========================
105         // Jacobian Apply Boundary
106         //========================
107 
108         template<typename LOP, typename IG, typename LFSU, typename X, typename LFSV, typename Y>
jacobianApplyBoundary(const LOP & lop,const IG & ig,const LFSU & lfsu_s,const X & z_s,const LFSV & lfsv_s,Y & y_s)109         std::enable_if_t<LOP::isLinear> jacobianApplyBoundary(
110             const LOP& lop,
111             const IG& ig,
112             const LFSU& lfsu_s, const X& z_s, const LFSV& lfsv_s,
113             Y& y_s)
114         {
115             lop.jacobian_apply_boundary(ig, lfsu_s, z_s, lfsv_s, y_s);
116         }
117         template<typename LOP, typename IG, typename LFSU, typename X, typename Z, typename LFSV, typename Y>
jacobianApplyBoundary(const LOP & lop,const IG & ig,const LFSU & lfsu_s,const X & x_s,const Z & z_s,const LFSV & lfsv_s,Y & y_s)118         std::enable_if_t<LOP::isLinear> jacobianApplyBoundary(
119             const LOP& lop,
120             const IG& ig,
121             const LFSU& lfsu_s, const X& x_s, const Z& z_s, const LFSV& lfsv_s,
122             Y& y_s)
123         {
124             DUNE_THROW(Dune::Exception, "You try to call a nonlinear method on a linear operator");
125         }
126         template<typename LOP, typename IG, typename LFSU, typename X, typename LFSV, typename Y>
jacobianApplyBoundary(const LOP & lop,const IG & ig,const LFSU & lfsu_s,const X & z_s,const LFSV & lfsv_s,Y & y_s)127         std::enable_if_t<not LOP::isLinear> jacobianApplyBoundary(
128             const LOP& lop,
129             const IG& ig,
130             const LFSU& lfsu_s, const X& z_s, const LFSV& lfsv_s,
131             Y& y_s)
132         {
133             DUNE_THROW(Dune::Exception, "You try to call a nonlinear method on a linear operator");
134         }
135         template<typename LOP, typename IG, typename LFSU, typename X, typename Z, typename LFSV, typename Y>
jacobianApplyBoundary(const LOP & lop,const IG & ig,const LFSU & lfsu_s,const X & x_s,const Z & z_s,const LFSV & lfsv_s,Y & y_s)136         std::enable_if_t<not LOP::isLinear> jacobianApplyBoundary(
137             const LOP& lop,
138             const IG& ig,
139             const LFSU& lfsu_s, const X& x_s, const Z& z_s, const LFSV& lfsv_s,
140             Y& y_s)
141         {
142             lop.jacobian_apply_boundary(ig, lfsu_s, x_s, z_s, lfsv_s, y_s);
143         }
144 
145     } //namespace impl
146   } // namespace PDELab
147 } // namespace Dune
148 
149 
150 #endif
151