1 #ifndef DUNE_FEM_FUNCTION_LOCALFUNCTION_CONST_HH
2 #define DUNE_FEM_FUNCTION_LOCALFUNCTION_CONST_HH
8 #include <dune/common/dynvector.hh>
23 struct DiscreteFunctionTraits;
25 class HasLocalFunction;
26 class IsDiscreteFunction;
27 struct BindableFunction;
32 template <
class BasisFunctionSet,
class LocalDofVector >
85 using BaseType::operator +=;
86 using BaseType::operator -=;
107 template<
class DiscreteFunction >
110 typename DiscreteFunctionTraits< std::remove_const_t< DiscreteFunction > >::DiscreteFunctionSpaceType::BasisFunctionSetType,
111 Dune::DynamicVector< typename DiscreteFunctionTraits< std::remove_const_t< DiscreteFunction > >::DofType,
112 typename DiscreteFunctionTraits< std::remove_const_t< DiscreteFunction > >::LocalDofVectorAllocatorType
113 :: template rebind< typename DiscreteFunctionTraits< std::remove_const_t< DiscreteFunction > > ::DofType > ::other > >
117 Dune::DynamicVector< typename DiscreteFunctionTraits< std::remove_const_t< DiscreteFunction > >
::DofType,
119 :: template rebind< typename DiscreteFunctionTraits< std::remove_const_t< DiscreteFunction > >
::DofType >::other > >
160 std::copy( localFunction.localDofVector().begin(), localFunction.localDofVector().end(),
localDofVector().begin() );
206 template<
class Po
int >
222 template<
class Po
int >
238 template<
class Po
int >
271 template<
class GF,
class =
void >
275 struct ConstLocalFunction< GF, std::enable_if_t< std::is_base_of< Fem::HasLocalFunction, GF >::value && std::is_base_of< Fem::IsDiscreteFunction, GF >::value > >
281 struct ConstLocalFunction< GF, std::enable_if_t< std::is_base_of< Fem::HasLocalFunction, GF >::value && !std::is_base_of< Fem::IsDiscreteFunction, GF >::value && std::is_class< typename GF::LocalFunctionType >::value > >
284 :
public GF::LocalFunctionType
286 typedef GF GridFunctionType;
287 typedef typename GridFunctionType::LocalFunctionType::EntityType EntityType;
289 typedef typename GF::LocalFunctionType::RangeType RangeType;
290 typedef typename GF::LocalFunctionType::JacobianRangeType JacobianRangeType;
291 typedef typename GF::LocalFunctionType::HessianRangeType HessianRangeType;
293 explicit Type (
const GridFunctionType &gridFunction )
294 : GridFunctionType::LocalFunctionType( gridFunction ),
295 gridFunction_( gridFunction )
298 using GF::LocalFunctionType::evaluate;
299 using GF::LocalFunctionType::jacobian;
300 using GF::LocalFunctionType::hessian;
301 using GF::LocalFunctionType::init;
302 using GF::LocalFunctionType::entity;
305 template<
class Po
int >
306 RangeType evaluate (
const Point &p )
const
314 template<
class Po
int >
315 JacobianRangeType jacobian (
const Point &p )
const
317 JacobianRangeType jac;
323 template<
class Po
int >
324 HessianRangeType hessian (
const Point &p )
const
331 void bind (
const EntityType &entity ) { init( entity ); }
334 const GridFunctionType &gridFunction ()
const {
return gridFunction_; }
337 const GridFunctionType &gridFunction_;
342 struct ConstLocalFunction< GF, std::enable_if_t< std::is_base_of< Fem::BindableFunction, GF >::value && !std::is_base_of< Fem::IsDiscreteFunction, GF >::value > >
346 typedef GF GridFunctionType;
347 typedef typename GF::EntityType EntityType;
348 typedef typename GF::RangeFieldType RangeFieldType;
349 typedef typename GF::RangeType RangeType;
350 typedef typename GF::JacobianRangeType JacobianRangeType;
351 typedef typename GF::HessianRangeType HessianRangeType;
353 explicit Type (
const GridFunctionType &gridFunction )
354 : gridFunction_( gridFunction )
357 template <
class Po
int>
358 void evaluate(
const Point &x, RangeType &ret)
const
360 gridFunction().evaluate(x,ret);
362 template <
class Po
int>
363 void jacobian(
const Point &x, JacobianRangeType &ret)
const
365 gridFunction().jacobian(x,ret);
367 template <
class Po
int>
368 void hessian(
const Point &x, HessianRangeType &ret)
const
370 gridFunction().hessian(x,ret);
372 unsigned int order()
const {
return gridFunction().order(); }
375 template<
class Po
int >
376 RangeType evaluate (
const Point &p )
const
384 template<
class Po
int >
385 JacobianRangeType jacobian (
const Point &p )
const
387 JacobianRangeType jac;
393 template<
class Po
int >
394 HessianRangeType hessian (
const Point &p )
const
401 template<
class Quadrature,
class ... Vectors >
402 void evaluateQuadrature (
const Quadrature &quad, Vectors & ... values )
const
404 static_assert(
sizeof...( Vectors ) > 0,
"evaluateQuadrature needs to be called with at least one vector." );
405 std::ignore = std::make_tuple( ( evaluateQuadrature( quad, values ), 1 ) ... );
408 template<
class Quadrature,
class Vector >
409 auto evaluateQuadrature (
const Quadrature &quad, Vector &v )
const
410 -> std::enable_if_t< std::is_same< std::decay_t< decltype(v[ 0 ]) >, RangeType >::value >
412 for(
const auto qp : quad )
413 v[ qp.index() ] = evaluate( qp );
416 template<
class Quadrature,
class Vector >
417 auto evaluateQuadrature (
const Quadrature &quad, Vector &v )
const
418 -> std::enable_if_t< std::is_same< std::decay_t< decltype(v[ 0 ]) >, JacobianRangeType >::value >
420 for(
const auto qp : quad )
421 v[ qp.index() ] = jacobian( qp );
424 template<
class Quadrature,
class Vector >
425 auto evaluateQuadrature (
const Quadrature &quad, Vector &v )
const
426 -> std::enable_if_t< std::is_same< std::decay_t< decltype(v[ 0 ]) >, HessianRangeType >::value >
428 for(
const auto qp : quad )
429 v[ qp.index() ] = hessian( qp );
432 void bind (
const EntityType &entity ) { gridFunction_.bind( entity ); }
433 void unbind () { gridFunction().unbind(); }
435 const EntityType& entity()
const
437 return gridFunction_.entity();
440 const GridFunctionType &gridFunction ()
const {
return gridFunction_; }
443 GridFunctionType &gridFunction () {
return gridFunction_; }
444 GridFunctionType gridFunction_;
450 template<
class Gr
idFunction >
Definition: bindguard.hh:11
typename Impl::ConstLocalFunction< GridFunction >::Type ConstLocalFunction
Definition: const.hh:451
Definition: explicitfieldvector.hh:75
Traits class for a DiscreteFunction.
Definition: common/discretefunction.hh:60
BasicConstLocalFunction(const BasisFunctionSetType &basisFunctionSet, LocalDofVectorType &&localDofVector)
Definition: const.hh:68
BasicConstLocalFunction(const BasisFunctionSetType &basisFunctionSet, const LocalDofVectorType &localDofVector)
Definition: const.hh:62
BasicConstLocalFunction(const BaseType &other)
Definition: const.hh:72
BasicConstLocalFunction(ThisType &&other)
Definition: const.hh:75
BaseType::SizeType SizeType
type of SizeType
Definition: const.hh:53
const DofType & operator[](SizeType i) const
Definition: const.hh:77
BaseType ::LocalDofVectorType LocalDofVectorType
type of LocalDofVector
Definition: const.hh:50
const LocalDofVectorType & localDofVector() const
return const reference to local Dof Vector
Definition: localfunction.hh:396
BasicConstLocalFunction(const BasisFunctionSetType &basisFunctionSet)
Definition: const.hh:58
BaseType ::BasisFunctionSetType BasisFunctionSetType
type of BasisFunctionSet
Definition: const.hh:47
BasicConstLocalFunction(LocalDofVectorType &&localDofVector)
Definition: const.hh:66
BasicConstLocalFunction(const ThisType &other)
Definition: const.hh:74
BasicConstLocalFunction(const LocalDofVectorType &localDofVector)
Definition: const.hh:60
BaseType::DofType DofType
type of Dof
Definition: const.hh:41
BasicConstLocalFunction()
default ctor
Definition: const.hh:56
BaseType ::EntityType EntityType
type of Entity
Definition: const.hh:44
A constant local function carrying values for one entity.
Definition: const.hh:114
const GridFunctionType & gridFunction() const
Definition: const.hh:257
BaseType::HessianRangeType HessianRangeType
Definition: const.hh:134
BaseType::RangeType RangeType
Definition: const.hh:132
ConstLocalDiscreteFunction(ThisType &&other)
move constructor
Definition: const.hh:190
const DiscreteFunctionType & discreteFunction() const
Definition: const.hh:256
ConstLocalDiscreteFunction(const DiscreteFunctionType &df)
constructor creating a local function without binding it to an entity
Definition: const.hh:149
RangeType evaluate(const Point &p) const
evaluate the local function
Definition: const.hh:207
const DiscreteFunctionType * discreteFunction_
Definition: const.hh:260
std::remove_const_t< DiscreteFunction > DiscreteFunctionType
Definition: const.hh:123
void init(const EntityType &entity)
interface for local functions :: init
Definition: const.hh:247
ConstLocalDiscreteFunction(const ThisType &other)
copy constructor
Definition: const.hh:184
BaseType::LocalDofVectorType LocalDofVectorType
Definition: const.hh:131
ConstLocalDiscreteFunction(const DiscreteFunctionType &df, const EntityType &entity)
constructor creating a local function and binding it to an entity
Definition: const.hh:176
const LocalDofVectorType & localDofVector() const
return const reference to local Dof Vector
Definition: localfunction.hh:396
DiscreteFunctionType GridFunctionType
Definition: const.hh:126
BaseType::DofType DofType
Definition: const.hh:128
DiscreteFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
Definition: const.hh:124
ConstLocalDiscreteFunction(const typename DiscreteFunctionType::LocalFunctionType &localFunction)
cast a MutableLocalFunction into this one !!! expensive !!!
Definition: const.hh:156
BaseType::BasisFunctionSetType BasisFunctionSetType
Definition: const.hh:130
BaseType::JacobianRangeType JacobianRangeType
Definition: const.hh:133
void bind(const EntityType &entity)
Definition: const.hh:253
HessianRangeType hessian(const Point &p) const
evaluate Hessian of the local function
Definition: const.hh:239
BaseType::EntityType EntityType
Definition: const.hh:129
JacobianRangeType jacobian(const Point &p) const
evaluate Jacobian of the local function
Definition: const.hh:223
void unbind()
Definition: const.hh:254
interface for local functions
Definition: localfunction.hh:44
void evaluate(const PointType &x, RangeType &ret) const
evaluate the local function
Definition: localfunction.hh:307
ThisType & axpy(const RangeFieldType s, const LocalFunction< BasisFunctionSet, T > &other)
add a multiple of another local function to this one
Definition: localfunction.hh:204
const EntityType & entity() const
obtain the entity, this local function lives on
Definition: localfunction.hh:292
BasisFunctionSet BasisFunctionSetType
type of basis function set
Definition: localfunction.hh:49
void hessian(const PointType &x, HessianRangeType &ret) const
evaluate Hessian of the local function
Definition: localfunction.hh:335
LocalDofVectorType::value_type DofType
type of DoF use with the discrete function
Definition: localfunction.hh:55
void init(const BasisFunctionSetType &basisFunctionSet)
Definition: localfunction.hh:295
FunctionSpaceType::RangeType RangeType
type of range vectors, i.e., type of function values
Definition: localfunction.hh:73
const BasisFunctionSetType & basisFunctionSet() const
obtain the basis function set for this local function
Definition: localfunction.hh:286
const LocalDofVectorType & localDofVector() const
return const reference to local Dof Vector
Definition: localfunction.hh:396
void jacobian(const PointType &x, JacobianRangeType &ret) const
evaluate Jacobian of the local function
Definition: localfunction.hh:321
FunctionSpaceType::JacobianRangeType JacobianRangeType
type of the Jacobian, i.e., type of evaluated Jacobian matrix
Definition: localfunction.hh:75
LocalDofVectorType::size_type SizeType
type of index
Definition: localfunction.hh:58
void clear()
set all DoFs to zero
Definition: localfunction.hh:172
BasisFunctionSetType::EntityType EntityType
type of the entity, the local function lives on is given by the space
Definition: localfunction.hh:61
void assign(const LocalFunction< BasisFunctionSet, T > &other)
assign all DoFs of this local function
Definition: localfunction.hh:166
LocalDofVector LocalDofVectorType
type of local Dof Vector
Definition: localfunction.hh:52
SizeType size() const
Definition: localfunction.hh:349