2 #ifndef DUNE_PDELAB_LOCALOPERATOR_BLOCKDIAGONAL_HH 3 #define DUNE_PDELAB_LOCALOPERATOR_BLOCKDIAGONAL_HH 8 #include <dune/typetree/traversal.hh> 9 #include <dune/typetree/childextraction.hh> 22 template<
typename LFSV,
typename Operation>
23 struct ApplyBlockOperation
24 :
public TypeTree::TreeVisitor
25 ,
public TypeTree::StaticTraversal
28 template<
typename LeafLFSU,
typename TreePath>
29 void leaf(LeafLFSU& leaf_lfsu, TreePath tree_path)
31 auto& leaf_lfsv = child(_lfsv,tree_path);
32 _operation(tree_path,leaf_lfsu,leaf_lfsv);
35 ApplyBlockOperation(
const LFSV& lfsv, Operation operation)
37 , _operation(operation)
45 template<
typename LFSV,
typename Operation>
46 auto applyBlockOperation(
const LFSV& lfsv, Operation operation)
48 return ApplyBlockOperation<LFSV,Operation>(lfsv,operation);
74 template<
typename ScalarLOP>
84 static constexpr
bool doPatternVolume =
true;
85 static constexpr
bool doAlphaVolume =
true;
89 : _scalar_lop(scalar_lop)
94 : _scalar_lop(scalar_lop)
98 template<
typename... ScalarOperatorArgs>
100 : _scalar_lop(
std::make_shared<ScalarLOP>(
std::forward<ScalarOperatorArgs>(scalarOperatorArgs)...))
103 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename R>
104 void alpha_volume(
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, R& r)
const 106 auto visitor = impl::applyBlockOperation(
108 [&](
auto tree_path,
auto& lfsu,
auto& lfsv)
110 _scalar_lop->alpha_volume(eg,lfsu,x,lfsv,r);
112 TypeTree::applyToTree(lfsu,visitor);
115 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename Y>
118 auto visitor = impl::applyBlockOperation(
120 [&](
auto tree_path,
auto& lfsu,
auto& lfsv)
122 _scalar_lop->jacobian_apply_volume(eg,lfsu,x,lfsv,y);
124 TypeTree::applyToTree(lfsu,visitor);
127 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename M>
128 void jacobian_volume(
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, M& mat)
const 130 auto visitor = impl::applyBlockOperation(
132 [&](
auto tree_path,
auto& lfsu,
auto& lfsv)
134 _scalar_lop->jacobian_volume(eg,lfsu,x,lfsv,mat);
136 TypeTree::applyToTree(lfsu,visitor);
141 _scalar_lop->setTime(t);
146 return _scalar_lop->getTime();
151 _scalar_lop->preStep(time,dt,stages);
156 _scalar_lop->postStep();
161 _scalar_lop->preStage(time,r);
166 return _scalar_lop->getStage();
171 _scalar_lop->postStage();
176 return _scalar_lop->suggestTimeStep(dt);
181 std::shared_ptr<ScalarLOP> _scalar_lop;
190 #endif // DUNE_PDELAB_LOCALOPERATOR_BLOCKDIAGONAL_HH Block diagonal extension of scalar local operator.
Definition: blockdiagonal.hh:75
void postStep()
Definition: blockdiagonal.hh:154
Default flags for all local operators.
Definition: flags.hh:18
sparsity pattern generator
Definition: pattern.hh:13
RealType suggestTimestep(RealType dt) const
Definition: blockdiagonal.hh:174
void alpha_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, R &r) const
Definition: blockdiagonal.hh:104
BlockDiagonalLocalOperatorFullCoupling(ScalarOperatorArgs &&... scalarOperatorArgs)
Constructs the adapter and creates a scalar operator with the given arguments.
Definition: blockdiagonal.hh:99
void jacobian_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, M &mat) const
Definition: blockdiagonal.hh:128
int getStage() const
Definition: blockdiagonal.hh:164
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
BlockDiagonalLocalOperatorFullCoupling(const std::shared_ptr< ScalarLOP > &scalar_lop)
Constructs the adapter by wrapping an existing shared_ptr to the scalar operator. ...
Definition: blockdiagonal.hh:88
RealType getTime() const
Definition: blockdiagonal.hh:144
void preStage(RealType time, int r)
Definition: blockdiagonal.hh:159
void postStage()
Definition: blockdiagonal.hh:169
void jacobian_apply_volume(const EG &eg, const LFSU &lfsu, const X &x, const LFSV &lfsv, Y &y) const
Definition: blockdiagonal.hh:116
void setTime(RealType t)
Definition: blockdiagonal.hh:139
void preStep(RealType time, RealType dt, int stages)
Definition: blockdiagonal.hh:149
BlockDiagonalLocalOperatorFullCoupling(std::shared_ptr< ScalarLOP > &scalar_lop)
Constructs the adapter by wrapping an existing shared_ptr to the scalar operator. ...
Definition: blockdiagonal.hh:93
typename impl::ScalarL2 ::RealType RealType
Definition: blockdiagonal.hh:82