Assembler.hpp 2.4 KB
Newer Older
1
2
#pragma once

3
// std c++ headers
4
#include <memory>
5
6

// AMDiS includes
7
8
9
10
11
#include <dune/amdis/QuadratureRules.hpp>
#include <dune/amdis/common/TypeDefs.hpp>

namespace AMDiS
{
12
13
  // the LocalContext is either an Codim=0-EntityType or an IntersectionType
  template <class GridView, class LocalContext>
14
15
16
17
18
  class Assembler
  {
    static constexpr int dim = GridView::dimension;
    using ctype = typename GridView::ctype;

19
    using LocalQuadratureRules = Dune::QuadratureRules<ctype, LocalContext::mydimension>;
20
21
    using QuadratureRule = QuadratureRuleFactory_t<LocalContext, ctype, dim>;
    using Geometry = typename Impl::Get<LocalContext>::Geometry;
22
23

  public:
24
25
    /// Constructor, initializes the geometry of the element and a
    /// quadrature-rule wrapper
26
    template <class Operator>
27
    Assembler(Operator& op, LocalContext const& element, int degree, FirstOrderType type = GRD_PHI)
28
29
30
      : geometry(get_geometry(element))
    {
      int order = op.getQuadratureDegree(geometry.type(), geometry, degree, type);
31
      auto const& quad = LocalQuadratureRules::rule(geometry.type(), order);
32
33
34
35

      quadrature.reset(new QuadratureRule(element, quad));
    }

36
37
38
39
40
41
42
    /// \brief Returns reference to the transformed quadrature rule
    /**
     * For intersections this corresponds to the points in the intersection
     * geometry, but coordinates extended to the whole inside-entity. For
     * elements this is a wrapper around the classical element quadrature rule.
     * Access the underlying dune-quadrature rule, with `quadrature->getRule()`.
     **/
43
    QuadratureRule const& getQuadrature() const
44
45
46
47
    {
      return *quadrature;
    }

48
49
50
51
52
    /// Return the geometry of the Object
    /**
     * The geometry is either the element geometry, or the geometry of the
     * inside-element for intersections.
     **/
53
54
55
56
57
    Geometry const& getGeometry() const
    {
      return geometry;
    }

58
59
60
61
62
63
  protected:

    // transform coords from intersection coords to element coords
    template <class Coordinate>
    decltype(auto) map(Coordinate const& p) const
    {
64
      return get_position<LocalContext>(geometry, p);
65
66
    }

67
  private:
68
    /// transformed quadrature rule
69
    std::shared_ptr<QuadratureRule const> quadrature;
70
71
72
73
74

    /// geometry() for entities or geometryInInside() for intersections
    Geometry geometry;

    // TODO: create geometry just once for each element, e.g. in ProblemStat when traversing the grid
75
76
77
  };

} // end namespace AMDiS