Assembler.hpp 2.3 KB
Newer Older
1
2
3
4
5
6
7
8
#pragma once

#include <memory>
#include <dune/amdis/QuadratureRules.hpp>
#include <dune/amdis/common/TypeDefs.hpp>

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

16
17
    using QuadratureRule = QuadratureRuleFactory_t<LocalContext, ctype, dim>;
    using Geometry = typename Impl::Get<LocalContext>::Geometry;
18
19

  public:
20
21
    /// Constructor, initializes the geometry of the element and a
    /// quadrature-rule wrapper
22
    template <class Operator>
23
    Assembler(Operator& op, LocalContext const& element, int degree, FirstOrderType type = GRD_PHI)
24
25
26
      : geometry(get_geometry(element))
    {
      int order = op.getQuadratureDegree(geometry.type(), geometry, degree, type);
27
      auto const& quad = Dune::QuadratureRules<ctype, LocalContext::mydimension>::rule(geometry.type(), order);
28
29
30
31

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

32
33
34
35
36
37
38
    /// \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()`.
     **/
39
40
41
42
43
    auto const& getQuadrature() const
    {
      return *quadrature;
    }

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

54
55
56
57
58
59
  protected:

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

63
  private:
64
    /// transformed quadrature rule
65
    std::shared_ptr<QuadratureRule const> quadrature;
66
67
68
69
70

    /// 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
71
72
73
  };

} // end namespace AMDiS