1#ifndef DUNE_FEM_FUNCTION_LOCALFUNCTION_BINDABLE_HH
2#define DUNE_FEM_FUNCTION_LOCALFUNCTION_BINDABLE_HH
5#include <dune/fem/space/common/discretefunctionspace.hh>
6#include <dune/fem/function/common/discretefunction.hh>
7#include <dune/fem/common/coordinate.hh>
8#include <dune/fem/quadrature/quadrature.hh>
9#include <dune/fem/common/intersectionside.hh>
15 struct BindableFunction :
public HasLocalFunction {};
17 template <
class Gr
idPart,
class Range>
18 struct BindableGridFunction :
public BindableFunction
20 typedef GridPart GridPartType;
21 typedef typename GridPart::template Codim<0>::EntityType EntityType;
22 typedef typename GridPart::IntersectionType IntersectionType;
23 typedef typename EntityType::Geometry Geometry;
30 BindableGridFunction(
const GridPart &gridPart)
37 void bind(
const EntityType &entity)
40 if (thread_==-1) thread_ = MPIManager::thread();
41 if (thread_ != MPIManager::thread())
43 std::cout <<
"wrong thread number\n";
47 if (entity_ || geometry_)
49 std::cout <<
"BindableGF: bind called on object before unbind was called\n";
52 assert(!entity_ && !geometry_);
56 entity_.emplace( entity );
57 geometry_.emplace( this->entity().geometry() );
63 if (thread_ != MPIManager::thread())
65 std::cout <<
"wrong thread number\n";
74 void bind(
const IntersectionType &intersection, IntersectionSide side)
77 const EntityType entity = side==IntersectionSide::in? intersection.inside(): intersection.outside();
81 bool continuous()
const {
return true; }
82 template <
class Po
int>
83 DomainType global(
const Point &x)
const
85 return geometry_.value().global( Dune::Fem::coordinate(x) );
89 template <
class Po
int>
90 void evaluate(
const Point& x, RangeType& ret )
const;
92 template <
class Quadrature,
class RangeArray>
93 void evaluate(
const Quadrature& quadrature, RangeArray& values )
const
95 const unsigned int nop = quadrature.nop();
97 for(
unsigned int qp=0; qp<nop; ++qp)
99 evaluate( quadrature[ qp ], values[ qp ]);
103 const GridPart& gridPart()
const {
return gridPart_; }
104 const EntityType &entity()
const {
return entity_.value(); }
105 const Geometry& geometry()
const {
return geometry_.value(); }
108 std::optional< EntityType > entity_;
109 std::optional< Geometry > geometry_;
110 const GridPart &gridPart_;
116 template <
class Gr
idPart,
class Range>
117 struct BindableGridFunctionWithSpace :
public BindableGridFunction<GridPart,Range>
119 typedef BindableGridFunction<GridPart,Range> Base;
120 typedef GridPart GridPartType;
121 typedef typename GridPart::template Codim<0>::EntityType EntityType;
122 typedef typename EntityType::Geometry::GlobalCoordinate DomainType;
129 BindableGridFunctionWithSpace(
const GridPart &gridPart,
const std::string &name,
int order)
131 space_( gridPart, order ),
135 unsigned int order()
const
137 return space().order();
139 const std::string &name()
const
143 const DiscreteFunctionSpaceType &space ()
const
148 DiscreteFunctionSpaceType space_;
149 const std::string name_;
154 template <
class,
class,
class>
156 : std::false_type {};
157 template <
class GP,
class LF>
158 struct canBind<GP,LF,
159 std::
void_t< decltype( std::declval<LF>().
160 bind(std::declval<const typename GP::template Codim<0>::EntityType&>())) >>
162 template <
class GP,
class LF>
163 using canBind_t = canBind<GP,LF,void>;
166 template <
class GP,
class LF>
167 constexpr detail::canBind_t<GP,LF> checkGridPartValid() {
return {}; }
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
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