gridfunction.hh 1.39 KB
Newer Older
1
2
3
4
5
6
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_CURVED_SURFACE_GRID_GRIDFUNCTION_HH
#define DUNE_CURVED_SURFACE_GRID_GRIDFUNCTION_HH

#include <type_traits>
7
8
#include <dune/curvedsurfacegrid/concepts.hh>
#include <dune/curvedsurfacegrid/gridfunctions/analyticgridfunction.hh>
9
10
11
12
13

namespace Dune
{
  namespace Impl
  {
14
    template< class ES, class = void >
15
16
    struct GridOf;

17
18
    template< class ES >
    struct GridOf<ES, std::void_t<typename ES::GridView>>
19
    {
20
      using type = typename ES::GridView::Grid;
21
22
    };

23
24
    template< class ES >
    struct GridOf<ES, std::void_t<typename ES::Grid>>
25
    {
26
      using type = typename ES::Grid;
27
28
29
30
    };

  } // end namespace Impl

Praetorius, Simon's avatar
Praetorius, Simon committed
31
  //! Type-Traits to extract the grid-type from a GridFunction `GF`
32
  template< class GF >
33
  using GridOf_t = typename Impl::GridOf<std::decay_t<decltype(std::declval<GF>().entitySet())>>::type;
34

Praetorius, Simon's avatar
Praetorius, Simon committed
35
36
37
38
39
40
  //! Conditionally define the GridFunction type.
  /**
   * If the type `GF` is a GridFunction on the grid `Grid`, use this type as GridFunction type,
   * Otherwise it is a functor and construct an \ref AnalyticGridFunction on the `Grid`.
   **/
  template< class Grid, class GF >
41
  using GridFunctionOf_t
Praetorius, Simon's avatar
Praetorius, Simon committed
42
    = std::conditional_t<Dune::Concept::isGridFunction<GF, Grid>(), GF, AnalyticGridFunction<Grid,GF>>;
43

44
45
46
} // end namespace Dune

#endif // DUNE_CURVED_SURFACE_GRID_GRIDFUNCTION_HH