1 #ifndef DUNE_FEM_COMMON_INTERSECTIONSIDE_HH
2 #define DUNE_FEM_COMMON_INTERSECTIONSIDE_HH
3 
4 #include <dune/common/typelist.hh>
5 
6 namespace Dune
7 {
8   namespace Fem
9   {
10     enum class IntersectionSide : std::size_t { in = 0u, out = 1u };
11     template<class GF, class Intersection>
hasIntersectionBind(const MetaType<Intersection> &)12     constexpr auto hasIntersectionBind(const MetaType<Intersection> &) ->
13       decltype(std::declval<GF&>().bind(
14                       std::declval<const Intersection&>(), IntersectionSide::in
15                ), std::true_type{})
16     {
17       return {};
18     }
19     template <class GF>
hasIntersectionBind(...)20     constexpr auto hasIntersectionBind(...) -> std::false_type
21     {
22       return {};
23     }
24     template<class GF, class Intersection>
defaultIntersectionBind(GF & gf,const Intersection & intersection,IntersectionSide side)25     void defaultIntersectionBind(GF &gf, const Intersection &intersection, IntersectionSide side)
26     {
27       if constexpr (hasIntersectionBind<GF>(MetaType<Intersection>()))
28         gf.bind(intersection,side);
29       else
30         gf.bind( side==IntersectionSide::in?  intersection.inside(): intersection.outside() );
31     }
32   }
33 }
34 
35 #endif // DUNE_FEM_COMMON_INTERSECTIONSIDE_HH
36