DUNE-FEM (unstable)

bindable.hh
1#ifndef DUNE_FEM_FUNCTION_LOCALFUNCTION_BINDABLE_HH
2#define DUNE_FEM_FUNCTION_LOCALFUNCTION_BINDABLE_HH
3
4#include <dune/fem/storage/entitygeometry.hh>
5
6#include <dune/fem/space/common/discretefunctionspace.hh>
7#include <dune/fem/function/common/discretefunction.hh>
8#include <dune/fem/common/coordinate.hh>
9#include <dune/fem/quadrature/quadrature.hh> // shouldn't be here (but otherwise the coordinate method doesn't work)
10#include <dune/fem/common/intersectionside.hh>
11
12namespace Dune
13{
14 namespace Fem
15 {
16 struct BindableFunction : public HasLocalFunction {};
17
18 template <class GridPart, class Range>
19 struct BindableGridFunction
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
26 typedef EntityGeometryStorage< EntityType > BaseType;
27
28 typedef typename GridPart::IntersectionType IntersectionType;
29 typedef typename EntityType::Geometry Geometry;
30 typedef typename Geometry::GlobalCoordinate DomainType;
31 typedef Dune::Fem::GridFunctionSpace<GridPartType, Range> FunctionSpaceType;
32 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
33 typedef typename FunctionSpaceType::RangeType RangeType;
34 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
35 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
36 BindableGridFunction(const GridPart &gridPart)
37 : BaseType(),
38 gridPart_(gridPart)
39 {}
40
41 using BaseType :: bind;
42 using BaseType :: unbind;
43 using BaseType :: entity;
44 using BaseType :: geometry;
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();
50 BaseType::bind( entity );
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>
82 struct BindableGridFunctionWithSpace : public BindableGridFunction<GridPart,Range>
83 {
84 typedef BindableGridFunction<GridPart,Range> Base;
85 typedef GridPart GridPartType;
86 typedef typename GridPart::template Codim<0>::EntityType EntityType;
87 typedef typename EntityType::Geometry::GlobalCoordinate DomainType;
88 typedef Dune::Fem::GridFunctionSpace<GridPartType, Range> FunctionSpaceType;
89 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
90 typedef typename FunctionSpaceType::RangeType RangeType;
91 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
92 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
94 BindableGridFunctionWithSpace(const GridPart &gridPart, const std::string &name, int order)
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 }
108 const DiscreteFunctionSpaceType &space () const
109 {
110 return space_;
111 }
112 private:
113 DiscreteFunctionSpaceType space_;
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
const Entity & entity() const
return entity
Definition: entitygeometry.hh:101
const Geometry & geometry() const
return geometry
Definition: entitygeometry.hh:111
void bind(const EntityType &entity)
set new entity object and geometry if enabled
Definition: entitygeometry.hh:135
Definition: explicitfieldvector.hh:75
FunctionSpaceTraits::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:71
FunctionSpaceTraits::LinearMappingType JacobianRangeType
Intrinsic type used for the jacobian values has a Dune::FieldMatrix type interface.
Definition: functionspaceinterface.hh:75
FunctionSpaceTraits::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:63
A vector valued function space.
Definition: functionspace.hh:60
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: geometry.hh:106
actual interface class for quadratures
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition: typetraits.hh:40
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)