concepts.hh 1.59 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
// -*- 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_CONCEPTS_HH
#define DUNE_CURVED_SURFACE_GRID_CONCEPTS_HH

#include <dune/common/concept.hh>
#include <dune/curvedsurfacegrid/gridfunctions/gridentityset.hh>
#include <dune/functions/common/functionconcepts.hh>

namespace Dune {
namespace Concept {

template< class LocalContext >
struct LocalFunction
{
  using LocalCoordinate = typename LocalContext::Geometry::LocalCoordinate;

  template< class LF >
  auto require(LF&& lf) -> decltype(
    lf.bind(std::declval<LocalContext>()),
    lf.unbind(),
    lf.localContext(),
    requireConcept<Dune::Functions::Concept::Callable<LocalCoordinate>>(lf),
    requireConvertible<LocalContext>(lf.localContext())
  );
};

template< class LF, class LocalContext >
constexpr bool isLocalFunction()
{ return models<Concept::LocalFunction<LocalContext>, LF>(); }


template< class HostGrid >
struct GridFunction
{
  using EntitySet = GridEntitySet<HostGrid,0>;
  using LocalContext = typename EntitySet::Element;
  using GlobalCoordinate = typename EntitySet::GlobalCoordinate;

  template< class GF >
  auto require(GF&& gf) -> decltype(
    localFunction(gf),
    gf.entitySet(),
    requireConcept<Dune::Functions::Concept::Callable<GlobalCoordinate>>(gf),
    requireConcept<LocalFunction<LocalContext>>(localFunction(gf))
  );
};

template< class GF, class HostGrid >
constexpr bool isGridFunction()
{ return models<Concept::GridFunction<HostGrid>, GF>(); }

} // end namespace Concept
} // end namespace Dune 

#endif // DUNE_CURVED_SURFACE_GRID_CONCEPTS_HH