AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
OperatorList.hpp
1 #pragma once
2 
3 #include <list>
4 #include <memory>
5 
6 #include <amdis/BoundarySubset.hpp>
7 #include <amdis/AssemblerInterface.hpp>
8 #include <amdis/typetree/TreeContainer.hpp>
9 
10 namespace AMDiS
11 {
12  namespace tag
13  {
14  template <class E> struct element_operator { using type = E; };
15  template <class I> struct intersection_operator { using type = I; };
16  template <class I> struct boundary_operator : public BoundarySubset<I>
17  {
18  using type = I;
20  };
21  }
22 
23  template <class GridView, class Container>
25  {
26  using Element = typename GridView::template Codim<0>::Entity;
27  using Intersection = typename GridView::Intersection;
28 
29  template <class Op>
30  struct DataElement
31  {
32  std::shared_ptr<Op> op;
34  };
35 
37  template <class... Nodes>
38  struct Data
39  {
41  bool empty() const
42  {
43  return element_.empty() && boundary_.empty() && intersection_.empty();
44  }
45 
47  bool doAssemble() const
48  {
49  return !assembled_ || changing_;
50  }
51 
52  operator bool() const
53  {
54  return doAssemble() && !empty();
55  }
56 
58  template <class Geo>
59  void bind(Element const& elem, Geo const& geo)
60  {
61  for (auto& op : element_) op->bind(elem,geo);
62  for (auto& op : intersection_) op->bind(elem,geo);
63  for (auto& data : boundary_) data.op->bind(elem,geo);
64  }
65 
67  void unbind()
68  {
69  for (auto& op : element_) op->unbind();
70  for (auto& op : intersection_) op->unbind();
71  for (auto& data : boundary_) data.op->unbind();
72  assembled_ = true;
73  }
74 
75 
76  template <class Op>
77  void push(tag::element_operator<Element>, Op&& op)
78  {
79  element_.emplace_back(FWD(op));
80  }
81 
82  template <class Op>
84  {
85  intersection_.emplace_back(FWD(op));
86  }
87 
88  template <class Op>
89  void push(tag::boundary_operator<Intersection> b, Op&& op)
90  {
91  boundary_.push_back({FWD(op), b});
92  }
93 
94 
95  auto& onElement() { return element_; }
96  auto const& onElement() const { return element_; }
97 
98  auto& onIntersection() { return intersection_; }
99  auto const& onIntersection() const { return intersection_; }
100 
101  auto& onBoundary() { return boundary_; }
102  auto const& onBoundary() const { return boundary_; }
103 
104  private:
105  using ElementTraits = DefaultAssemblerTraits<Element,Container>;
106  using IntersectionTraits = DefaultAssemblerTraits<Intersection,Container>;
107 
109  using ElementAssembler = AssemblerInterface<ElementTraits, Nodes...>;
110 
112  using IntersectionAssembler = AssemblerInterface<IntersectionTraits, Nodes...>;
113 
115  std::vector<std::shared_ptr<ElementAssembler>> element_;
116 
118  std::vector<std::shared_ptr<IntersectionAssembler>> intersection_;
119 
121  std::vector<DataElement<IntersectionAssembler>> boundary_;
122 
124  bool assembled_ = false;
125 
127  bool changing_ = true;
128  };
129 
130  public:
131 
133  template <class RowNode, class ColNode>
134  using MatData = Data<RowNode, ColNode>;
135 
137  template <class Node>
138  using VecData = Data<Node>;
139  };
140 
141 
142  template <class RowBasis, class ColBasis, class ElementMatrix>
143  using MatrixOperators
144  = TypeTree::TreeMatrix<
146  typename RowBasis::LocalView::TreeCache,
147  typename ColBasis::LocalView::TreeCache>;
148 
149  template <class Basis, class ElementVector>
150  using VectorOperators
151  = TypeTree::TreeContainer<
153  typename Basis::LocalView::TreeCache>;
154 
155 } // end namespace AMDiS
Class defining a subset of a domain boundary.
Definition: BoundarySubset.hpp:22
Data< RowNode, ColNode > MatData
List of operators associated with matrix blocks (RowNode, ColNode)
Definition: OperatorList.hpp:134
Definition: OperatorList.hpp:24
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
Definition: OperatorList.hpp:16
Data< Node > VecData
List of operators associated with vector blocks [Node].
Definition: OperatorList.hpp:138
Definition: AssemblerInterface.hpp:13
Abstract base-class of a Assembler.
Definition: AssemblerInterface.hpp:21
Definition: OperatorList.hpp:14
Definition: OperatorList.hpp:15