LocalAssemblerBase.hpp 1.66 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
12
13
14
15
16

namespace AMDiS
{
  /// Abstract base-class of a \ref LocalAssembler
  template <class LocalContext, class... Nodes>
  class LocalAssemblerBase
  {
  public:
17
    /// The codim=0 grid entity
18
    using Element = typename Impl::ContextTypes<LocalContext>::Entity;
19
    /// The geometry of the \ref Element
20
21
22
23
24
25
    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!");

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

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

  public:
35
    /// Virtual destructor
36
    virtual ~LocalAssemblerBase() = default;
37

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

    /// Unbind from the element
42
43
44
    virtual void unbind() = 0;

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

} // end namespace AMDiS