DUNE PDELab (git)

scaled.hh
1// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=8 sw=2 sts=2:
3#ifndef DUNE_PDELAB_LOCALOPERATOR_SCALED_HH
4#define DUNE_PDELAB_LOCALOPERATOR_SCALED_HH
5
6namespace Dune {
7 namespace PDELab {
11
13
33 template<typename Backend, typename Factor, typename Time = double>
35 // do *not* derive from LocalOperatorDefaultFlags -- we need to take care
36 // of all the possible flags ourselves.
37 //
38 // If there is a new flag added to LocalOperatorDefaultFlags, it will
39 // probably be false by default. If we would derive from
40 // LocalOperatorDefaultFlags, we would derive from that flag -- and claim
41 // this flag to be false no matter what the underlying local operator
42 // says. It that flag controls a method that the underlying operator
43 // implements, that method would never get called, and no diagnostic would
44 // be given. The only way to notice this situation would be by noticing
45 // that the solution of the simulation is errornous.
46 //
47 // By not deriving from LocalOperatorDefaultFlags, we do not inherit any
48 // new flags. If anything tries to use this new flag, this will result in
49 // a compilation error. This way the missing implementation in this class
50 // gets noticed, and the flag can be correctly forwarded from the
51 // underlying local operator.
52 //
53 // The same argument applies for not deriving from
54 // InstationaryLocalOperatorDefaultMethods.
55 {
56 Factor factor;
57 Backend* bp;
58
59 public:
61 //
64 //
65
67
71 ScaledLocalOperator(Backend& backend, Factor factor_ = 0)
72 : factor(factor_), bp(&backend) { }
74
80 ScaledLocalOperator(Factor factor_ = 0) : factor(factor_), bp(0) { }
81
83 void setFactor(Factor factor_) { factor = factor_; }
85 Factor getFactor() const { return factor; }
86
88 void setBackend(Backend& backend) { bp = &backend; }
90 Backend& getBackend() const { return *bp; }
91
93
95 //
98 //
99
102 enum { doPatternVolume = Backend::doPatternVolume };
106 enum {
107 doPatternVolumePostSkeleton = Backend::doPatternVolumePostSkeleton
108 };
112 enum { doPatternSkeleton = Backend::doPatternSkeleton };
116 enum { doPatternBoundary = Backend::doPatternBoundary };
117
120 enum { doAlphaVolume = Backend::doAlphaVolume };
125 enum { doAlphaVolumePostSkeleton = Backend::doAlphaVolumePostSkeleton };
128 enum { doAlphaSkeleton = Backend::doAlphaSkeleton };
131 enum { doAlphaBoundary = Backend::doAlphaBoundary };
132
134 enum { doLambdaVolume = Backend::doLambdaVolume };
137 enum {
138 doLambdaVolumePostSkeleton = Backend::doLambdaVolumePostSkeleton
139 };
141 enum { doLambdaSkeleton = Backend::doLambdaSkeleton };
143 enum { doLambdaBoundary = Backend::doLambdaBoundary };
144
146 enum { doSkeletonTwoSided = Backend::doSkeletonTwoSided };
147
149
151 //
154 //
155
157
169 template<typename LFSU, typename LFSV, typename LocalPattern>
171 ( const LFSU& lfsu, const LFSV& lfsv,
172 LocalPattern& pattern) const
173 {
174 if(factor != 0)
175 bp->pattern_volume(lfsu, lfsv, pattern);
176 }
177
180
192 template<typename LFSU, typename LFSV, typename LocalPattern>
194 ( const LFSU& lfsu, const LFSV& lfsv,
195 LocalPattern& pattern) const
196 {
197 if(factor != 0)
198 bp->pattern_volume_post_skeleton(lfsu, lfsv, pattern);
199 }
200
202
222 template<typename LFSU, typename LFSV, typename LocalPattern>
224 ( const LFSU& lfsu_s, const LFSV& lfsv_s,
225 const LFSU& lfsu_n, const LFSV& lfsv_n,
226 LocalPattern& pattern_sn,
227 LocalPattern& pattern_ns) const
228 {
229 if(factor != 0)
230 bp->pattern_skeleton(lfsu_s, lfsv_s, lfsu_n, lfsv_n,
231 pattern_sn, pattern_ns);
232 }
233
235
250 template<typename LFSU, typename LFSV, typename LocalPattern>
252 ( const LFSU& lfsu_s, const LFSV& lfsv_s,
253 LocalPattern& pattern_ss) const
254 {
255 if(factor != 0)
256 bp->pattern_boundary(lfsu_s, lfsv_s, pattern_ss);
257 }
258
260
262 //
265 //
266
268
289 template<typename EG, typename LFSU, typename X, typename LFSV,
290 typename R>
292 ( const EG& eg,
293 const LFSU& lfsu, const X& x, const LFSV& lfsv,
294 R& r) const
295 {
296 if(factor != 0) {
297 typename R::WeightedAccumulationView
298 my_r(r.weightedAccumulationView(factor));
299 bp->alpha_volume(eg, lfsu, x, lfsv, my_r);
300 }
301 }
302
305
327 template<typename EG, typename LFSU, typename X, typename LFSV,
328 typename R>
330 ( const EG& eg,
331 const LFSU& lfsu, const X& x, const LFSV& lfsv,
332 R& r) const
333 {
334 if(factor != 0) {
335 typename R::WeightedAccumulationView
336 my_r(r.weightedAccumulationView(factor));
337 bp->alpha_volume_post_skeleton(eg, lfsu, x, lfsv, my_r);
338 }
339 }
340
342
374 template<typename IG, typename LFSU, typename X, typename LFSV,
375 typename R>
377 ( const IG& ig,
378 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
379 const LFSU& lfsu_n, const X& x_n, const LFSV& lfsv_n,
380 R& r_s, R& r_n) const
381 {
382 if(factor != 0) {
383 typename R::WeightedAccumulationView
384 my_r_s(r_s.weightedAccumulationView(factor));
385 typename R::WeightedAccumulationView
386 my_r_n(r_n.weightedAccumulationView(factor));
387 bp->alpha_skeleton(ig,
388 lfsu_s, x_s, lfsv_s,
389 lfsu_n, x_n, lfsv_n,
390 my_r_s, my_r_n);
391 }
392 }
393
395
420 template<typename IG, typename LFSU, typename X, typename LFSV,
421 typename R>
423 ( const IG& ig,
424 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
425 R& r_s) const
426 {
427 if(factor != 0) {
428 typename R::WeightedAccumulationView
429 my_r_s(r_s.weightedAccumulationView(factor));
430 bp->alpha_boundary(ig, lfsu_s, x_s, lfsv_s, my_r_s);
431 }
432 }
433
435
437 //
440 //
441
443
457 template<typename EG, typename LFSV, typename R>
458 void lambda_volume(const EG& eg, const LFSV& lfsv, R& r) const
459 {
460 if(factor != 0) {
461 typename R::WeightedAccumulationView
462 my_r(r.weightedAccumulationView(factor));
463 bp->lambda_volume(eg, lfsv, my_r);
464 }
465 }
466
469
485 template<typename EG, typename LFSV, typename R>
487 const LFSV& lfsv,
488 R& r) const
489 {
490 if(factor != 0) {
491 typename R::WeightedAccumulationView
492 my_r(r.weightedAccumulationView(factor));
493 bp->lambda_volume_post_skeleton(eg, lfsv, my_r);
494 }
495 }
496
498
518 template<typename IG, typename LFSV, typename R>
519 void lambda_skeleton(const IG& ig,
520 const LFSV& lfsv_s, const LFSV& lfsv_n,
521 R& r_s, R& r_n) const
522 {
523 if(factor != 0) {
524 typename R::WeightedAccumulationView
525 my_r_s(r_s.weightedAccumulationView(factor));
526 typename R::WeightedAccumulationView
527 my_r_n(r_n.weightedAccumulationView(factor));
528 bp->lambda_skeleton(ig, lfsv_s, lfsv_n, my_r_s, my_r_n);
529 }
530 }
531
533
550 template<typename IG, typename LFSV, typename R>
551 void lambda_boundary(const IG& ig, const LFSV& lfsv_s, R& r_s) const
552 {
553 if(factor != 0) {
554 typename R::WeightedAccumulationView
555 my_r_s(r_s.weightedAccumulationView(factor));
556 bp->lambda_boundary(ig, lfsv_s, my_r_s);
557 }
558 }
559
561
563 //
566 //
567
569
594 template<typename EG, typename LFSU, typename X, typename LFSV,
595 typename Y>
597 ( const EG& eg,
598 const LFSU& lfsu, const X& x, const LFSV& lfsv,
599 Y& y) const
600 {
601 if(factor != 0) {
602 typename Y::WeightedAccumulationView
603 my_y(y.weightedAccumulationView(factor));
604 bp->jacobian_apply_volume(eg, lfsu, x, lfsv, my_y);
605 }
606 }
607
610
636 template<typename EG, typename LFSU, typename X, typename LFSV,
637 typename Y>
639 ( const EG& eg,
640 const LFSU& lfsu, const X& x, const LFSV& lfsv,
641 Y& y) const
642 {
643 if(factor != 0) {
644 typename Y::WeightedAccumulationView
645 my_y(y.weightedAccumulationView(factor));
646 bp->jacobian_apply_volume_post_skeleton(eg, lfsu, x, lfsv, my_y);
647 }
648 }
649
651
688 template<typename IG, typename LFSU, typename X, typename LFSV,
689 typename Y>
691 ( const IG& ig,
692 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
693 const LFSU& lfsu_n, const X& x_n, const LFSV& lfsv_n,
694 Y& y_s, Y& y_n) const
695 {
696 if(factor != 0) {
697 typename Y::WeightedAccumulationView
698 my_y_s(y_s.weightedAccumulationView(factor));
699 typename Y::WeightedAccumulationView
700 my_y_n(y_n.weightedAccumulationView(factor));
701 bp->jacobian_apply_skeleton(ig,
702 lfsu_s, x_s, lfsv_s,
703 lfsu_n, x_n, lfsv_n,
704 my_y_s, my_y_n);
705 }
706 }
707
709
738 template<typename IG, typename LFSU, typename X, typename LFSV,
739 typename Y>
741 ( const IG& ig,
742 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
743 Y& y_s) const
744 {
745 if(factor != 0) {
746 typename Y::WeightedAccumulationView
747 my_y_s(y_s.weightedAccumulationView(factor));
748 bp->jacobian_apply_boundary(ig, lfsu_s, x_s, lfsv_s, my_y_s);
749 }
750 }
751
753
755 //
758 //
759
761
777 template<typename EG, typename LFSU, typename X, typename LFSV,
778 typename M>
780 ( const EG& eg,
781 const LFSU& lfsu, const X& x, const LFSV& lfsv,
782 M& mat) const
783 {
784 if(factor != 0) {
785 typename M::WeightedAccumulationView
786 my_mat(mat.weightedAccumulationView(factor));
787 bp->jacobian_volume(eg, lfsu, x, lfsv, my_mat);
788 }
789 }
790
792
809 template<typename EG, typename LFSU, typename X, typename LFSV,
810 typename M>
812 ( const EG& eg,
813 const LFSU& lfsu, const X& x, const LFSV& lfsv,
814 M& mat) const
815 {
816 if(factor != 0) {
817 typename M::WeightedAccumulationView
818 my_mat(mat.weightedAccumulationView(factor));
819 bp->jacobian_volume_post_skeleton(eg, lfsu, x, lfsv, my_mat);
820 }
821 }
822
824
858 template<typename IG, typename LFSU, typename X, typename LFSV,
859 typename M>
861 ( const IG& ig,
862 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
863 const LFSU& lfsu_n, const X& x_n, const LFSV& lfsv_n,
864 M& mat_ss, M& mat_sn, M& mat_ns, M& mat_nn) const
865 {
866 if(factor != 0) {
867 typename M::WeightedAccumulationView
868 my_mat_ss(mat_ss.weightedAccumulationView(factor));
869 typename M::WeightedAccumulationView
870 my_mat_sn(mat_sn.weightedAccumulationView(factor));
871 typename M::WeightedAccumulationView
872 my_mat_ns(mat_ns.weightedAccumulationView(factor));
873 typename M::WeightedAccumulationView
874 my_mat_nn(mat_nn.weightedAccumulationView(factor));
875 bp->jacobian_skeleton(ig,
876 lfsu_s, x_s, lfsv_s,
877 lfsu_n, x_n, lfsv_n,
878 my_mat_ss, my_mat_sn, my_mat_ns, my_mat_nn);
879 }
880 }
881
883
904 template<typename IG, typename LFSU, typename X, typename LFSV,
905 typename M>
907 ( const IG& ig,
908 const LFSU& lfsu_s, const X& x_s, const LFSV& lfsv_s,
909 M& mat_ss) const
910 {
911 if(factor != 0) {
912 typename M::WeightedAccumulationView
913 my_mat_ss(mat_ss.weightedAccumulationView(factor));
914 bp->jacobian_boundary(ig, lfsu_s, x_s, lfsv_s, my_mat_ss);
915 }
916 }
917
919
921 //
924
925 typedef Time RealType;
926
928
936 void setTime (Time t) { bp->setTime(t); }
937
939
942 Time getTime () const { return bp->getTime(); }
943
945
960 void preStep (Time time, Time dt, int stages)
961 { bp->preStep(time, dt, stages); }
962
964
970 void postStep () { bp->postStep(); }
971
973
986 void preStage (Time time, int r) { bp->preStage(time, r); }
987
989
992 int getStage () const { return bp->getStage(); }
993
995 void postStage () { bp->postStage(); }
996
998
1008 Time suggestTimestep (Time dt) const
1009 { return bp->suggestTimestep(dt); }
1010
1012
1013 };
1014
1016 }
1017}
1018
1019#endif // DUNE_PDELAB_LOCALOPERATOR_SCALED_HH
A local operator that scales the result of another local operator.
Definition: scaled.hh:55
void pattern_volume_post_skeleton(const LFSU &lfsu, const LFSV &lfsv, LocalPattern &pattern) const
get an element's contribution to the sparsity pattern after the intersections have been handled
Definition: scaled.hh:194
int getStage() const
get current stage
Definition: scaled.hh:992
ScaledLocalOperator(Backend &backend, Factor factor_=0)
construct a ScaledLocalOperator
Definition: scaled.hh:71
void lambda_boundary(const IG &ig, const LFSV &lfsv_s, R &r_s) const
get a boundary intersections's contribution to lambda
Definition: scaled.hh:551
ScaledLocalOperator(Factor factor_=0)
construct a ScaledLocalOperator
Definition: scaled.hh:80
void jacobian_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, M &mat) const
get an element's jacobian
Definition: scaled.hh:780
void jacobian_skeleton(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, M &mat_ss, M &mat_sn, M &mat_ns, M &mat_nn) const
apply an internal intersections's jacobians
Definition: scaled.hh:861
void pattern_volume(const LFSU &lfsu, const LFSV &lfsv, LocalPattern &pattern) const
get an element's contribution to the sparsity pattern
Definition: scaled.hh:171
void lambda_skeleton(const IG &ig, const LFSV &lfsv_s, const LFSV &lfsv_n, R &r_s, R &r_n) const
get an internal intersections's contribution to lambda
Definition: scaled.hh:519
Backend & getBackend() const
get a reference to the backend
Definition: scaled.hh:90
void jacobian_volume_post_skeleton(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, M &mat) const
get an element's jacobian after the intersections have been handled
Definition: scaled.hh:812
void jacobian_apply_boundary(const IG &ig, const LFSU &lfsu_s, const X &x_s, const LFSV &lfsv_s, Y &y_s) const
apply a boundary intersections's jacobian
Definition: scaled.hh:741
void jacobian_boundary(const IG &ig, const LFSU &lfsu_s, const X &x_s, const LFSV &lfsv_s, M &mat_ss) const
get a boundary intersections's jacobian
Definition: scaled.hh:907
void setBackend(Backend &backend)
set the backend
Definition: scaled.hh:88
void lambda_volume_post_skeleton(const EG &eg, const LFSV &lfsv, R &r) const
get an element's contribution to lambda after the intersections have been handled
Definition: scaled.hh:486
void setFactor(Factor factor_)
set the scaling factor
Definition: scaled.hh:83
void preStep(Time time, Time dt, int stages)
to be called once before each time step
Definition: scaled.hh:960
void pattern_boundary(const LFSU &lfsu_s, const LFSV &lfsv_s, LocalPattern &pattern_ss) const
get a boundary intersection's contribution to the sparsity pattern
Definition: scaled.hh:252
void jacobian_apply_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, Y &y) const
apply an element's jacobian
Definition: scaled.hh:597
void postStage()
to be called once at the end of each stage
Definition: scaled.hh:995
void lambda_volume(const EG &eg, const LFSV &lfsv, R &r) const
get an element's contribution to lambda
Definition: scaled.hh:458
void alpha_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, R &r) const
get an element's contribution to alpha
Definition: scaled.hh:292
void alpha_skeleton(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, R &r_s, R &r_n) const
get an internal intersections's contribution to alpha
Definition: scaled.hh:377
void alpha_boundary(const IG &ig, const LFSU &lfsu_s, const X &x_s, const LFSV &lfsv_s, R &r_s) const
get a boundary intersections's contribution to alpha
Definition: scaled.hh:423
void postStep()
to be called once at the end of each time step
Definition: scaled.hh:970
Factor getFactor() const
get the scaling factor
Definition: scaled.hh:85
Time suggestTimestep(Time dt) const
to be called after stage 1
Definition: scaled.hh:1008
void pattern_skeleton(const LFSU &lfsu_s, const LFSV &lfsv_s, const LFSU &lfsu_n, const LFSV &lfsv_n, LocalPattern &pattern_sn, LocalPattern &pattern_ns) const
get an internal intersection's contribution to the sparsity pattern
Definition: scaled.hh:224
void jacobian_apply_skeleton(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) const
apply an internal intersections's jacobians
Definition: scaled.hh:691
void alpha_volume_post_skeleton(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, R &r) const
get an element's contribution to alpha after the intersections have been handled
Definition: scaled.hh:330
void setTime(Time t)
set time for subsequent evaluation
Definition: scaled.hh:936
void jacobian_apply_volume_post_skeleton(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, Y &y) const
apply an element's jacobian after the intersections have been handled
Definition: scaled.hh:639
Time getTime() const
get current time
Definition: scaled.hh:942
void preStage(Time time, int r)
to be called once before each stage
Definition: scaled.hh:986
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)