4 #ifndef DUNE_PDELAB_FUNCTION_CALLABLEADAPTER_HH
5 #define DUNE_PDELAB_FUNCTION_CALLABLEADAPTER_HH
9 #include <dune/common/fvector.hh>
10 #include <dune/common/typetraits.hh>
23 template<
typename GV,
typename RF,
int n,
typename F>
26 GridFunctionTraits<GV,RF,n,Dune::FieldVector<RF,n> >,
27 GlobalCallableToGridFunctionAdapter<GV,RF,n,F> >
32 typedef Dune::PDELab::
33 GridFunctionTraits<GV,RF,n,Dune::FieldVector<RF,n> >
Traits;
56 template<
typename T,
int n>
66 template<
typename T,
int n>
73 template<
typename GV,
typename RF,
int n,
typename F>
76 GridFunctionTraits<GV,RF,n,Dune::FieldVector<RF,n> >,
77 LocalCallableToGridFunctionAdapter<GV,RF,n,F> >
82 typedef Dune::PDELab::
83 GridFunctionTraits<GV,RF,n,Dune::FieldVector<RF,n> >
Traits;
112 template <
typename GV,
typename F>
119 template <
typename GV,
typename F>
121 ->
typename std::enable_if<
123 decltype(f(std::declval<
typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate>()))
125 GlobalCallableToGridFunctionAdapter<
127 typename CallableAdapterGetRangeFieldType<
128 decltype(f(std::declval<
typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate>()))
130 CallableAdapterGetDim<
131 decltype(f(std::declval<
typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate>()))
136 typedef typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate X;
138 typedef decltype(f(x)) ReturnType;
141 typedef GlobalCallableToGridFunctionAdapter<GV,RF,dim,F> TheType;
142 return TheType(gv,f);
147 template <
typename GV,
typename F>
149 ->
typename std::enable_if<
152 std::declval<
typename GV::template Codim<0>::Entity>(),
153 std::declval<
typename GV::template Codim<0>::Entity::Geometry::LocalCoordinate>()
156 LocalCallableToGridFunctionAdapter<
158 typename CallableAdapterGetRangeFieldType<
160 std::declval<
typename GV::template Codim<0>::Entity>(),
161 std::declval<
typename GV::template Codim<0>::Entity::Geometry::LocalCoordinate>()
164 CallableAdapterGetDim<
166 std::declval<
typename GV::template Codim<0>::Entity>(),
167 std::declval<
typename GV::template Codim<0>::Entity::Geometry::LocalCoordinate>()
173 typedef typename GV::template Codim<0>::Entity E;
175 typedef typename E::Geometry::LocalCoordinate X;
177 typedef decltype(f(
e,x)) ReturnType;
180 typedef LocalCallableToGridFunctionAdapter<GV,RF,dim,F> TheType;
181 return TheType(gv,f);
193 template<
typename GV,
typename RF,
int n,
typename F,
typename P>
196 GridFunctionTraits<GV,RF,n,Dune::FieldVector<RF,n> >,
197 GlobalCallableToInstationaryGridFunctionAdapter<GV,RF,n,F,P> >
203 typedef Dune::PDELab::
204 GridFunctionTraits<GV,RF,n,Dune::FieldVector<RF,n> >
Traits;
208 : gv(gv_), f(f_),
p(p_)
231 template<
typename GV,
typename RF,
int n,
typename F,
typename P>
234 GridFunctionTraits<GV,RF,n,Dune::FieldVector<RF,n> >,
235 LocalCallableToInstationaryGridFunctionAdapter<GV,RF,n,F,P> >
241 typedef Dune::PDELab::
242 GridFunctionTraits<GV,RF,n,Dune::FieldVector<RF,n> >
Traits;
278 template <
typename GV,
typename F>
286 template <
typename GV,
typename F,
typename PARAM>
288 ->
typename std::enable_if<
290 decltype(f(std::declval<
typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate>()))
292 GlobalCallableToInstationaryGridFunctionAdapter<
294 typename CallableAdapterGetRangeFieldType<
295 decltype(f(std::declval<
typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate>()))
297 CallableAdapterGetDim<
298 decltype(f(std::declval<
typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate>()))
304 typedef typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate X;
306 typedef decltype(f(x)) ReturnType;
309 typedef GlobalCallableToInstationaryGridFunctionAdapter<GV,RF,dim,F,PARAM> TheType;
310 return TheType(gv,f,param);
315 template <
typename GV,
typename F,
typename PARAM>
317 ->
typename std::enable_if<
320 std::declval<
typename GV::template Codim<0>::Entity>(),
321 std::declval<
typename GV::template Codim<0>::Entity::Geometry::LocalCoordinate>()
324 LocalCallableToInstationaryGridFunctionAdapter<
326 typename CallableAdapterGetRangeFieldType<
328 std::declval<
typename GV::template Codim<0>::Entity>(),
329 std::declval<
typename GV::template Codim<0>::Entity::Geometry::LocalCoordinate>()
332 CallableAdapterGetDim<
334 std::declval<
typename GV::template Codim<0>::Entity>(),
335 std::declval<
typename GV::template Codim<0>::Entity::Geometry::LocalCoordinate>()
342 typedef typename GV::template Codim<0>::Entity E;
344 typedef typename E::Geometry::LocalCoordinate X;
346 typedef decltype(f(
e,x)) ReturnType;
349 typedef LocalCallableToInstationaryGridFunctionAdapter<GV,RF,dim,F,PARAM> TheType;
350 return TheType(gv,f,param);
373 const Dune::FieldVector<typename I::ctype, I::mydimension> & coord
376 auto xg = intersection.geometry().global(coord);
382 const Dune::FieldVector<typename I::ctype, I::mydimension> & coord
405 bool isDirichlet(
const I &
ig,
const Dune::FieldVector<typename I::ctype, I::mydimension> & coord
408 return(f(
ig.intersection(),coord));
413 const Dune::FieldVector<typename I::ctype, I::mydimension> & coord
433 template <
typename GV,
typename F>
434 BoundaryConditionAdapter makebBoundaryConditionFromCallable (
const GV& gv,
const F& f)
439 template<
typename GV,
typename F>
440 auto makeBoundaryConditionFromCallable (
const GV& gv,
const F& f)
441 ->
typename std::enable_if<
443 decltype(f(std::declval<
typename GV::template Codim<0>::Entity::Geometry::GlobalCoordinate>()))
445 GlobalCallableToBoundaryConditionAdapter<F>
448 return GlobalCallableToBoundaryConditionAdapter<F>(f);
453 template<
typename GV,
typename F>
454 auto makeBoundaryConditionFromCallable (
const GV& gv,
const F& f)
455 ->
typename std::enable_if<
457 decltype(f(std::declval<typename GV::Intersection>(),
458 std::declval<typename GV::Intersection::Geometry::LocalCoordinate>()
462 LocalCallableToBoundaryConditionAdapter<F>
465 return LocalCallableToBoundaryConditionAdapter<F>(f);
472 #endif // DUNE_PDELAB_FUNCTION_CALLABLEADAPTER_HH