1#ifndef DUNE_ACFEM_GRADIENTFUNCTION_HH
2#define DUNE_ACFEM_GRADIENTFUNCTION_HH
4#include "../functions/localfunctionwrapper.hh"
5#include "../functions/gridfunctionexpression.hh"
23 template<
class Gr
idFunction>
26 typedef GridFunction GradientFunctionType;
27 typedef typename GradientFunctionType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType;
28 typedef typename GradientFunctionType::LocalFunctionType LocalGradientFunctionType;
30 typedef typename DiscreteFunctionSpaceType::FunctionSpaceType GradientFunctionSpaceType;
32 Fem::ToNewDimRangeFunctionSpace<GradientFunctionSpaceType, GradientFunctionSpaceType::dimDomain>::Type
34 typedef typename GridFunction::GridPartType GridPartType;
35 typedef typename GridPartType::template Codim<0>::EntityType EntityType;
37 typedef typename FunctionSpaceType::RangeType RangeType;
38 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
39 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
41 static_assert((int)GradientFunctionSpaceType::dimRange == 1,
42 "Gradient Adapter needs dimRange == 1 for underlying function");
44 LocalGradientAdapter(
const Fem::Function<GradientFunctionSpaceType, GradientFunctionType>& function,
45 const std::string& name =
"")
46 : function_(function),
47 localFunction_(function_()),
48 name_(name ==
"" ?
"grad(" + function_().name() +
")" : name)
52 : function_(other.function_()),
53 localFunction_(function_()),
57 const std::string& name()
const {
return name_; }
60 void init(
const EntityType& entity)
62 localFunction_.init(entity);
66 template<
class Po
intType>
67 void evaluate(
const PointType& x, RangeType& ret)
const
69 typename GradientFunctionType::JacobianRangeType myValue;
70 localFunction_.jacobian(x, myValue);
77 template<
class Po
intType>
78 void jacobian(
const PointType& x, JacobianRangeType& ret)
const
80 typename GradientFunctionType::HessianRangeType myJacobian;
81 localFunction_.hessian(x, myJacobian);
90 template<
class Po
intType>
91 void hessian(
const PointType& x, HessianRangeType& ret)
const
93#if __DUNE_ACFEM_MAKE_CHECK__
97 DUNE_THROW(NotImplemented,
"Hessian of the gradient of a given function is NEVER implemented.");
103 return std::max(0, localFunction_.order() - 1);
107 ExpressionStorage<GradientFunctionType> function_;
108 mutable LocalGradientFunctionType localFunction_;
109 const std::string name_;
An adapter class to compute the gradient of a scalar GridFunction.
Definition: gradientfunction.hh:25
void jacobian(const PointType &x, JacobianRangeType &ret) const
gradient of local function
Definition: gradientfunction.hh:78
void evaluate(const PointType &x, RangeType &ret) const
evaluate local function
Definition: gradientfunction.hh:67
LocalFunctionWrapper< LocalMaxAdapter< GridFunction1, GridFunction2 >, typename GridFunction1::GridPartType > max(const Fem::Function< typename GridFunction1::FunctionSpaceType, GridFunction1 > &f1, const Fem::Function< typename GridFunction2::FunctionSpaceType, GridFunction2 > &f2, const std::string &name="")
Pointwise maximum of two given functions.
Definition: maxfunction.hh:121