dune-pdelab  2.4.1
jacobianapplyengine.hh
Go to the documentation of this file.
1 #ifndef DUNE_PDELAB_DEFAULT_APPLYJACOBIANENGINE_HH
2 #define DUNE_PDELAB_DEFAULT_APPLYJACOBIANENGINE_HH
3 
9 
10 namespace Dune{
11  namespace PDELab{
12 
20  template<typename LA>
23  {
24  public:
25 
26  template<typename TrialConstraintsContainer, typename TestConstraintsContainer>
27  bool needsConstraintsCaching(const TrialConstraintsContainer& cu, const TestConstraintsContainer& cv) const
28  {
29  return false;
30  }
31 
33  typedef LA LocalAssembler;
34 
36  typedef typename LA::LocalOperator LOP;
37 
39  typedef typename LA::Traits::Residual Residual;
40  typedef typename Residual::ElementType ResidualElement;
41 
43  typedef typename LA::Traits::Solution Solution;
44  typedef typename Solution::ElementType SolutionElement;
45 
47  typedef typename LA::LFSU LFSU;
48  typedef typename LA::LFSUCache LFSUCache;
49  typedef typename LFSU::Traits::GridFunctionSpace GFSU;
50  typedef typename LA::LFSV LFSV;
51  typedef typename LA::LFSVCache LFSVCache;
52  typedef typename LFSV::Traits::GridFunctionSpace GFSV;
53 
54  typedef typename Solution::template ConstLocalView<LFSUCache> SolutionView;
55  typedef typename Residual::template LocalView<LFSVCache> ResidualView;
56 
63  DefaultLocalJacobianApplyAssemblerEngine(const LocalAssembler & local_assembler_)
64  : local_assembler(local_assembler_), lop(local_assembler_.lop),
65  rl_view(rl,1.0),
66  rn_view(rn,1.0)
67  {}
68 
71  bool requireSkeleton() const
72  { return local_assembler.doAlphaSkeleton(); }
74  { return local_assembler.doSkeletonTwoSided(); }
75  bool requireUVVolume() const
76  { return local_assembler.doAlphaVolume(); }
77  bool requireUVSkeleton() const
78  { return local_assembler.doAlphaSkeleton(); }
79  bool requireUVBoundary() const
80  { return local_assembler.doAlphaBoundary(); }
82  { return local_assembler.doAlphaVolumePostSkeleton(); }
84 
86  const LocalAssembler & localAssembler() const { return local_assembler; }
87 
89  const typename LocalAssembler::Traits::TrialGridFunctionSpaceConstraints& trialConstraints() const
90  {
91  return localAssembler().trialConstraints();
92  }
93 
95  const typename LocalAssembler::Traits::TestGridFunctionSpaceConstraints& testConstraints() const
96  {
97  return localAssembler().testConstraints();
98  }
99 
102  void setResidual(Residual & residual_){
103  global_rl_view.attach(residual_);
104  global_rn_view.attach(residual_);
105  }
106 
109  void setSolution(const Solution & solution_){
110  global_sl_view.attach(solution_);
111  global_sn_view.attach(solution_);
112  }
113 
117  template<typename EG, typename LFSUC, typename LFSVC>
118  void onBindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache){
119  global_sl_view.bind(lfsu_cache);
120  xl.resize(lfsu_cache.size());
121  }
122 
123  template<typename EG, typename LFSVC>
124  void onBindLFSV(const EG & eg, const LFSVC & lfsv_cache){
125  global_rl_view.bind(lfsv_cache);
126  rl.assign(lfsv_cache.size(),0.0);
127  }
128 
129  template<typename IG, typename LFSUC, typename LFSVC>
130  void onBindLFSUVInside(const IG & ig, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache){
131  global_sl_view.bind(lfsu_cache);
132  xl.resize(lfsu_cache.size());
133  }
134 
135  template<typename IG, typename LFSUC, typename LFSVC>
136  void onBindLFSUVOutside(const IG & ig,
137  const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
138  const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
139  {
140  global_sn_view.bind(lfsu_n_cache);
141  xn.resize(lfsu_n_cache.size());
142  }
143 
144  template<typename IG, typename LFSVC>
145  void onBindLFSVInside(const IG & ig, const LFSVC & lfsv_cache){
146  global_rl_view.bind(lfsv_cache);
147  rl.assign(lfsv_cache.size(),0.0);
148  }
149 
150  template<typename IG, typename LFSVC>
151  void onBindLFSVOutside(const IG & ig,
152  const LFSVC & lfsv_s_cache,
153  const LFSVC & lfsv_n_cache)
154  {
155  global_rn_view.bind(lfsv_n_cache);
156  rn.assign(lfsv_n_cache.size(),0.0);
157  }
158 
160 
164  template<typename EG, typename LFSVC>
165  void onUnbindLFSV(const EG & eg, const LFSVC & lfsv_cache){
166  global_rl_view.add(rl);
167  global_rl_view.commit();
168  }
169 
170  template<typename IG, typename LFSVC>
171  void onUnbindLFSVInside(const IG & ig, const LFSVC & lfsv_cache){
172  global_rl_view.add(rl);
173  global_rl_view.commit();
174  }
175 
176  template<typename IG, typename LFSVC>
177  void onUnbindLFSVOutside(const IG & ig,
178  const LFSVC & lfsv_s_cache,
179  const LFSVC & lfsv_n_cache)
180  {
181  global_rn_view.add(rn);
182  global_rn_view.commit();
183  }
185 
188  template<typename LFSUC>
189  void loadCoefficientsLFSUInside(const LFSUC & lfsu_s_cache){
190  global_sl_view.read(xl);
191  }
192  template<typename LFSUC>
193  void loadCoefficientsLFSUOutside(const LFSUC & lfsu_n_cache){
194  global_sn_view.read(xn);
195  }
196  template<typename LFSUC>
197  void loadCoefficientsLFSUCoupling(const LFSUC & lfsu_c_cache)
198  {DUNE_THROW(Dune::NotImplemented,"No coupling lfsu available for ");}
200 
203 
204  void postAssembly(const GFSU& gfsu, const GFSV& gfsv){
205  if(local_assembler.doPostProcessing){
206  Dune::PDELab::constrain_residual(*(local_assembler.pconstraintsv),global_rl_view.container());
207  }
208  }
209 
211 
214 
221  template<typename EG>
222  bool assembleCell(const EG & eg)
223  {
224  return LocalAssembler::isNonOverlapping && eg.entity().partitionType() != Dune::InteriorEntity;
225  }
226 
227  template<typename EG, typename LFSUC, typename LFSVC>
228  void assembleUVVolume(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
229  {
230  rl_view.setWeight(local_assembler.weight);
232  jacobian_apply_volume(lop,eg,lfsu_cache.localFunctionSpace(),xl,lfsv_cache.localFunctionSpace(),rl_view);
233  }
234 
235  template<typename IG, typename LFSUC, typename LFSVC>
236  void assembleUVSkeleton(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
237  const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
238  {
239  rl_view.setWeight(local_assembler.weight);
240  rn_view.setWeight(local_assembler.weight);
243  lfsu_s_cache.localFunctionSpace(),xl,lfsv_s_cache.localFunctionSpace(),
244  lfsu_n_cache.localFunctionSpace(),xn,lfsv_n_cache.localFunctionSpace(),
245  rl_view,rn_view);
246  }
247 
248  template<typename IG, typename LFSUC, typename LFSVC>
249  void assembleUVBoundary(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache)
250  {
251  rl_view.setWeight(local_assembler.weight);
253  jacobian_apply_boundary(lop,ig,lfsu_s_cache.localFunctionSpace(),xl,lfsv_s_cache.localFunctionSpace(),rl_view);
254  }
255 
256  template<typename IG, typename LFSUC, typename LFSVC>
257  static void assembleUVEnrichedCoupling(const IG & ig,
258  const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
259  const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache,
260  const LFSUC & lfsu_coupling_cache, const LFSVC & lfsv_coupling_cache)
261  {DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");}
262 
263  template<typename EG, typename LFSUC, typename LFSVC>
264  void assembleUVVolumePostSkeleton(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
265  {
266  rl_view.setWeight(local_assembler.weight);
268  jacobian_apply_volume_post_skeleton(lop,eg,lfsu_cache.localFunctionSpace(),xl,lfsv_cache.localFunctionSpace(),rl_view);
269  }
270 
272 
273  private:
276  const LocalAssembler & local_assembler;
277 
279  const LOP & lop;
280 
282  ResidualView global_rl_view;
283  ResidualView global_rn_view;
284 
286  SolutionView global_sl_view;
287  SolutionView global_sn_view;
288 
293 
296 
298  SolutionVector xl;
300  SolutionVector xn;
302  ResidualVector rl;
304  ResidualVector rn;
310 
311  }; // End of class DefaultLocalJacobianAssemblerEngine
312 
313  }
314 }
315 #endif
void resize(size_type size)
Resize the container.
Definition: localvector.hh:251
void loadCoefficientsLFSUInside(const LFSUC &lfsu_s_cache)
Definition: jacobianapplyengine.hh:189
WeightedVectorAccumulationView< LocalVector > WeightedAccumulationView
An accumulate-only view of this container that automatically applies a weight to all contributions...
Definition: localvector.hh:198
static void jacobian_apply_volume_post_skeleton(const LA &la, const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, Y &y)
Definition: callswitch.hh:135
Residual::template LocalView< LFSVCache > ResidualView
Definition: jacobianapplyengine.hh:55
static void assembleUVEnrichedCoupling(const IG &ig, const LFSUC &lfsu_s_cache, const LFSVC &lfsv_s_cache, const LFSUC &lfsu_n_cache, const LFSVC &lfsv_n_cache, const LFSUC &lfsu_coupling_cache, const LFSVC &lfsv_coupling_cache)
Definition: jacobianapplyengine.hh:257
const LocalAssembler::Traits::TrialGridFunctionSpaceConstraints & trialConstraints() const
Trial space constraints.
Definition: jacobianapplyengine.hh:89
bool requireUVSkeleton() const
Definition: jacobianapplyengine.hh:77
void loadCoefficientsLFSUCoupling(const LFSUC &lfsu_c_cache)
Definition: jacobianapplyengine.hh:197
bool requireSkeleton() const
Definition: jacobianapplyengine.hh:71
const LocalAssembler::Traits::TestGridFunctionSpaceConstraints & testConstraints() const
Test space constraints.
Definition: jacobianapplyengine.hh:95
void assembleUVSkeleton(const IG &ig, const LFSUC &lfsu_s_cache, const LFSVC &lfsv_s_cache, const LFSUC &lfsu_n_cache, const LFSVC &lfsv_n_cache)
Definition: jacobianapplyengine.hh:236
void assembleUVVolume(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:228
void onBindLFSVInside(const IG &ig, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:145
DefaultLocalJacobianApplyAssemblerEngine(const LocalAssembler &local_assembler_)
Constructor.
Definition: jacobianapplyengine.hh:63
void setWeight(weight_type weight)
Resets the weighting coefficient of the view.
Definition: localvector.hh:72
bool requireSkeletonTwoSided() const
Definition: jacobianapplyengine.hh:73
const IG & ig
Definition: constraints.hh:148
void postAssembly(const GFSU &gfsu, const GFSV &gfsv)
Definition: jacobianapplyengine.hh:204
void onUnbindLFSVOutside(const IG &ig, const LFSVC &lfsv_s_cache, const LFSVC &lfsv_n_cache)
Definition: jacobianapplyengine.hh:177
LFSU::Traits::GridFunctionSpace GFSU
Definition: jacobianapplyengine.hh:49
bool requireUVBoundary() const
Definition: jacobianapplyengine.hh:79
Solution::ElementType SolutionElement
Definition: jacobianapplyengine.hh:44
void onUnbindLFSVInside(const IG &ig, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:171
Definition: adaptivity.hh:27
Residual::ElementType ResidualElement
Definition: jacobianapplyengine.hh:40
LA::LFSV LFSV
Definition: jacobianapplyengine.hh:50
void onBindLFSUVInside(const IG &ig, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:130
void assign(size_type size, const T &value)
Resize the container to size and assign the passed value to all entries.
Definition: localvector.hh:257
LFSV::Traits::GridFunctionSpace GFSV
Definition: jacobianapplyengine.hh:52
void onBindLFSV(const EG &eg, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:124
static void jacobian_apply_volume(const LA &la, const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, Y &y)
Definition: callswitch.hh:131
LA::LFSU LFSU
The local function spaces.
Definition: jacobianapplyengine.hh:47
LA::LFSUCache LFSUCache
Definition: jacobianapplyengine.hh:48
bool assembleCell(const EG &eg)
Definition: jacobianapplyengine.hh:222
LA::Traits::Residual Residual
The type of the residual vector.
Definition: jacobianapplyengine.hh:39
void setResidual(Residual &residual_)
Definition: jacobianapplyengine.hh:102
bool needsConstraintsCaching(const TrialConstraintsContainer &cu, const TestConstraintsContainer &cv) const
Definition: jacobianapplyengine.hh:27
static void jacobian_apply_skeleton(const LA &la, 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)
Definition: callswitch.hh:139
LA LocalAssembler
The type of the wrapping local assembler.
Definition: jacobianapplyengine.hh:33
void setSolution(const Solution &solution_)
Definition: jacobianapplyengine.hh:109
void assembleUVVolumePostSkeleton(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:264
void constrain_residual(const CG &cg, XG &xg)
transform residual into transformed basis: r -> r~
Definition: constraints.hh:906
LA::LocalOperator LOP
The type of the local operator.
Definition: jacobianapplyengine.hh:36
void loadCoefficientsLFSUOutside(const LFSUC &lfsu_n_cache)
Definition: jacobianapplyengine.hh:193
void onBindLFSVOutside(const IG &ig, const LFSVC &lfsv_s_cache, const LFSVC &lfsv_n_cache)
Definition: jacobianapplyengine.hh:151
Definition: localfunctionspacetags.hh:48
Definition: localfunctionspacetags.hh:54
LA::Traits::Solution Solution
The type of the solution vector.
Definition: jacobianapplyengine.hh:43
The local assembler engine for DUNE grids which assembles the local application of the Jacobian...
Definition: jacobianapplyengine.hh:21
static void jacobian_apply_boundary(const LA &la, const IG &ig, const LFSU &lfsu_s, const X &x_s, const LFSV &lfsv_s, Y &y_s)
Definition: callswitch.hh:146
bool requireUVVolume() const
Definition: jacobianapplyengine.hh:75
Base class for LocalAssemblerEngine implementations to avoid boilerplate code.
Definition: localassemblerenginebase.hh:21
void onBindLFSUV(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:118
LA::LFSVCache LFSVCache
Definition: jacobianapplyengine.hh:51
void assembleUVBoundary(const IG &ig, const LFSUC &lfsu_s_cache, const LFSVC &lfsv_s_cache)
Definition: jacobianapplyengine.hh:249
void onUnbindLFSV(const EG &eg, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:165
bool requireUVVolumePostSkeleton() const
Definition: jacobianapplyengine.hh:81
Solution::template ConstLocalView< LFSUCache > SolutionView
Definition: jacobianapplyengine.hh:54
const LocalAssembler & localAssembler() const
Public access to the wrapping local assembler.
Definition: jacobianapplyengine.hh:86
void onBindLFSUVOutside(const IG &ig, const LFSUC &lfsu_s_cache, const LFSVC &lfsv_s_cache, const LFSUC &lfsu_n_cache, const LFSVC &lfsv_n_cache)
Definition: jacobianapplyengine.hh:136