dune-pdelab  2.7-git
onestep/jacobianapplyengine.hh
Go to the documentation of this file.
1 // -*- tab-width: 2; indent-tabs-mode: nil -*-
2 // vi: set et ts=2 sw=2 sts=2:
3 #ifndef DUNE_PDELAB_GRIDOPERATOR_ONESTEP_JACOBIANAPPLYENGINE_HH
4 #define DUNE_PDELAB_GRIDOPERATOR_ONESTEP_JACOBIANAPPLYENGINE_HH
5 
7 #include <cmath>
8 
9 namespace Dune{
10  namespace PDELab{
11 
19  template<typename OSLA>
21  : public OneStepLocalAssemblerEngineBase<OSLA,
22  typename OSLA::LocalAssemblerDT0::LocalJacobianApplyAssemblerEngine,
23  typename OSLA::LocalAssemblerDT1::LocalJacobianApplyAssemblerEngine
24  >
25  {
27  typename OSLA::LocalAssemblerDT0::LocalJacobianApplyAssemblerEngine,
28  typename OSLA::LocalAssemblerDT1::LocalJacobianApplyAssemblerEngine
29  > BaseT;
30 
31  using BaseT::la;
32  using BaseT::lae0;
33  using BaseT::lae1;
34  using BaseT::implicit;
37  public:
39  typedef OSLA LocalAssembler;
40 
41  typedef typename OSLA::LocalAssemblerDT0 LocalAssemblerDT0;
42  typedef typename OSLA::LocalAssemblerDT1 LocalAssemblerDT1;
43 
44  typedef typename LocalAssemblerDT0::LocalJacobianApplyAssemblerEngine JacobianEngineDT0;
45  typedef typename LocalAssemblerDT1::LocalJacobianApplyAssemblerEngine JacobianEngineDT1;
46 
48  typedef typename OSLA::Traits::Range Range;
49 
51  typedef typename OSLA::Traits::Domain Domain;
52 
54  typedef typename OSLA::Real Real;
55 
62  : BaseT(local_assembler_)
63  , invalid_result(nullptr)
64  , invalid_solution(nullptr)
65  , invalid_update(nullptr)
66  , result(invalid_result)
67  , solution(invalid_solution)
68  , update(invalid_update)
69  {}
70 
73  void setSolution(const Domain& solution_)
74  {
75  solution = &solution_;
76  }
77 
80  void setUpdate(const Domain& update_)
81  {
82  update = &update_;
83  }
84 
87  void setResult(Range& result_)
88  {
89  result = &result_;
90 
91  // Initialize the engines of the two wrapped local assemblers
92  assert(update != invalid_update);
93  setLocalAssemblerEngineDT0
94  (la.la0.localJacobianApplyAssemblerEngine(*solution,*update,*result));
95  setLocalAssemblerEngineDT1
96  (la.la1.localJacobianApplyAssemblerEngine(*solution,*update,*result));
97  }
98 
102  void setWeights()
103  {
104  la.la0.setWeight(b_rr * la.dt_factor0);
105  la.la1.setWeight(la.dt_factor1);
106  }
107 
110  void preAssembly()
111  {
112  lae0->preAssembly();
113  lae1->preAssembly();
114 
115  // Extract the coefficients of the time step scheme
116  b_rr = la.osp_method->b(la.stage,la.stage);
117  d_r = la.osp_method->d(la.stage);
118 
119  // Here we only want to know whether this stage is implicit
120  using std::abs;
121  implicit = abs(b_rr) > 1e-6;
122 
123  // prepare local operators for stage
124  la.la0.setTime(la.time + d_r * la.dt);
125  la.la1.setTime(la.time + d_r * la.dt);
126 
127  setWeights();
128  }
129 
130  template<typename GFSU, typename GFSV>
131  void postAssembly(const GFSU& gfsu, const GFSV& gfsv)
132  {
133  lae0->postAssembly(gfsu,gfsv);
134  lae1->postAssembly(gfsu,gfsv);
135  }
137 
138  private:
139 
141  Range * const invalid_result;
142 
144  Domain * const invalid_solution;
145 
147  Domain * const invalid_update;
148 
151  Range * result;
152 
154  const Domain * solution;
155 
157  const Domain * update;
158 
160  Real b_rr, d_r;
161 
162  }; // end class OneStepLocalJacobianApplyAssemblerEngine
163 
164  } // end namespace PDELab
165 } // end Dune
166 #endif
const Entity & e
Definition: localfunctionspace.hh:121
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
The local assembler engine for UDG sub triangulations which assembles the residual vector.
Definition: enginebase.hh:16
const LocalAssembler & la
Definition: enginebase.hh:459
void setLocalAssemblerEngineDT0(LocalAssemblerEngineDT0 &lae0_)
Definition: enginebase.hh:119
LocalAssemblerEngineDT1 * lae1
Definition: enginebase.hh:462
void setLocalAssemblerEngineDT1(LocalAssemblerEngineDT1 &lae1_)
Definition: enginebase.hh:124
LocalAssemblerEngineDT0 * lae0
Definition: enginebase.hh:461
bool implicit
Definition: enginebase.hh:464
The local assembler engine for one-step methods which applies the jacobian without explicitly assembl...
Definition: onestep/jacobianapplyengine.hh:25
void postAssembly(const GFSU &gfsu, const GFSV &gfsv)
Definition: onestep/jacobianapplyengine.hh:131
void preAssembly()
Definition: onestep/jacobianapplyengine.hh:110
OSLA::Traits::Domain Domain
The type of the solution vector.
Definition: onestep/jacobianapplyengine.hh:51
void setSolution(const Domain &solution_)
Definition: onestep/jacobianapplyengine.hh:73
OSLA::Real Real
The type for real numbers.
Definition: onestep/jacobianapplyengine.hh:54
OSLA::LocalAssemblerDT1 LocalAssemblerDT1
Definition: onestep/jacobianapplyengine.hh:42
void setUpdate(const Domain &update_)
Definition: onestep/jacobianapplyengine.hh:80
LocalAssemblerDT1::LocalJacobianApplyAssemblerEngine JacobianEngineDT1
Definition: onestep/jacobianapplyengine.hh:45
void setWeights()
Definition: onestep/jacobianapplyengine.hh:102
OneStepLocalJacobianApplyAssemblerEngine(LocalAssembler &local_assembler_)
Constructor.
Definition: onestep/jacobianapplyengine.hh:61
LocalAssemblerDT0::LocalJacobianApplyAssemblerEngine JacobianEngineDT0
Definition: onestep/jacobianapplyengine.hh:44
OSLA::LocalAssemblerDT0 LocalAssemblerDT0
Definition: onestep/jacobianapplyengine.hh:41
OSLA::Traits::Range Range
The type of the result vector.
Definition: onestep/jacobianapplyengine.hh:48
void setResult(Range &result_)
Definition: onestep/jacobianapplyengine.hh:87
OSLA LocalAssembler
The type of the wrapping local assembler.
Definition: onestep/jacobianapplyengine.hh:39