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>
11#include <dune/pdelab/localoperator/flags.hh>
12#include <dune/pdelab/localoperator/pattern.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>
82 using RealType =
typename ScalarLOP::RealType;
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);
115 template<
typename EG,
typename LFSU,
typename X,
typename LFSV,
typename Y>
116 void jacobian_apply_volume(
const EG& eg,
const LFSU& lfsu,
const X& x,
const LFSV& lfsv, Y& y)
const
118 auto visitor = impl::applyBlockOperation(
120 [&](
auto tree_path,
auto& lfsu,
auto& lfsv)
122 _scalar_lop->jacobian_apply_volume(eg,lfsu,x,lfsv,y);
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);
139 void setTime(RealType t)
141 _scalar_lop->setTime(t);
144 RealType getTime()
const
146 return _scalar_lop->getTime();
149 void preStep(RealType time, RealType dt,
int stages)
151 _scalar_lop->preStep(time,dt,stages);
156 _scalar_lop->postStep();
159 void preStage(RealType time,
int r)
161 _scalar_lop->preStage(time,r);
166 return _scalar_lop->getStage();
171 _scalar_lop->postStage();
174 RealType suggestTimestep(RealType dt)
const
176 return _scalar_lop->suggestTimeStep(dt);
181 std::shared_ptr<ScalarLOP> _scalar_lop;
Block diagonal extension of scalar local operator.
Definition: blockdiagonal.hh:78
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
BlockDiagonalLocalOperatorFullCoupling(std::shared_ptr< ScalarLOP > &scalar_lop)
Constructs the adapter by wrapping an existing shared_ptr to the scalar operator.
Definition: blockdiagonal.hh:93
BlockDiagonalLocalOperatorFullCoupling(ScalarOperatorArgs &&... scalarOperatorArgs)
Constructs the adapter and creates a scalar operator with the given arguments.
Definition: blockdiagonal.hh:99
sparsity pattern generator
Definition: pattern.hh:14
Default flags for all local operators.
Definition: flags.hh:19
void applyToTree(Tree &&tree, Visitor &&visitor)
Apply visitor to TypeTree.
Definition: traversal.hh:237
Dune namespace.
Definition: alignedallocator.hh:11