3#ifndef DUNE_PDELAB_LOCALOPERATOR_NUMERICALJACOBIANAPPLY_HH
4#define DUNE_PDELAB_LOCALOPERATOR_NUMERICALJACOBIANAPPLY_HH
6#include <dune/pdelab/localoperator/numericalnonlinearjacobianapply.hh>
31 template<
typename Imp>
52 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
56 const LFSU& lfsu,
const X& x,
const LFSV& lfsv,
59 typedef typename X::value_type D;
60 typedef typename Y::value_type R;
62 typedef typename ResidualVector::WeightedAccumulationView ResidualView;
64 const int m=lfsv.
size();
65 const int n=lfsu.size();
70 ResidualVector down(y.size()),up(y.size());
71 ResidualView downview = down.weightedAccumulationView(y.weight());
72 ResidualView upview = up.weightedAccumulationView(y.weight());
74 asImp().alpha_volume(eg,lfsu,u,lfsv,downview);
75 for (
int j=0; j<n; j++)
78 D delta = epsilon*(1.0+std::abs(u(lfsu,j)));
80 asImp().alpha_volume(eg,lfsu,u,lfsv,upview);
81 for (
int i=0; i<m; i++)
82 y.rawAccumulate(lfsv,i,((up(lfsv,i)-down(lfsv,i))/delta)*x(lfsu,j));
83 u(lfsu,j) = x(lfsu,j);
89 Imp& asImp () {
return static_cast<Imp &
> (*this); }
90 const Imp& asImp ()
const {
return static_cast<const Imp &
>(*this); }
106 template<
typename Imp>
127 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
131 const LFSU& lfsu,
const X& x,
const LFSV& lfsv,
134 typedef typename X::value_type D;
135 typedef typename Y::value_type R;
137 typedef typename ResidualVector::WeightedAccumulationView ResidualView;
139 const int m=lfsv.
size();
140 const int n=lfsu.size();
145 ResidualVector down(y.size()),up(y.size());
146 ResidualView downview = down.weightedAccumulationView(y.weight());
147 ResidualView upview = up.weightedAccumulationView(y.weight());
149 asImp().alpha_volume_post_skeleton(eg,lfsu,u,lfsv,downview);
150 for (
int j=0; j<n; j++)
153 D delta = epsilon*(1.0+std::abs(u(lfsu,j)));
155 asImp().alpha_volume_post_skeleton(eg,lfsu,u,lfsv,upview);
156 for (
int i=0; i<m; i++)
157 y.rawAccumulate(lfsv,i,((up(lfsv,i)-down(lfsv,i))/delta)*x(lfsu,j));
158 u(lfsu,j) = x(lfsu,j);
163 const double epsilon;
164 Imp& asImp () {
return static_cast<Imp &
> (*this);}
165 const Imp& asImp ()
const {
return static_cast<const Imp &
>(*this);}
179 template<
typename Imp>
200 template<
typename IG,
typename LFSU,
typename X,
typename LFSV,
204 const LFSU& lfsu_s,
const X& x_s,
const LFSV& lfsv_s,
205 const LFSU& lfsu_n,
const X& x_n,
const LFSV& lfsv_n,
206 Y& y_s, Y& y_n)
const
208 typedef typename X::value_type D;
209 typedef typename Y::value_type R;
211 typedef typename ResidualVector::WeightedAccumulationView ResidualView;
213 const int m_s=lfsv_s.
size();
214 const int m_n=lfsv_n.size();
215 const int n_s=lfsu_s.size();
216 const int n_n=lfsu_n.size();
222 ResidualVector down_s(y_s.size()),up_s(y_s.size());
223 ResidualView downview_s = down_s.weightedAccumulationView(1.0);
224 ResidualView upview_s = up_s.weightedAccumulationView(1.0);
226 ResidualVector down_n(y_n.size()),up_n(y_n.size());
227 ResidualView downview_n = down_n.weightedAccumulationView(1.0);
228 ResidualView upview_n = up_n.weightedAccumulationView(1.0);
231 asImp().alpha_skeleton(ig,lfsu_s,u_s,lfsv_s,lfsu_n,u_n,lfsv_n,downview_s,
235 for (
int j=0; j<n_s; j++)
239 D delta = epsilon*(1.0+std::abs(u_s(lfsu_s,j)));
240 u_s(lfsu_s,j) += delta;
241 asImp().alpha_skeleton(ig,lfsu_s,u_s,lfsv_s,lfsu_n,u_n,lfsv_n,upview_s,
243 for (
int i=0; i<m_s; i++)
244 y_s.accumulate(lfsv_s,i,((up_s(lfsv_s,i)-down_s(lfsv_s,i))/delta)*x_s(lfsu_s,j));
245 for (
int i=0; i<m_n; i++)
246 y_n.accumulate(lfsv_n,i,((up_n(lfsv_n,i)-down_n(lfsv_n,i))/delta)*x_s(lfsu_s,j));
247 u_s(lfsu_s,j) = x_s(lfsu_s,j);
251 for (
int j=0; j<n_n; j++)
255 D delta = epsilon*(1.0+std::abs(u_n(lfsu_n,j)));
256 u_n(lfsu_n,j) += delta;
257 asImp().alpha_skeleton(ig,lfsu_s,u_s,lfsv_s,lfsu_n,u_n,lfsv_n,upview_s,
259 for (
int i=0; i<m_s; i++)
260 y_s.accumulate(lfsv_s,i,((up_s(lfsv_s,i)-down_s(lfsv_s,i))/delta)*x_n(lfsu_n,j));
261 for (
int i=0; i<m_n; i++)
262 y_n.accumulate(lfsv_n,i,((up_n(lfsv_n,i)-down_n(lfsv_n,i))/delta)*x_n(lfsu_n,j));
263 u_n(lfsu_n,j) = x_n(lfsu_n,j);
268 const double epsilon;
269 Imp& asImp () {
return static_cast<Imp &
> (*this); }
270 const Imp& asImp ()
const {
return static_cast<const Imp &
>(*this); }
284 template<
typename Imp>
305 template<
typename IG,
typename LFSU,
typename X,
typename LFSV,
309 const LFSU& lfsu_s,
const X& x_s,
const LFSV& lfsv_s,
312 typedef typename X::value_type D;
313 typedef typename Y::value_type R;
315 typedef typename ResidualVector::WeightedAccumulationView ResidualView;
317 const int m_s=lfsv_s.
size();
318 const int n_s=lfsu_s.size();
323 ResidualVector down_s(y_s.size()),up_s(y_s.size());
324 ResidualView downview_s = down_s.weightedAccumulationView(1.0);
325 ResidualView upview_s = up_s.weightedAccumulationView(1.0);
328 asImp().alpha_boundary(ig,lfsu_s,u_s,lfsv_s,downview_s);
331 for (
int j=0; j<n_s; j++)
334 D delta = epsilon*(1.0+std::abs(u_s(lfsu_s,j)));
335 u_s(lfsu_s,j) += delta;
336 asImp().alpha_boundary(ig,lfsu_s,u_s,lfsv_s,upview_s);
337 for (
int i=0; i<m_s; i++)
338 y_s.rawAccumulate(lfsv_s,i,((up_s(lfsv_s,i)-down_s(lfsv_s,i))/delta)*x_s(lfsu_s,j));
339 u_s(lfsu_s,j) = x_s(lfsu_s,j);
344 const double epsilon;
345 Imp& asImp () {
return static_cast<Imp &
> (*this); }
346 const Imp& asImp ()
const {
return static_cast<const Imp &
>(*this); }
A container for storing data associated with the degrees of freedom of a LocalFunctionSpace.
Definition: localvector.hh:184
size_type size() const
The size of the container.
Definition: localvector.hh:318
Implements linear and nonlinear versions of jacobian_apply_boundary() based on alpha_boundary()
Definition: numericaljacobianapply.hh:287
void jacobian_apply_boundary(const IG &ig, const LFSU &lfsu_s, const X &x_s, const LFSV &lfsv_s, Y &y_s) const
apply local jacobian of the boundaryterm
Definition: numericaljacobianapply.hh:308
Implements linear and nonlinear versions of jacobian_apply_skeleton() based on alpha_skeleton()
Definition: numericaljacobianapply.hh:182
void jacobian_apply_skeleton(const IG &ig, const LFSU &lfsu_s, const X &x_s, const LFSV &lfsv_s, const LFSU &lfsu_n, const X &x_n, const LFSV &lfsv_n, Y &y_s, Y &y_n) const
apply local jacobian of the skeleton term
Definition: numericaljacobianapply.hh:203
Definition: numericaljacobianapply.hh:109
void jacobian_apply_volume_post_skeleton(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, Y &y) const
apply local jacobian of the volume term (post skeleton part)
Definition: numericaljacobianapply.hh:130
Implements linear and nonlinear versions of jacobian_apply_volume() based on alpha_volume()
Definition: numericaljacobianapply.hh:34
void jacobian_apply_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, Y &y) const
apply local jacobian of the volume term
Definition: numericaljacobianapply.hh:55
Implements nonlinear version of jacobian_apply_boundary() based on alpha_boundary()
Definition: numericalnonlinearjacobianapply.hh:249
Implements nonlinear version of jacobian_apply_skeleton() based on alpha_skeleton()
Definition: numericalnonlinearjacobianapply.hh:158
Definition: numericalnonlinearjacobianapply.hh:97
Implements nonlinear version of jacobian_apply_volume() based on alpha_volume()
Definition: numericalnonlinearjacobianapply.hh:34
Dune namespace.
Definition: alignedallocator.hh:13