ContextGeometry.hpp 1.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once

namespace AMDiS
{
  template <class LocalContext, class Geometry, class LocalGeometry>
  struct ContextGeometry
  {
    enum {
      dim = Geometry::mydimension,    //< the dimension of the grid element
      dow = Geometry::coorddimension  //< the dimension of the world
    };

    LocalContext const& localContext;
    Geometry const& geometry;
    LocalGeometry const& localGeometry;

    /// Coordinate `p` given in `localGeometry`, transformed to coordinate in `geometry`.
    template <class Coordinate>
    decltype(auto) position(Coordinate const& p) const
    {
      return position(p, std::is_same<Geometry, LocalGeometry>{});
    }

    /// The integration element from the `localGeometry`, the quadrature points are
    /// defined in.
    template <class Coordinate>
    auto integrationElement(Coordinate const& p) const
    {
      return localGeometry.integrationElement(p);
    }

    /// Transformation of coordinate `p` given in `localGeometry` to world space coordinates.
    template <class Coordinate>
    decltype(auto) global(Coordinate const& p) const
    {
      return geometry.global(p);
    }

  private: // implementation detail

    // position for elements
    template <class Coordinate>
    Coordinate const& position(Coordinate const& p, std::true_type) const
    {
      return p;
    }

    // position for intersection
    template <class Coordinate>
    auto position(Coordinate const& p, std::false_type) const
    {
      return localGeometry.global(p);
    }

  };

} // end namespace AMDiS