Assembler.hpp 2.38 KB
Newer Older
1
2
3
#pragma once

#include <memory>
4
#include <tuple>
5

6
#include <amdis/DirichletBC.hpp>
7
#include <amdis/LocalAssemblerList.hpp>
8
#include <amdis/common/Mpl.hpp>
9
10
11

namespace AMDiS
{
12
  template <class Traits>
13
14
  class Assembler
  {
15
16
    using GlobalBasis = typename Traits::GlobalBasis;

17
    /// The grid view the global FE basis lives on
18
    using GridView = typename GlobalBasis::GridView;
19
20

  public:
21

22
    /// Constructor, stores a shared-pointer to the feSpaces
23
24
    Assembler(GlobalBasis& globalBasis,
              MatrixOperators<GlobalBasis>& matrixOperators,
25
26
              VectorOperators<GlobalBasis>& rhsOperators,
              Constraints<GlobalBasis>& constraints)
27
      : globalBasis_(globalBasis)
28
29
      , matrixOperators_(matrixOperators)
      , rhsOperators_(rhsOperators)
30
      , constraints_(constraints)
31
    {}
32

33
    /// Assemble the linear system
34
    template <class SystemMatrixType, class SystemVectorType>
35
36
37
38
    void assemble(
        SystemMatrixType& matrix,
        SystemVectorType& solution,
        SystemVectorType& rhs,
39
        bool asmMatrix, bool asmVector);
40

41

42
  private:
43

44
    /// Sets the system to zero and initializes all operators and boundary conditions
45
    template <class SystemMatrixType, class SystemVectorType>
46
47
48
49
    void initMatrixVector(
        SystemMatrixType& matrix,
        SystemVectorType& solution,
        SystemVectorType& rhs,
50
        bool asmMatrix, bool asmVector) const;
51

52
53
    /// Assemble operators on an element, by passing the element/intersection to
    /// `elementAssembler` functor.
54
    template <class Element, class Operators, class ElementAssembler>
55
    void assembleElementOperators(
56
        Element const& element,
57
        Operators& operators,
58
        ElementAssembler const& elementAssembler) const;
59
60
61

    /// Finish insertion into the matrix and assembles boundary conditions
    /// Return the number of nonzeros assembled into the matrix
62
    template <class SystemMatrixType, class SystemVectorType>
63
64
65
66
    std::size_t finishMatrixVector(
        SystemMatrixType& matrix,
        SystemVectorType& solution,
        SystemVectorType& rhs,
67
68
        bool asmMatrix, bool asmVector) const;

69

70
  private:
71

72
73
74
    GlobalBasis& globalBasis_;
    MatrixOperators<GlobalBasis>& matrixOperators_;
    VectorOperators<GlobalBasis>& rhsOperators_;
75
    Constraints<GlobalBasis>& constraints_;
76
77

    //TODO: add caching of localBases
78
79
80
  };

} // end namespace AMDiS
81
82

#include "Assembler.inc.hpp"