4#ifndef DUNE_PDELAB_FUNCTION_CALLABLEADAPTER_HH
5#define DUNE_PDELAB_FUNCTION_CALLABLEADAPTER_HH
12#include <dune/pdelab/common/function.hh>
13#include <dune/pdelab/constraints/common/constraintsparameters.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;
52 struct CallableAdapterGetDim {
56 template<
typename T,
int n>
57 struct CallableAdapterGetDim< FieldVector<T,n> > {
62 struct CallableAdapterGetRangeFieldType {
66 template<
typename T,
int n>
67 struct CallableAdapterGetRangeFieldType< FieldVector<T,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>
113 WrapperConformingToGridFunctionInterface makeGridFunctionFromCallable (
const GV& gv,
const F& f)
119 template <
typename GV,
typename F>
120 auto makeGridFunctionFromCallable (
const GV& gv,
const F& 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;
139 typedef typename CallableAdapterGetRangeFieldType<ReturnType>::Type RF;
140 const int dim = CallableAdapterGetDim<ReturnType>::dim;
141 typedef GlobalCallableToGridFunctionAdapter<GV,RF,dim,F> TheType;
142 return TheType(gv,f);
147 template <
typename GV,
typename F>
148 auto makeGridFunctionFromCallable (
const GV& gv,
const F& 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;
178 typedef typename CallableAdapterGetRangeFieldType<ReturnType>::Type RF;
179 const int dim = CallableAdapterGetDim<ReturnType>::dim;
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_)
224 void setTime (RF t) {
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;
259 void setTime (RF t) {
278 template <
typename GV,
typename F>
279 WrapperConformingToGridFunctionInterface makeInstationaryGridFunctionFromCallable (
const GV& gv,
const F& f)
286 template <
typename GV,
typename F,
typename PARAM>
287 auto makeInstationaryGridFunctionFromCallable (
const GV& gv,
const F& f, PARAM& 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;
307 typedef typename CallableAdapterGetRangeFieldType<ReturnType>::Type RF;
308 const int dim = CallableAdapterGetDim<ReturnType>::dim;
309 typedef GlobalCallableToInstationaryGridFunctionAdapter<GV,RF,dim,F,PARAM> TheType;
310 return TheType(gv,f,param);
315 template <
typename GV,
typename F,
typename PARAM>
316 auto makeInstationaryGridFunctionFromCallable (
const GV& gv,
const F& f, PARAM& 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;
347 typedef typename CallableAdapterGetRangeFieldType<ReturnType>::Type RF;
348 const int dim = CallableAdapterGetDim<ReturnType>::dim;
349 typedef LocalCallableToInstationaryGridFunctionAdapter<GV,RF,dim,F,PARAM> TheType;
350 return TheType(gv,f,param);
376 auto xg = intersection.geometry().global(coord);
381 bool isNeumann(
const I & ig,
408 return(f(ig.intersection(),coord));
412 bool isNeumann(
const I & ig,
416 return !isDirichlet( ig, 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<
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);
vector space out of a tensor product of fields.
Definition: fvector.hh:91
Adapter for boundary cond from a callable taking global coordinates.
Definition: callableadapter.hh:363
bool isDirichlet(const I &intersection, const Dune::FieldVector< typename I::ctype, I::mydimension > &coord) const
Test whether boundary is Dirichlet-constrained.
Definition: callableadapter.hh:372
GlobalCallableToBoundaryConditionAdapter(F f_)
construct from functor
Definition: callableadapter.hh:368
Adapter for callables f(x) expecting a global coordinate x.
Definition: callableadapter.hh:28
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &xl, typename Traits::RangeType &y) const
evaluate extended function on element
Definition: callableadapter.hh:42
GlobalCallableToGridFunctionAdapter(const GV &gv_, const F &f_)
construct from grid view
Definition: callableadapter.hh:36
const GV & getGridView() const
get a reference to the grid view
Definition: callableadapter.hh:39
return a PDELab GridFunction (with setTime method) defined by a parameter class and a callable f(x) g...
Definition: callableadapter.hh:198
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &xl, typename Traits::RangeType &y) const
evaluate extended function on element
Definition: callableadapter.hh:215
const GV & getGridView() const
get a reference to the grid view
Definition: callableadapter.hh:212
GlobalCallableToInstationaryGridFunctionAdapter(const GV &gv_, const F &f_, P &p_)
construct from grid view
Definition: callableadapter.hh:207
leaf of a function tree
Definition: function.hh:302
Adapter for boundary cond from a callable taking an entity and local coordinates.
Definition: callableadapter.hh:395
Adapter for callables f(e,x) expecting an entity e and a global coordinate x.
Definition: callableadapter.hh:78
LocalCallableToGridFunctionAdapter(const GV &gv_, const F &f_)
construct from grid view
Definition: callableadapter.hh:86
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &xl, typename Traits::RangeType &y) const
evaluate extended function on element
Definition: callableadapter.hh:92
const GV & getGridView() const
get a reference to the grid view
Definition: callableadapter.hh:89
return a PDELab GridFunction (with setTime method) defined by a parameter class and a callable f(e,...
Definition: callableadapter.hh:236
void evaluate(const typename Traits::ElementType &e, const typename Traits::DomainType &xl, typename Traits::RangeType &y) const
evaluate extended function on element
Definition: callableadapter.hh:251
const GV & getGridView() const
get a reference to the grid view
Definition: callableadapter.hh:248
LocalCallableToInstationaryGridFunctionAdapter(const GV &gv_, const F &f_, P &p_)
construct from grid view
Definition: callableadapter.hh:245
Traits for type conversions and type information.
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:13
template which always yields a true value
Definition: typetraits.hh:134
Static tag representing a codimension.
Definition: dimension.hh:24
Definition: constraintsparameters.hh:26
Definition: constraintsparameters.hh:122
R RangeType
range type
Definition: function.hh:62
traits class holding the function signature, same as in local function
Definition: function.hh:183
GV::Traits::template Codim< 0 >::Entity ElementType
codim 0 entity
Definition: function.hh:119