DUNE PDELab (2.7)

residualengine.hh
1#ifndef DUNE_PDELAB_GRIDOPERATOR_FASTDG_RESIDUALENGINE_HH
2#define DUNE_PDELAB_GRIDOPERATOR_FASTDG_RESIDUALENGINE_HH
3
5#include <dune/pdelab/gridoperator/common/gridoperatorutilities.hh>
6#include <dune/pdelab/gridoperator/common/assemblerutilities.hh>
7#include <dune/pdelab/gridoperator/common/localassemblerenginebase.hh>
8#include <dune/pdelab/constraints/common/constraints.hh>
9#include <dune/pdelab/localoperator/callswitch.hh>
10
11namespace 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
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() ); }
100 bool requireSkeletonTwoSided() const
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(); }
114 bool requireUVVolumePostSkeleton() const
115 { return local_assembler.doAlphaVolumePostSkeleton(); }
116 bool requireVVolumePostSkeleton() const
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
276 template<typename EG>
277 bool assembleCell(const EG & eg)
278 {
279 return LocalAssembler::isNonOverlapping && eg.entity().partitionType() != Dune::InteriorEntity;
280 }
281
282 template<typename EG, typename LFSUC, typename LFSVC>
283 void assembleUVVolume(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
284 {
285 //rl_view.setWeight(local_assembler.weight());
286 global_rl_view.setWeight(local_assembler.weight());
287 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolume>::
288 alpha_volume(lop,eg,lfsu_cache.localFunctionSpace(),global_sl_view,lfsv_cache.localFunctionSpace(),global_rl_view);
289 }
290
291 template<typename EG, typename LFSVC>
292 void assembleVVolume(const EG & eg, const LFSVC & lfsv_cache)
293 {
294 //rl_view.setWeight(local_assembler.weight());
295 global_rl_view.setWeight(local_assembler.weight());
296 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doLambdaVolume>::
297 lambda_volume(lop,eg,lfsv_cache.localFunctionSpace(),global_rl_view);
298 }
299
300 template<typename IG, typename LFSUC, typename LFSVC>
301 void assembleUVSkeleton(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
302 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
303 {
304 //rl_view.setWeight(local_assembler.weight());
305 //rn_view.setWeight(local_assembler.weight());
306 global_rl_view.setWeight(local_assembler.weight());
307 global_rn_view.setWeight(local_assembler.weight());
308 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaSkeleton>::
309 alpha_skeleton(lop,ig,
310 lfsu_s_cache.localFunctionSpace(),global_sl_view,lfsv_s_cache.localFunctionSpace(),
311 lfsu_n_cache.localFunctionSpace(),global_sn_view,lfsv_n_cache.localFunctionSpace(),
312 global_rl_view,global_rn_view);
313 }
314
315 template<typename IG, typename LFSVC>
316 void assembleVSkeleton(const IG & ig, const LFSVC & lfsv_s_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());
322 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doLambdaSkeleton>::
323 lambda_skeleton(lop, ig, lfsv_s_cache.localFunctionSpace(), lfsv_n_cache.localFunctionSpace(), global_rl_view, global_rn_view);
324 }
325
326 template<typename IG, typename LFSUC, typename LFSVC>
327 void assembleUVBoundary(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache)
328 {
329 //rl_view.setWeight(local_assembler.weight());
330 global_rl_view.setWeight(local_assembler.weight());
331 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaBoundary>::
332 alpha_boundary(lop,ig,lfsu_s_cache.localFunctionSpace(),global_sl_view,lfsv_s_cache.localFunctionSpace(),global_rl_view);
333 }
334
335 template<typename IG, typename LFSVC>
336 void assembleVBoundary(const IG & ig, const LFSVC & lfsv_s_cache)
337 {
338 //rl_view.setWeight(local_assembler.weight());
339 global_rl_view.setWeight(local_assembler.weight());
340 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doLambdaBoundary>::
341 lambda_boundary(lop,ig,lfsv_s_cache.localFunctionSpace(),global_rl_view);
342 }
343
344 template<typename IG, typename LFSUC, typename LFSVC>
345 static void assembleUVEnrichedCoupling(const IG & ig,
346 const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
347 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache,
348 const LFSUC & lfsu_coupling_cache, const LFSVC & lfsv_coupling_cache)
349 {
350 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
351 }
352
353 template<typename IG, typename LFSVC>
354 static void assembleVEnrichedCoupling(const IG & ig,
355 const LFSVC & lfsv_s_cache,
356 const LFSVC & lfsv_n_cache,
357 const LFSVC & lfsv_coupling_cache)
358 {
359 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
360 }
361
362 template<typename EG, typename LFSUC, typename LFSVC>
363 void assembleUVVolumePostSkeleton(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
364 {
365 //rl_view.setWeight(local_assembler.weight());
366 global_rl_view.setWeight(local_assembler.weight());
367 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolumePostSkeleton>::
368 alpha_volume_post_skeleton(lop,eg,lfsu_cache.localFunctionSpace(),global_sl_view,lfsv_cache.localFunctionSpace(),global_rl_view);
369 }
370
371 template<typename EG, typename LFSVC>
372 void assembleVVolumePostSkeleton(const EG & eg, const LFSVC & lfsv_cache)
373 {
374 //rl_view.setWeight(local_assembler.weight());
375 global_rl_view.setWeight(local_assembler.weight());
376 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doLambdaVolumePostSkeleton>::
377 lambda_volume_post_skeleton(lop,eg,lfsv_cache.localFunctionSpace(),global_rl_view);
378 }
379
381
382 private:
385 const LocalAssembler & local_assembler;
386
388 const LOP & lop;
389
391 ResidualView global_rl_view;
392 ResidualView global_rn_view;
393
395 SolutionView global_sl_view;
396 SolutionView global_sn_view;
397
400 typedef Dune::PDELab::TrialSpaceTag LocalTrialSpaceTag;
401 typedef Dune::PDELab::TestSpaceTag LocalTestSpaceTag;
402
405
407 //typename ResidualVector::WeightedAccumulationView rl_view;
409 //typename ResidualVector::WeightedAccumulationView rn_view;
411
412 }; // End of class FastDGLocalResidualAssemblerEngine
413
414 }
415}
416#endif
Default exception for dummy implementations.
Definition: exceptions.hh:261
The fast DG local assembler engine for DUNE grids which assembles the residual vector.
Definition: residualengine.hh:24
LA::Traits::Residual Residual
The type of the residual vector.
Definition: residualengine.hh:40
LA::Traits::Solution Solution
The type of the solution vector.
Definition: residualengine.hh:44
void setSolution(const Solution &solution_)
Definition: residualengine.hh:148
LA LocalAssembler
The type of the wrapping local assembler.
Definition: residualengine.hh:34
void onBindLFSUV(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: residualengine.hh:158
bool assembleCell(const EG &eg)
Definition: residualengine.hh:277
bool requireSkeleton() const
Definition: residualengine.hh:98
const LocalAssembler::Traits::TestGridFunctionSpaceConstraints & testConstraints() const
Test space constraints.
Definition: residualengine.hh:133
void setResidual(Residual &residual_)
Definition: residualengine.hh:140
void onUnbindLFSV(const EG &eg, const LFSVC &lfsv_cache)
Definition: residualengine.hh:209
FastDGLocalResidualAssemblerEngine(const LocalAssembler &local_assembler_)
Constructor.
Definition: residualengine.hh:64
LA::LFSU LFSU
The local function spaces.
Definition: residualengine.hh:48
void loadCoefficientsLFSUInside(const LFSUC &lfsu_s_cache)
Definition: residualengine.hh:238
void postAssembly(const GFSU &gfsu, const GFSV &gfsv)
Definition: residualengine.hh:257
FastDGLocalResidualAssemblerEngine(const FastDGLocalResidualAssemblerEngine &other)
copy contructor
Definition: residualengine.hh:86
LA::LocalOperator LOP
The type of the local operator.
Definition: residualengine.hh:37
const LocalAssembler::Traits::TrialGridFunctionSpaceConstraints & trialConstraints() const
Trial space constraints.
Definition: residualengine.hh:127
const LocalAssembler & localAssembler() const
Public access to the wrapping local assembler.
Definition: residualengine.hh:121
Base class for LocalAssemblerEngine implementations to avoid boilerplate code.
Definition: localassemblerenginebase.hh:22
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
@ InteriorEntity
all interior entities
Definition: gridenums.hh:29
void constrain_residual(const CG &cg, XG &xg)
transform residual into transformed basis: r -> r~
Definition: constraints.hh:904
Dune namespace.
Definition: alignedallocator.hh:14
Definition: localfunctionspacetags.hh:54
Definition: localfunctionspacetags.hh:48
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)