1#ifndef DUNE_PDELAB_GRIDOPERATOR_ONESTEP_PRESTAGEENGINE_HH
2#define DUNE_PDELAB_GRIDOPERATOR_ONESTEP_PRESTAGEENGINE_HH
4#include <dune/pdelab/gridoperator/onestep/enginebase.hh>
18 template<
typename OSLA>
21 typename OSLA::LocalAssemblerDT0::LocalResidualAssemblerEngine,
22 typename OSLA::LocalAssemblerDT1::LocalResidualAssemblerEngine
27 typename OSLA::LocalAssemblerDT0::LocalResidualAssemblerEngine,
28 typename OSLA::LocalAssemblerDT1::LocalResidualAssemblerEngine
34 using BaseT::implicit;
35 using BaseT::setLocalAssemblerEngineDT0;
36 using BaseT::setLocalAssemblerEngineDT1;
45 typedef typename OSLA::LocalAssemblerDT1 LocalAssemblerDT1;
47 typedef typename LocalAssemblerDT0::LocalResidualAssemblerEngine ResidualEngineDT0;
48 typedef typename LocalAssemblerDT1::LocalResidualAssemblerEngine ResidualEngineDT1;
52 typedef typename OSLA::Traits::Residual
Residual;
53 typedef typename Residual::ElementType ResidualElement;
56 typedef typename OSLA::Traits::Solution
Solution;
57 typedef typename Solution::ElementType SolutionElement;
60 typedef typename OSLA::Real
Real;
73 , invalid_residual(nullptr)
74 , invalid_solutions(nullptr)
75 , const_residual_0(invalid_residual)
76 , const_residual_1(invalid_residual)
77 , solutions(invalid_solutions)
83 {
return lae0->requireSkeleton() || lae1->requireSkeleton(); }
90 solutions = &solutions_;
97 const_residual_0 = &const_residual_0_;
98 const_residual_1 = &const_residual_1_;
101 assert(solutions != invalid_solutions);
102 setLocalAssemblerEngineDT0(la.la0.localResidualAssemblerEngine(*const_residual_0,*((*solutions)[0])));
103 setLocalAssemblerEngineDT1(la.la1.localResidualAssemblerEngine(*const_residual_1,*((*solutions)[0])));
110 const_residual_0 = &const_residual_;
111 const_residual_1 = &const_residual_;
114 assert(solutions != invalid_solutions);
115 setLocalAssemblerEngineDT0(la.la0.localResidualAssemblerEngine(*const_residual_0,*((*solutions)[0])));
116 setLocalAssemblerEngineDT1(la.la1.localResidualAssemblerEngine(*const_residual_1,*((*solutions)[0])));
125 template<
typename EG,
typename LFSU,
typename LFSV>
126 void onBindLFSUV(
const EG& eg,
const LFSU& lfsu,
const LFSV& lfsv)
128 template<
typename IG,
typename LFSU_S,
typename LFSV_S>
129 void onBindLFSUVInside(
const IG & ig,
130 const LFSU_S & lfsu_s,
const LFSV_S & lfsv_s)
132 template<
typename IG,
typename LFSU_S,
typename LFSV_S,
typename LFSU_N,
typename LFSV_N>
133 void onBindLFSUVOutside(
const IG & ig,
134 const LFSU_S & lfsu_s,
const LFSV_S & lfsv_s,
135 const LFSU_N & lfsu_n,
const LFSV_N & lfsv_n)
145 template<
typename LFSU>
148 template<
typename LFSU>
149 void loadCoefficientsLFSUOutside(
const LFSU & lfsu_n)
151 template<
typename LFSU>
152 void loadCoefficientsLFSUCoupling(
const LFSU & lfsu_c)
161 la.la1.setTime(la.time+la.osp_method->d(la.stage)*la.dt);
171 *const_residual_0 = 0.0;
172 *const_residual_1 = 0.0;
178 do0.resize(la.stage);
179 do1.resize(la.stage);
180 for (
int i=0; i<la.stage; ++i){
181 a[i] = la.osp_method->a(la.stage,i);
182 b[i] = la.osp_method->b(la.stage,i);
183 d[i] = la.osp_method->d(i);
184 do0[i] = ( std::abs(b[i]) > 1E-6 );
185 do1[i] = ( std::abs(a[i]) > 1E-6 );
189 la.la0.preStage(la.time+la.osp_method->d(la.stage)*la.dt,la.stage);
190 la.la1.preStage(la.time+la.osp_method->d(la.stage)*la.dt,la.stage);
193 template<
typename GFSU,
typename GFSV>
194 void postAssembly(
const GFSU& gfsu,
const GFSV& gfsv)
196 lae0->postAssembly(gfsu,gfsv);
197 lae1->postAssembly(gfsu,gfsv);
204 template<
typename EG,
typename LFSU,
typename LFSV>
207 for (
int s=0; s<la.stage; ++s)
210 la.la0.setTime(la.time+d[s]*la.dt);
211 la.la1.setTime(la.time+d[s]*la.dt);
215 lae0->setSolution(*((*solutions)[s]));
216 lae0->onBindLFSUV(eg,lfsu,lfsv);
217 lae0->loadCoefficientsLFSUInside(lfsu);
218 la.la0.setWeight(b[s]*la.dt_factor0);
219 lae0->assembleUVVolume(eg,lfsu,lfsv);
224 lae1->setSolution(*((*solutions)[s]));
225 lae1->onBindLFSUV(eg,lfsu,lfsv);
226 lae1->loadCoefficientsLFSUInside(lfsu);
227 la.la1.setWeight(a[s]*la.dt_factor1);
228 lae1->assembleUVVolume(eg,lfsu,lfsv);
233 template<
typename EG,
typename LFSV>
234 void assembleVVolume(
const EG & eg,
const LFSV & lfsv)
236 for (
int s=0; s<la.stage; ++s)
239 la.la0.setTime(la.time+d[s]*la.dt);
240 la.la1.setTime(la.time+d[s]*la.dt);
244 la.la0.setWeight(b[s]*la.dt_factor0);
245 lae0->assembleVVolume(eg,lfsv);
250 la.la1.setWeight(a[s]*la.dt_factor1);
251 lae1->assembleVVolume(eg,lfsv);
257 template<
typename IG,
typename LFSU_S,
typename LFSV_S,
typename LFSU_N,
typename LFSV_N>
258 void assembleUVSkeleton(
const IG & ig,
const LFSU_S & lfsu_s,
const LFSV_S & lfsv_s,
259 const LFSU_N & lfsu_n,
const LFSV_N & lfsv_n)
261 for (
int s=0; s<la.stage; ++s)
264 la.la0.setTime(la.time+d[s]*la.dt);
265 la.la1.setTime(la.time+d[s]*la.dt);
269 la.la0.setWeight(b[s]*la.dt_factor0);
270 lae0->setSolution(*((*solutions)[s]));
271 lae0->onBindLFSUVInside(ig,lfsu_s,lfsv_s);
272 lae0->onBindLFSUVOutside(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n);
273 lae0->loadCoefficientsLFSUInside(lfsu_s);
274 lae0->loadCoefficientsLFSUOutside(lfsu_n);
275 la.la0.setWeight(b[s]*la.dt_factor0);
276 lae0->assembleUVSkeleton(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n);
281 la.la1.setWeight(a[s]*la.dt_factor1);
282 lae1->setSolution(*((*solutions)[s]));
283 lae1->onBindLFSUVInside(ig,lfsu_s,lfsv_s);
284 lae1->onBindLFSUVOutside(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n);
285 lae1->loadCoefficientsLFSUInside(lfsu_s);
286 lae1->loadCoefficientsLFSUOutside(lfsu_n);
287 la.la1.setWeight(a[s]*la.dt_factor1);
288 lae1->assembleUVSkeleton(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n);
293 template<
typename IG,
typename LFSV_S,
typename LFSV_N>
294 void assembleVSkeleton(
const IG & ig,
const LFSV_S & lfsv_s,
const LFSV_N & lfsv_n)
296 for (
int s=0; s<la.stage; ++s)
299 la.la0.setTime(la.time+d[s]*la.dt);
300 la.la1.setTime(la.time+d[s]*la.dt);
304 la.la0.setWeight(b[s]*la.dt_factor0);
305 lae0->assembleVSkeleton(ig,lfsv_s,lfsv_n);
310 la.la1.setWeight(a[s]*la.dt_factor1);
311 lae1->assembleVSkeleton(ig,lfsv_s,lfsv_n);
316 template<
typename IG,
typename LFSU_S,
typename LFSV_S>
317 void assembleUVBoundary(
const IG & ig,
const LFSU_S & lfsu_s,
const LFSV_S & lfsv_s)
319 for (
int s=0; s<la.stage; ++s)
322 la.la0.setTime(la.time+d[s]*la.dt);
323 la.la1.setTime(la.time+d[s]*la.dt);
327 lae0->setSolution(*((*solutions)[s]));
328 lae0->onBindLFSUVInside(ig,lfsu_s,lfsv_s);
329 lae0->loadCoefficientsLFSUInside(lfsu_s);
330 la.la0.setWeight(b[s]*la.dt_factor0);
331 lae0->assembleUVBoundary(ig,lfsu_s,lfsv_s);
336 lae1->setSolution(*((*solutions)[s]));
337 lae1->onBindLFSUVInside(ig,lfsu_s,lfsv_s);
338 lae1->loadCoefficientsLFSUInside(lfsu_s);
339 la.la1.setWeight(a[s]*la.dt_factor1);
340 lae1->assembleUVBoundary(ig,lfsu_s,lfsv_s);
345 template<
typename IG,
typename LFSV_S>
346 void assembleVBoundary(
const IG & ig,
const LFSV_S & lfsv_s)
348 for (
int s=0; s<la.stage; ++s)
351 la.la0.setTime(la.time+d[s]*la.dt);
352 la.la1.setTime(la.time+d[s]*la.dt);
356 la.la0.setWeight(b[s]*la.dt_factor0);
357 lae0->assembleVBoundary(ig,lfsv_s);
362 la.la1.setWeight(a[s]*la.dt_factor1);
363 lae1->assembleVBoundary(ig,lfsv_s);
368 template<
typename IG,
typename LFSU_S,
typename LFSV_S>
369 void assembleUVProcessor(
const IG & ig,
const LFSU_S & lfsu_s,
const LFSV_S & lfsv_s)
371 for (
int s=0; s<la.stage; ++s)
374 la.la0.setTime(la.time+d[s]*la.dt);
375 la.la1.setTime(la.time+d[s]*la.dt);
379 lae0->setSolution(*((*solutions)[s]));
380 lae0->onBindLFSUVInside(ig,lfsu_s,lfsv_s);
381 lae0->loadCoefficientsLFSUInside(lfsu_s);
382 la.la0.setWeight(b[s]*la.dt_factor0);
383 lae0->assembleUVProcessor(ig,lfsu_s,lfsv_s);
388 lae1->setSolution(*((*solutions)[s]));
389 lae1->onBindLFSUVInside(ig,lfsu_s,lfsv_s);
390 lae1->loadCoefficientsLFSUInside(lfsu_s);
391 la.la1.setWeight(a[s]*la.dt_factor1);
392 lae1->assembleUVProcessor(ig,lfsu_s,lfsv_s);
397 template<
typename IG,
typename LFSV_S>
398 void assembleVProcessor(
const IG & ig,
const LFSV_S & lfsv_s)
400 for (
int s=0; s<la.stage; ++s)
403 la.la0.setTime(la.time+d[s]*la.dt);
404 la.la1.setTime(la.time+d[s]*la.dt);
408 la.la0.setWeight(b[s]*la.dt_factor0);
409 lae0->assembleVProcessor(ig,lfsv_s);
414 la.la1.setWeight(a[s]*la.dt_factor1);
415 lae1->assembleVProcessor(ig,lfsv_s);
420 template<
typename IG,
typename LFSU_S,
typename LFSV_S,
typename LFSU_N,
typename LFSV_N,
421 typename LFSU_C,
typename LFSV_C>
422 void assembleUVEnrichedCoupling(
const IG & ig,
423 const LFSU_S & lfsu_s,
const LFSV_S & lfsv_s,
424 const LFSU_N & lfsu_n,
const LFSV_N & lfsv_n,
425 const LFSU_C & lfsu_c,
const LFSV_C & lfsv_c)
427 for (
int s=0; s<la.stage; ++s)
430 la.la0.setTime(la.time+d[s]*la.dt);
431 la.la1.setTime(la.time+d[s]*la.dt);
435 lae0->setSolution(*((*solutions)[s]));
436 lae0->loadCoefficientsLFSUInside(lfsu_s);
437 lae0->loadCoefficientsLFSUOutside(lfsu_n);
438 lae0->loadCoefficientsLFSUCoupling(lfsu_c);
439 la.la0.setWeight(b[s]*la.dt_factor0);
440 lae0->assembleUVEnrichedCoupling(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n,lfsu_c,lfsv_c);
445 lae1->setSolution(*((*solutions)[s]));
446 lae1->loadCoefficientsLFSUInside(lfsu_s);
447 lae1->loadCoefficientsLFSUOutside(lfsu_n);
448 lae1->loadCoefficientsLFSUCoupling(lfsu_c);
449 la.la1.setWeight(a[s]*la.dt_factor1);
450 lae1->assembleUVEnrichedCoupling(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n,lfsu_c,lfsv_c);
455 template<
typename IG,
typename LFSV_S,
typename LFSV_N,
typename LFSV_C>
456 void assembleVEnrichedCoupling(
const IG & ig,
457 const LFSV_S & lfsv_s,
458 const LFSV_N & lfsv_n,
459 const LFSV_C & lfsv_c)
461 for (
int s=0; s<la.stage; ++s)
464 la.la0.setTime(la.time+d[s]*la.dt);
465 la.la1.setTime(la.time+d[s]*la.dt);
469 la.la0.setWeight(b[s]*la.dt_factor0);
470 lae0->assembleVEnrichedCoupling(ig,lfsv_s,lfsv_n,lfsv_c);
475 la.la1.setWeight(a[s]*la.dt_factor1);
476 lae1->assembleVEnrichedCoupling(ig,lfsv_s,lfsv_n,lfsv_c);
482 template<
typename EG,
typename LFSU,
typename LFSV>
483 void assembleUVVolumePostSkeleton(
const EG & eg,
const LFSU & lfsu,
const LFSV & lfsv)
485 for (
int s=0; s<la.stage; ++s)
488 la.la0.setTime(la.time+d[s]*la.dt);
489 la.la1.setTime(la.time+d[s]*la.dt);
493 lae0->setSolution(*((*solutions)[s]));
494 lae0->onBindLFSUV(eg,lfsu,lfsv);
495 lae0->loadCoefficientsLFSUInside(lfsu);
496 la.la0.setWeight(b[s]*la.dt_factor0);
497 lae0->assembleUVVolumePostSkeleton(eg,lfsu,lfsv);
502 lae1->setSolution(*((*solutions)[s]));
503 lae1->onBindLFSUV(eg,lfsu,lfsv);
504 lae1->loadCoefficientsLFSUInside(lfsu);
505 la.la1.setWeight(a[s]*la.dt_factor1);
506 lae1->assembleUVVolumePostSkeleton(eg,lfsu,lfsv);
512 template<
typename EG,
typename LFSV>
513 void assembleVVolumePostSkeleton(
const EG & eg,
const LFSV & lfsv)
515 for (
int s=0; s<la.stage; ++s)
518 la.la0.setTime(la.time+d[s]*la.dt);
519 la.la1.setTime(la.time+d[s]*la.dt);
523 la.la0.setWeight(b[s]*la.dt_factor0);
524 lae0->assembleVVolumePostSkeleton(eg,lfsv);
529 la.la1.setWeight(a[s]*la.dt_factor1);
530 lae1->assembleVVolumePostSkeleton(eg,lfsv);
559 std::vector<bool> do0;
560 std::vector<bool> do1;
The local assembler engine for UDG sub triangulations which assembles the residual vector.
Definition: enginebase.hh:16
const LocalAssembler & la
Definition: enginebase.hh:472
The local assembler engine for one step methods which assembles the constant part of the residual vec...
Definition: prestageengine.hh:24
void setSolutions(const Solutions &solutions_)
Definition: prestageengine.hh:88
std::vector< Solution * > Solutions
The type of the solution container.
Definition: prestageengine.hh:63
OSLA::Traits::Solution Solution
The type of the solution vector.
Definition: prestageengine.hh:56
void loadCoefficientsLFSUInside(const LFSU &lfsu_s)
Definition: prestageengine.hh:146
void assembleUVVolume(const EG &eg, const LFSU &lfsu, const LFSV &lfsv)
Definition: prestageengine.hh:205
OneStepLocalPreStageAssemblerEngine(LocalAssembler &la_)
Constructor.
Definition: prestageengine.hh:71
OSLA::Real Real
The type for real numbers.
Definition: prestageengine.hh:60
void onBindLFSUV(const EG &eg, const LFSU &lfsu, const LFSV &lfsv)
Definition: prestageengine.hh:126
bool requireSkeleton() const
Definition: prestageengine.hh:82
OSLA::Traits::Residual Residual
The type of the residual vector.
Definition: prestageengine.hh:52
void preAssembly()
Definition: prestageengine.hh:166
void setConstResiduals(Residual &const_residual_0_, Residual &const_residual_1_)
Definition: prestageengine.hh:95
OSLA LocalAssembler
The type of the wrapping local assembler.
Definition: prestageengine.hh:40
OSLA::LocalAssemblerDT0 LocalAssemblerDT0
Definition: prestageengine.hh:44
void setTimeInLastStage()
Definition: prestageengine.hh:159
void setConstResidual(Residual &const_residual_)
Definition: prestageengine.hh:108
Dune namespace.
Definition: alignedallocator.hh:13