AssemblerInterface.hpp 1.69 KB
Newer Older
1
2
3
4
#pragma once

#include <type_traits>

5
6
#include <dune/common/dynmatrix.hh>
#include <dune/common/dynvector.hh>
7

8
#include <amdis/ContextGeometry.hpp>
9
10
11

namespace AMDiS
{
12
  /// Abstract base-class of a \ref Assembler
13
  template <class LocalContext, class... Nodes>
14
  class AssemblerInterface
15
  {
16
17
    using ContextType = Impl::ContextTypes<LocalContext>;

18
  public:
19
    /// The codim=0 grid entity
20
    using Element = typename ContextType::Entity;
21
    /// The geometry of the \ref Element
22
23
24
25
26
27
    using Geometry = typename Element::Geometry;

    static constexpr int numNodes = sizeof...(Nodes);
    static_assert( numNodes == 1 || numNodes == 2,
      "VectorAssembler gets 1 Node, MatrixAssembler gets 2 Nodes!");

28
29
    using ElementMatrix = Dune::DynamicMatrix<double>; // TODO: choose correct value_type
    using ElementVector = Dune::DynamicVector<double>;
30

31
    /// Either an ElementVector or an ElementMatrix (depending on the number of nodes)
32
    using ElementMatrixVector = std::conditional_t<
33
34
      (sizeof...(Nodes)==1), ElementVector, std::conditional_t<
      (sizeof...(Nodes)==2), ElementMatrix, void>>;
35
36

  public:
37
    /// Virtual destructor
38
    virtual ~AssemblerInterface() = default;
39

40
    /// Bind the local-assembler to the grid-element with its corresponding geometry
41
    virtual void bind(Element const& element, Geometry const& geometry) = 0;
42
43

    /// Unbind from the element
44
45
46
    virtual void unbind() = 0;

    /// Assemble an element matrix or element vector on the test- (and trial-) function node(s)
47
48
49
    virtual void assemble(LocalContext const& localContext,
                          Nodes const&... nodes,
                          ElementMatrixVector& elementMatrixVector) = 0;
50
51
52
  };

} // end namespace AMDiS