AMDiS  2.10
The Adaptive Multi-Dimensional Simulation Toolbox
OperatorAdapter.hpp
1 #pragma once
2 
3 #include <dune/typetree/childextraction.hh>
4 
5 namespace AMDiS
6 {
8  template <class LocalOperator, class RowTreePath, class ColTreePath = RowTreePath>
10  {
11  public:
13  LocalOperatorAdapter(LocalOperator const& lop, RowTreePath rowTp, ColTreePath colTp = {})
14  : lop_(lop)
15  , rowTp_(rowTp)
16  , colTp_(colTp)
17  {}
18 
20 
23  template <class Element>
24  void bind(Element const& element)
25  {
26  lop_.bind(element);
27  }
28 
30  void unbind()
31  {
32  lop_.unbind();
33  }
34 
36 
42  template <class ContextGeo, class RowNode, class ColNode, class Mat>
43  void assemble(ContextGeo const& cg, RowNode const& row, ColNode const& col, Mat& mat) const
44  {
45  using Dune::TypeTree::child;
46  lop_.assemble(cg,child(row,rowTp_),child(col,colTp_),mat);
47  }
48 
50 
55  template <class ContextGeo, class Node, class Vec>
56  void assemble(ContextGeo const& cg, Node const& node, Vec& vec) const
57  {
58  using Dune::TypeTree::child;
59  lop_.assemble(cg,child(node,rowTp_),vec);
60  }
61 
62  private:
63  LocalOperator lop_;
64  RowTreePath rowTp_;
65  ColTreePath colTp_;
66  };
67 
68 
77  template <class Operator, class RowTreePath, class ColTreePath = RowTreePath>
79  {
80  public:
82  OperatorAdapter(Operator op, RowTreePath rowTp, ColTreePath colTp = {})
83  : op_(std::move(op))
84  , rowTp_(rowTp)
85  , colTp_(colTp)
86  {}
87 
89  template <class GridView>
90  void update(GridView const& gv)
91  {
92  op_.update(gv);
93  }
94 
96  friend auto localOperator(OperatorAdapter const& adapter)
97  {
98  return LocalOperatorAdapter{localOperator(adapter.op_),adapter.rowTp_,adapter.colTp_};
99  }
100 
101  private:
102  Operator op_;
103  RowTreePath rowTp_;
104  ColTreePath colTp_;
105  };
106 
107 } // end namespace AMDiS
friend auto localOperator(OperatorAdapter const &adapter)
Transform an operator into a local-operator.
Definition: OperatorAdapter.hpp:96
The local operator associated to the OperatorAdapter.
Definition: OperatorAdapter.hpp:9
void bind(Element const &element)
Binds the local operator to an element.
Definition: OperatorAdapter.hpp:24
The base class for an operator to be used in an Assembler.
Definition: Operator.hpp:78
void assemble(ContextGeo const &cg, Nodes const &... ns, MatVec &mv) const
Assemble a local element matrix or vector on the element that is bound.
Definition: LocalOperator.hpp:123
Definition: AdaptBase.hpp:6
OperatorAdapter(Operator op, RowTreePath rowTp, ColTreePath colTp={})
Constructor, stores all the arguments in local variables.
Definition: OperatorAdapter.hpp:82
void bind(Element const &element)
Binds the local operator to an element.
Definition: LocalOperator.hpp:106
The base class for a local operator to be used in a Assembler.
Definition: LocalOperator.hpp:73
void assemble(ContextGeo const &cg, RowNode const &row, ColNode const &col, Mat &mat) const
Assemble a local element matrix on the element that is bound.
Definition: OperatorAdapter.hpp:43
void update(GridView const &gv)
Update the wrapped operator on a GridView.
Definition: OperatorAdapter.hpp:90
LocalOperatorAdapter(LocalOperator const &lop, RowTreePath rowTp, ColTreePath colTp={})
Constructor, stores all the arguments in local variables.
Definition: OperatorAdapter.hpp:13
void unbind()
Unbinds operator from element.
Definition: LocalOperator.hpp:112
void assemble(ContextGeo const &cg, Node const &node, Vec &vec) const
Assemble a local element vector on the element that is bound.
Definition: OperatorAdapter.hpp:56
void unbind()
Unbinds operator from element.
Definition: OperatorAdapter.hpp:30
Wraps an operator that is bound to some tree path (rwo,col) and transforms it into an operator that a...
Definition: OperatorAdapter.hpp:78