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>
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