LocalAssemblerList.hpp 3.79 KB
Newer Older
1
2
3
4
5
#pragma once

#include <list>
#include <memory>

6
#include <amdis/Boundary.hpp>
7
8
9
10
11
#include <amdis/LocalAssemblerBase.hpp>
#include <amdis/utility/TreeData.hpp>

namespace AMDiS
{
12
13
14
15
16
17
18
  namespace tag
  {
    template <class E> struct element_operator { using type = E; };
    template <class I> struct intersection_operator { using type = I; };
    template <class I> struct boundary_operator { using type = I; BoundaryType id; };
  }

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  template <class GridView>
  class OperatorLists
  {
    using Element = typename GridView::template Codim<0>::Entity;
    using Intersection = typename GridView::Intersection;

    template <class OperatorType>
    struct DataElement
    {
      std::shared_ptr<OperatorType> op;
      BoundaryType b = {0};
    };

    /// Lists of \ref DataElement on the Element, BoundaryIntersction, and InteriorIntersections
    template <class... Nodes>
    struct Data
    {
      /// The type of local operators associated with grid elements
      using ElementOperator = LocalAssemblerBase<Element, Nodes...>;
      /// The type of local operators associated with grid intersections
      using IntersectionOperator = LocalAssemblerBase<Intersection, Nodes...>;

      /// Return whether any operators are stored on the node
      bool empty() const
      {
        return element.empty() && boundary.empty() && intersection.empty();
      }

      /// Test whether to assemble on the node
48
      bool doAssemble() const
49
      {
50
        return !assembled || changing;
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
      }

      /// Bind all operators to the grid element and geometry
      template <class Geo>
      void bind(Element const& elem, Geo const& geo)
      {
        for (auto& scaled : element) scaled.op->bind(elem,geo);
        for (auto& scaled : boundary) scaled.op->bind(elem,geo);
        for (auto& scaled : intersection) scaled.op->bind(elem,geo);
      }

      /// Unbind all operators from the element
      void unbind()
      {
        for (auto& scaled : element) scaled.op->unbind();
        for (auto& scaled : boundary) scaled.op->unbind();
        for (auto& scaled : intersection) scaled.op->unbind();
      }

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

      template <class... Args>
      void push(tag::element_operator<Element>, Args&&... args)
      {
        element.push_back({std::forward<Args>(args)...});
      }

      template <class... Args>
      void push(tag::boundary_operator<Intersection> b, Args&&... args)
      {
        boundary.push_back({std::forward<Args>(args)..., b.id});
      }

      template <class... Args>
      void push(tag::intersection_operator<Intersection>, Args&&... args)
      {
        intersection.push_back({std::forward<Args>(args)...});
      }


90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
      /// List of operators to be assembled on grid elements
      std::list<DataElement<ElementOperator>> element;
      /// List of operators to be assembled on boundary intersections
      std::list<DataElement<IntersectionOperator>> boundary;
      /// List of operators to be assembled on interior intersections
      std::list<DataElement<IntersectionOperator>> intersection;

      /// if false, do reassemble of all operators
      bool assembled = false;

      /// if true, or \ref assembled false, do reassemble of all operators
      bool changing = false;
    };

  public:

    /// List of operators associated with matrix blocks (RowNode, ColNode)
    template <class RowNode, class ColNode>
    using MatData = Data<RowNode, ColNode>;

    /// List of operators associated with vector blocks [Node]
    template <class Node>
    using VecData = Data<Node>;
  };


116
117
  template <class RowBasis, class ColBasis>
  using MatrixOperators = MatrixData<RowBasis, ColBasis, OperatorLists<typename RowBasis::GridView>::template MatData>;
118
119
120
121
122

  template <class GlobalBasis>
  using VectorOperators = VectorData<GlobalBasis, OperatorLists<typename GlobalBasis::GridView>::template VecData>;

} // end namespace AMDiS