dune-fem 2.12-git
Loading...
Searching...
No Matches
bindable.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_FUNCTION_LOCALFUNCTION_BINDABLE_HH
2#define DUNE_FEM_FUNCTION_LOCALFUNCTION_BINDABLE_HH
3
5
9#include <dune/fem/quadrature/quadrature.hh> // shouldn't be here (but otherwise the coordinate method doesn't work)
11
12namespace Dune
13{
14 namespace Fem
15 {
17
18 template <class GridPart, class Range>
20 : public EntityGeometryStorage< typename GridPart::template Codim<0>::EntityType >,
21 public BindableFunction
22 {
23 typedef GridPart GridPartType;
24 typedef typename GridPart::template Codim<0>::EntityType EntityType;
25
27
28 typedef typename GridPart::IntersectionType IntersectionType;
29 typedef typename EntityType::Geometry Geometry;
32 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
33 typedef typename FunctionSpaceType::RangeType RangeType;
34 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
35 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
37 : BaseType(),
39 {}
40
41 using BaseType :: bind;
42 using BaseType :: unbind;
43 using BaseType :: entity;
45
46 void bind(const IntersectionType &intersection, IntersectionSide side)
47 {
48 // store local copy to avoid problems with casting to temporary types
49 const EntityType entity = side==IntersectionSide::in? intersection.inside(): intersection.outside();
51 }
52
53 bool continuous() const { return true; }
54 template <class Point>
55 DomainType global(const Point &x) const
56 {
57 return geometry().global( Dune::Fem::coordinate(x) );
58 }
59
60 // this method needs to be overloaded in the derived class
61 template <class Point>
62 void evaluate( const Point& x, RangeType& ret ) const;
63
64 template <class Quadrature, class RangeArray>
65 void evaluate( const Quadrature& quadrature, RangeArray& values ) const
66 {
67 const unsigned int nop = quadrature.nop();
68 values.resize( nop );
69 for( unsigned int qp=0; qp<nop; ++qp)
70 {
71 evaluate( quadrature[ qp ], values[ qp ]);
72 }
73 }
74
75 const GridPart& gridPart() const { return gridPart_; }
76
77 protected:
78 const GridPart &gridPart_;
79 };
80
81 template <class GridPart, class Range>
83 {
85 typedef GridPart GridPartType;
86 typedef typename GridPart::template Codim<0>::EntityType EntityType;
87 typedef typename EntityType::Geometry::GlobalCoordinate DomainType;
89 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
90 typedef typename FunctionSpaceType::RangeType RangeType;
91 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
92 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
95 : Base(gridPart),
96 space_( gridPart, order ),
97 name_(name)
98 {}
100 unsigned int order() const
101 {
102 return space().order();
103 }
104 const std::string &name() const
105 {
106 return name_;
107 }
109 {
110 return space_;
111 }
112 private:
114 const std::string name_;
115 };
116
117 namespace detail
118 {
119 template <class,class,class>
120 struct canBind
121 : std::false_type {};
122 template <class GP,class LF>
123 struct canBind<GP,LF,
124 std::void_t< decltype( std::declval<LF>().
125 bind(std::declval<const typename GP::template Codim<0>::EntityType&>())) >>
126 : std::true_type {};
127 template <class GP,class LF>
128 using canBind_t = canBind<GP,LF,void>;
129 }
130
131 template <class GP,class LF>
132 constexpr detail::canBind_t<GP,LF> checkGridPartValid() { return {}; }
133
134 } // namespace Fem
135} // namespace Dune
136#endif // DUNE_FEM_FUNCTION_LOCALFUNCTION_BINDABLE_HH
typename Impl::voider< Types... >::type void_t
STL namespace.
constexpr detail::canBind_t< GP, LF > checkGridPartValid()
Definition bindable.hh:132
typename Impl::GridFunctionSpace< GridPart, T >::Type GridFunctionSpace
Definition functionspace.hh:317
static const Point & coordinate(const Point &x)
Definition coordinate.hh:14
IntersectionSide
Definition intersectionside.hh:11
base class for determing whether a function has local functions or not
Definition common/discretefunction.hh:57
Definition bindable.hh:16
Definition bindable.hh:22
FunctionSpaceType::JacobianRangeType JacobianRangeType
Definition bindable.hh:34
GridPart::template Codim< 0 >::EntityType EntityType
Definition bindable.hh:24
bool continuous() const
Definition bindable.hh:53
void bind(const IntersectionType &intersection, IntersectionSide side)
Definition bindable.hh:46
FunctionSpaceType::RangeFieldType RangeFieldType
Definition bindable.hh:32
const GridPart & gridPart() const
Definition bindable.hh:75
GridPart GridPartType
Definition bindable.hh:23
FunctionSpaceType::HessianRangeType HessianRangeType
Definition bindable.hh:35
Dune::Fem::GridFunctionSpace< GridPartType, Range > FunctionSpaceType
Definition bindable.hh:31
BindableGridFunction(const GridPart &gridPart)
Definition bindable.hh:36
EntityType::Geometry Geometry
Definition bindable.hh:29
GridPart::IntersectionType IntersectionType
Definition bindable.hh:28
void evaluate(const Point &x, RangeType &ret) const
DomainType global(const Point &x) const
Definition bindable.hh:55
void evaluate(const Quadrature &quadrature, RangeArray &values) const
Definition bindable.hh:65
Geometry::GlobalCoordinate DomainType
Definition bindable.hh:30
FunctionSpaceType::RangeType RangeType
Definition bindable.hh:33
const GridPart & gridPart_
Definition bindable.hh:78
EntityGeometryStorage< EntityType > BaseType
Definition bindable.hh:26
EntityType::Geometry::GlobalCoordinate DomainType
Definition bindable.hh:87
const DiscreteFunctionSpaceType & space() const
Definition bindable.hh:108
FunctionSpaceType::HessianRangeType HessianRangeType
Definition bindable.hh:92
BindableGridFunctionWithSpace(const GridPart &gridPart, const std::string &name, int order)
Definition bindable.hh:94
FunctionSpaceType::RangeType RangeType
Definition bindable.hh:90
BindableGridFunction< GridPart, Range > Base
Definition bindable.hh:84
Dune::Fem::GridFunctionSpace< GridPartType, Range > FunctionSpaceType
Definition bindable.hh:88
FunctionSpaceType::RangeFieldType RangeFieldType
Definition bindable.hh:89
DiscreteFunctionSpaceAdapter< FunctionSpaceType, GridPartType > DiscreteFunctionSpaceType
Definition bindable.hh:93
GridPart::template Codim< 0 >::EntityType EntityType
Definition bindable.hh:86
FunctionSpaceType::JacobianRangeType JacobianRangeType
Definition bindable.hh:91
const std::string & name() const
Definition bindable.hh:104
unsigned int order() const
return the order of the space
Definition bindable.hh:100
GridPart GridPartType
Definition bindable.hh:85
actual interface class for integration point lists
Definition quadrature.hh:158
int nop() const
obtain the number of integration points
Definition quadrature.hh:312
int order() const
get global order of space
Definition discretefunctionspace.hh:1104
implementation of entity and geometry storage for basis function set and local functions
Definition entitygeometry.hh:35
const Entity & entity() const
return entity
Definition entitygeometry.hh:101
const Geometry & geometry() const
return geometry
Definition entitygeometry.hh:111
void unbind()
release entity and geometry object
Definition entitygeometry.hh:164
void bind(const EntityType &entity)
set new entity object and geometry if enabled
Definition entitygeometry.hh:135