dune-pdelab  2.7-git
fastdg/residualengine.hh
Go to the documentation of this file.
1 #ifndef DUNE_PDELAB_GRIDOPERATOR_FASTDG_RESIDUALENGINE_HH
2 #define DUNE_PDELAB_GRIDOPERATOR_FASTDG_RESIDUALENGINE_HH
3 
10 
11 namespace Dune{
12  namespace PDELab{
13 
21  template<typename LA>
24  {
25  public:
26 
27  template<typename TrialConstraintsContainer, typename TestConstraintsContainer>
28  bool needsConstraintsCaching(const TrialConstraintsContainer& cu, const TestConstraintsContainer& cv) const
29  {
30  return false;
31  }
32 
34  typedef LA LocalAssembler;
35 
37  typedef typename LA::LocalOperator LOP;
38 
40  typedef typename LA::Traits::Residual Residual;
41  typedef typename Residual::ElementType ResidualElement;
42 
44  typedef typename LA::Traits::Solution Solution;
45  typedef typename Solution::ElementType SolutionElement;
46 
48  typedef typename LA::LFSU LFSU;
49  typedef typename LA::LFSUCache LFSUCache;
50  typedef typename LFSU::Traits::GridFunctionSpace GFSU;
51  typedef typename LA::LFSV LFSV;
52  typedef typename LA::LFSVCache LFSVCache;
53  typedef typename LFSV::Traits::GridFunctionSpace GFSV;
54 
55  typedef typename Solution::template ConstAliasedLocalView<LFSUCache> SolutionView;
56  typedef typename Residual::template AliasedLocalView<LFSVCache> ResidualView;
57 
65  : local_assembler(local_assembler_),
66  lop(local_assembler_.localOperator())
67  //rl_view(rl,1.0),
68  //rn_view(rn,1.0)
69  {}
70 
72 
86  (const FastDGLocalResidualAssemblerEngine &other) :
87  local_assembler(other.local_assembler), lop(other.lop),
88  global_rl_view(other.global_rl_view),
89  global_rn_view(other.global_rn_view),
90  global_sl_view(other.global_sl_view),
91  global_sn_view(other.global_sn_view)
92  //rl_view(rl,1.0),
93  //rn_view(rn,1.0)
94  { }
95 
98  bool requireSkeleton() const
99  { return ( local_assembler.doAlphaSkeleton() || local_assembler.doLambdaSkeleton() ); }
101  { return local_assembler.doSkeletonTwoSided(); }
102  bool requireUVVolume() const
103  { return local_assembler.doAlphaVolume(); }
104  bool requireVVolume() const
105  { return local_assembler.doLambdaVolume(); }
106  bool requireUVSkeleton() const
107  { return local_assembler.doAlphaSkeleton(); }
108  bool requireVSkeleton() const
109  { return local_assembler.doLambdaSkeleton(); }
110  bool requireUVBoundary() const
111  { return local_assembler.doAlphaBoundary(); }
112  bool requireVBoundary() const
113  { return local_assembler.doLambdaBoundary(); }
115  { return local_assembler.doAlphaVolumePostSkeleton(); }
117  { return local_assembler.doLambdaVolumePostSkeleton(); }
119 
122  {
123  return local_assembler;
124  }
125 
127  const typename LocalAssembler::Traits::TrialGridFunctionSpaceConstraints& trialConstraints() const
128  {
129  return localAssembler().trialConstraints();
130  }
131 
133  const typename LocalAssembler::Traits::TestGridFunctionSpaceConstraints& testConstraints() const
134  {
135  return localAssembler().testConstraints();
136  }
137 
140  void setResidual(Residual & residual_)
141  {
142  global_rl_view.attach(residual_);
143  global_rn_view.attach(residual_);
144  }
145 
148  void setSolution(const Solution & solution_)
149  {
150  global_sl_view.attach(solution_);
151  global_sn_view.attach(solution_);
152  }
153 
157  template<typename EG, typename LFSUC, typename LFSVC>
158  void onBindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
159  {
160  global_sl_view.bind(lfsu_cache);
161  //xl.resize(lfsu_cache.size());
162  }
163 
164  template<typename EG, typename LFSVC>
165  void onBindLFSV(const EG & eg, const LFSVC & lfsv_cache)
166  {
167  global_rl_view.bind(lfsv_cache);
168  //rl.assign(lfsv_cache.size(),0.0);
169  }
170 
171  template<typename IG, typename LFSUC, typename LFSVC>
172  void onBindLFSUVInside(const IG & ig, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
173  {
174  global_sl_view.bind(lfsu_cache);
175  //xl.resize(lfsu_cache.size());
176  }
177 
178  template<typename IG, typename LFSUC, typename LFSVC>
179  void onBindLFSUVOutside(const IG & ig,
180  const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
181  const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
182  {
183  global_sn_view.bind(lfsu_n_cache);
184  //xn.resize(lfsu_n_cache.size());
185  }
186 
187  template<typename IG, typename LFSVC>
188  void onBindLFSVInside(const IG & ig, const LFSVC & lfsv_cache)
189  {
190  global_rl_view.bind(lfsv_cache);
191  //rl.assign(lfsv_cache.size(),0.0);
192  }
193 
194  template<typename IG, typename LFSVC>
195  void onBindLFSVOutside(const IG & ig,
196  const LFSVC & lfsv_s_cache,
197  const LFSVC & lfsv_n_cache)
198  {
199  global_rn_view.bind(lfsv_n_cache);
200  //rn.assign(lfsv_n_cache.size(),0.0);
201  }
202 
204 
208  template<typename EG, typename LFSVC>
209  void onUnbindLFSV(const EG & eg, const LFSVC & lfsv_cache)
210  {
211  //global_rl_view.add(rl);
212  global_rl_view.unbind();
213  global_rl_view.commit();
214  }
215 
216  template<typename IG, typename LFSVC>
217  void onUnbindLFSVInside(const IG & ig, const LFSVC & lfsv_cache)
218  {
219  //global_rl_view.add(rl);
220  global_rl_view.commit();
221  global_rl_view.unnbind();
222  }
223 
224  template<typename IG, typename LFSVC>
225  void onUnbindLFSVOutside(const IG & ig,
226  const LFSVC & lfsv_s_cache,
227  const LFSVC & lfsv_n_cache)
228  {
229  //global_rn_view.add(rn);
230  global_rn_view.commit();
231  global_rn_view.unbind();
232  }
234 
237  template<typename LFSUC>
238  void loadCoefficientsLFSUInside(const LFSUC & lfsu_s_cache)
239  {
240  //global_sl_view.read(xl);
241  }
242  template<typename LFSUC>
243  void loadCoefficientsLFSUOutside(const LFSUC & lfsu_n_cache)
244  {
245  //global_sn_view.read(xn);
246  }
247  template<typename LFSUC>
248  void loadCoefficientsLFSUCoupling(const LFSUC & lfsu_c_cache)
249  {
250  DUNE_THROW(Dune::NotImplemented,"No coupling lfsu available for ");
251  }
253 
256 
257  void postAssembly(const GFSU& gfsu, const GFSV& gfsv)
258  {
259  if(local_assembler.doPostProcessing())
260  Dune::PDELab::constrain_residual(local_assembler.testConstraints(),
261  global_rl_view.container());
262 
263  }
264 
266 
269 
270 
277  template <typename EG> bool skipEntity(const EG &eg)
278  {
279  return localAssembler().skipEntity(eg) ||
280  (LocalAssembler::isNonOverlapping &&
281  eg.entity().partitionType() != Dune::InteriorEntity);
282  }
283 
290  template<typename IG>
291  bool skipIntersection(const IG & ig)
292  {
293  return localAssembler().skipIntersection(ig);
294  }
295 
296  template<typename EG, typename LFSUC, typename LFSVC>
297  void assembleUVVolume(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
298  {
299  //rl_view.setWeight(local_assembler.weight());
300  global_rl_view.setWeight(local_assembler.weight());
302  alpha_volume(lop,eg,lfsu_cache.localFunctionSpace(),global_sl_view,lfsv_cache.localFunctionSpace(),global_rl_view);
303  }
304 
305  template<typename EG, typename LFSVC>
306  void assembleVVolume(const EG & eg, const LFSVC & lfsv_cache)
307  {
308  //rl_view.setWeight(local_assembler.weight());
309  global_rl_view.setWeight(local_assembler.weight());
311  lambda_volume(lop,eg,lfsv_cache.localFunctionSpace(),global_rl_view);
312  }
313 
314  template<typename IG, typename LFSUC, typename LFSVC>
315  void assembleUVSkeleton(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
316  const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
317  {
318  //rl_view.setWeight(local_assembler.weight());
319  //rn_view.setWeight(local_assembler.weight());
320  global_rl_view.setWeight(local_assembler.weight());
321  global_rn_view.setWeight(local_assembler.weight());
323  alpha_skeleton(lop,ig,
324  lfsu_s_cache.localFunctionSpace(),global_sl_view,lfsv_s_cache.localFunctionSpace(),
325  lfsu_n_cache.localFunctionSpace(),global_sn_view,lfsv_n_cache.localFunctionSpace(),
326  global_rl_view,global_rn_view);
327  }
328 
329  template<typename IG, typename LFSVC>
330  void assembleVSkeleton(const IG & ig, const LFSVC & lfsv_s_cache, const LFSVC & lfsv_n_cache)
331  {
332  //rl_view.setWeight(local_assembler.weight());
333  //rn_view.setWeight(local_assembler.weight());
334  global_rl_view.setWeight(local_assembler.weight());
335  global_rn_view.setWeight(local_assembler.weight());
337  lambda_skeleton(lop, ig, lfsv_s_cache.localFunctionSpace(), lfsv_n_cache.localFunctionSpace(), global_rl_view, global_rn_view);
338  }
339 
340  template<typename IG, typename LFSUC, typename LFSVC>
341  void assembleUVBoundary(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache)
342  {
343  //rl_view.setWeight(local_assembler.weight());
344  global_rl_view.setWeight(local_assembler.weight());
346  alpha_boundary(lop,ig,lfsu_s_cache.localFunctionSpace(),global_sl_view,lfsv_s_cache.localFunctionSpace(),global_rl_view);
347  }
348 
349  template<typename IG, typename LFSVC>
350  void assembleVBoundary(const IG & ig, const LFSVC & lfsv_s_cache)
351  {
352  //rl_view.setWeight(local_assembler.weight());
353  global_rl_view.setWeight(local_assembler.weight());
355  lambda_boundary(lop,ig,lfsv_s_cache.localFunctionSpace(),global_rl_view);
356  }
357 
358  template<typename IG, typename LFSUC, typename LFSVC>
359  static void assembleUVEnrichedCoupling(const IG & ig,
360  const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
361  const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache,
362  const LFSUC & lfsu_coupling_cache, const LFSVC & lfsv_coupling_cache)
363  {
364  DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
365  }
366 
367  template<typename IG, typename LFSVC>
368  static void assembleVEnrichedCoupling(const IG & ig,
369  const LFSVC & lfsv_s_cache,
370  const LFSVC & lfsv_n_cache,
371  const LFSVC & lfsv_coupling_cache)
372  {
373  DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
374  }
375 
376  template<typename EG, typename LFSUC, typename LFSVC>
377  void assembleUVVolumePostSkeleton(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
378  {
379  //rl_view.setWeight(local_assembler.weight());
380  global_rl_view.setWeight(local_assembler.weight());
382  alpha_volume_post_skeleton(lop,eg,lfsu_cache.localFunctionSpace(),global_sl_view,lfsv_cache.localFunctionSpace(),global_rl_view);
383  }
384 
385  template<typename EG, typename LFSVC>
386  void assembleVVolumePostSkeleton(const EG & eg, const LFSVC & lfsv_cache)
387  {
388  //rl_view.setWeight(local_assembler.weight());
389  global_rl_view.setWeight(local_assembler.weight());
391  lambda_volume_post_skeleton(lop,eg,lfsv_cache.localFunctionSpace(),global_rl_view);
392  }
393 
395 
396  private:
399  const LocalAssembler & local_assembler;
400 
402  const LOP & lop;
403 
405  ResidualView global_rl_view;
406  ResidualView global_rn_view;
407 
409  SolutionView global_sl_view;
410  SolutionView global_sn_view;
411 
414  typedef Dune::PDELab::TrialSpaceTag LocalTrialSpaceTag;
415  typedef Dune::PDELab::TestSpaceTag LocalTestSpaceTag;
416 
419 
421  //typename ResidualVector::WeightedAccumulationView rl_view;
423  //typename ResidualVector::WeightedAccumulationView rn_view;
425 
426  }; // End of class FastDGLocalResidualAssemblerEngine
427 
428  }
429 }
430 #endif
const IG & ig
Definition: constraints.hh:149
void constrain_residual(const CG &cg, XG &xg)
transform residual into transformed basis: r -> r~
Definition: constraints.hh:904
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Impl::LocalAssemblerCallSwitchHelper< LOP, doIt > LocalAssemblerCallSwitch
Definition: callswitch.hh:407
Definition: localfunctionspacetags.hh:48
Definition: localfunctionspacetags.hh:54
Base class for LocalAssemblerEngine implementations to avoid boilerplate code.
Definition: localassemblerenginebase.hh:22
The fast DG local assembler engine for DUNE grids which assembles the residual vector.
Definition: fastdg/residualengine.hh:24
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: fastdg/residualengine.hh:179
LA::LFSVCache LFSVCache
Definition: fastdg/residualengine.hh:52
bool requireVBoundary() const
Definition: fastdg/residualengine.hh:112
LA::Traits::Residual Residual
The type of the residual vector.
Definition: fastdg/residualengine.hh:40
LA::Traits::Solution Solution
The type of the solution vector.
Definition: fastdg/residualengine.hh:44
void setSolution(const Solution &solution_)
Definition: fastdg/residualengine.hh:148
LA LocalAssembler
The type of the wrapping local assembler.
Definition: fastdg/residualengine.hh:34
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: fastdg/residualengine.hh:315
void assembleUVVolumePostSkeleton(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: fastdg/residualengine.hh:377
void onBindLFSUV(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: fastdg/residualengine.hh:158
LA::LFSV LFSV
Definition: fastdg/residualengine.hh:51
LA::LFSUCache LFSUCache
Definition: fastdg/residualengine.hh:49
LFSU::Traits::GridFunctionSpace GFSU
Definition: fastdg/residualengine.hh:50
bool requireUVSkeleton() const
Definition: fastdg/residualengine.hh:106
const LocalAssembler::Traits::TrialGridFunctionSpaceConstraints & trialConstraints() const
Trial space constraints.
Definition: fastdg/residualengine.hh:127
bool requireSkeleton() const
Definition: fastdg/residualengine.hh:98
const LocalAssembler::Traits::TestGridFunctionSpaceConstraints & testConstraints() const
Test space constraints.
Definition: fastdg/residualengine.hh:133
bool needsConstraintsCaching(const TrialConstraintsContainer &cu, const TestConstraintsContainer &cv) const
Definition: fastdg/residualengine.hh:28
void assembleVVolumePostSkeleton(const EG &eg, const LFSVC &lfsv_cache)
Definition: fastdg/residualengine.hh:386
void loadCoefficientsLFSUCoupling(const LFSUC &lfsu_c_cache)
Definition: fastdg/residualengine.hh:248
bool requireVVolumePostSkeleton() const
Definition: fastdg/residualengine.hh:116
void setResidual(Residual &residual_)
Definition: fastdg/residualengine.hh:140
bool requireUVVolume() const
Definition: fastdg/residualengine.hh:102
void assembleUVVolume(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: fastdg/residualengine.hh:297
void onUnbindLFSV(const EG &eg, const LFSVC &lfsv_cache)
Definition: fastdg/residualengine.hh:209
FastDGLocalResidualAssemblerEngine(const LocalAssembler &local_assembler_)
Constructor.
Definition: fastdg/residualengine.hh:64
void assembleVBoundary(const IG &ig, const LFSVC &lfsv_s_cache)
Definition: fastdg/residualengine.hh:350
void assembleVVolume(const EG &eg, const LFSVC &lfsv_cache)
Definition: fastdg/residualengine.hh:306
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: fastdg/residualengine.hh:359
void onBindLFSVInside(const IG &ig, const LFSVC &lfsv_cache)
Definition: fastdg/residualengine.hh:188
Solution::template ConstAliasedLocalView< LFSUCache > SolutionView
Definition: fastdg/residualengine.hh:55
void onBindLFSUVInside(const IG &ig, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: fastdg/residualengine.hh:172
bool requireVSkeleton() const
Definition: fastdg/residualengine.hh:108
Residual::ElementType ResidualElement
Definition: fastdg/residualengine.hh:41
bool requireVVolume() const
Definition: fastdg/residualengine.hh:104
LFSV::Traits::GridFunctionSpace GFSV
Definition: fastdg/residualengine.hh:53
LA::LFSU LFSU
The local function spaces.
Definition: fastdg/residualengine.hh:48
bool requireSkeletonTwoSided() const
Definition: fastdg/residualengine.hh:100
void onUnbindLFSVOutside(const IG &ig, const LFSVC &lfsv_s_cache, const LFSVC &lfsv_n_cache)
Definition: fastdg/residualengine.hh:225
void onBindLFSV(const EG &eg, const LFSVC &lfsv_cache)
Definition: fastdg/residualengine.hh:165
void loadCoefficientsLFSUInside(const LFSUC &lfsu_s_cache)
Definition: fastdg/residualengine.hh:238
const LocalAssembler & localAssembler() const
Public access to the wrapping local assembler.
Definition: fastdg/residualengine.hh:121
Solution::ElementType SolutionElement
Definition: fastdg/residualengine.hh:45
void loadCoefficientsLFSUOutside(const LFSUC &lfsu_n_cache)
Definition: fastdg/residualengine.hh:243
void assembleVSkeleton(const IG &ig, const LFSVC &lfsv_s_cache, const LFSVC &lfsv_n_cache)
Definition: fastdg/residualengine.hh:330
bool skipIntersection(const IG &ig)
Definition: fastdg/residualengine.hh:291
void assembleUVBoundary(const IG &ig, const LFSUC &lfsu_s_cache, const LFSVC &lfsv_s_cache)
Definition: fastdg/residualengine.hh:341
void onUnbindLFSVInside(const IG &ig, const LFSVC &lfsv_cache)
Definition: fastdg/residualengine.hh:217
void postAssembly(const GFSU &gfsu, const GFSV &gfsv)
Definition: fastdg/residualengine.hh:257
bool requireUVBoundary() const
Definition: fastdg/residualengine.hh:110
FastDGLocalResidualAssemblerEngine(const FastDGLocalResidualAssemblerEngine &other)
copy contructor
Definition: fastdg/residualengine.hh:86
bool requireUVVolumePostSkeleton() const
Definition: fastdg/residualengine.hh:114
static void assembleVEnrichedCoupling(const IG &ig, const LFSVC &lfsv_s_cache, const LFSVC &lfsv_n_cache, const LFSVC &lfsv_coupling_cache)
Definition: fastdg/residualengine.hh:368
void onBindLFSVOutside(const IG &ig, const LFSVC &lfsv_s_cache, const LFSVC &lfsv_n_cache)
Definition: fastdg/residualengine.hh:195
LA::LocalOperator LOP
The type of the local operator.
Definition: fastdg/residualengine.hh:37
bool skipEntity(const EG &eg)
Definition: fastdg/residualengine.hh:277
Residual::template AliasedLocalView< LFSVCache > ResidualView
Definition: fastdg/residualengine.hh:56