1#ifndef __DUNE_ACFEM_MODELS_MODULES_GRADIENTMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_GRADIENTMODEL_HH__
4#include "../operatorparts/modeladapter.hh"
47 template<
class Gr
idFunction>
49 :
public OperatorPartsExpression<GradientOperatorParts<GridFunction> >
55 typedef typename GridFunction::LocalFunctionType LocalFunctionType;
57 typedef GridFunction GradientFunctionType;
58 typedef typename GradientFunctionType::DiscreteFunctionSpaceType::FunctionSpaceType GradientFunctionSpaceType;
59 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
61 typedef typename FunctionSpaceType::DomainType DomainType;
62 typedef typename FunctionSpaceType::RangeType RangeType;
63 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
64 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
67 dimDomain = FunctionSpaceType::dimDomain,
68 dimRange = FunctionSpaceType::dimRange,
72 static_assert(dimDomain == dimRange && dimDomain == dimWorld,
73 "This is meant for dimDomain == dimRange, i.e. pressure gradients and such.");
76 const std::string& name =
"")
77 : function_(function),
78 localFunction_(function_()),
79 name_(name ==
"" ?
"(grad " + function_().name() +
")" : name)
82 std::string name()
const
89 template<
class Entity>
90 void setEntity(
const Entity& entity)
const
92 localFunction_.init(entity);
96 template<
class Entity,
class Po
int>
97 void flux(
const Entity& entity,
99 const RangeType& value,
100 const JacobianRangeType& jacobian,
101 JacobianRangeType&
flux)
const
103 typename GradientFunctionType::RangeType scalarValue;
104 localFunction_.evaluate(x, scalarValue);
109 for (
int i = 0; i < FunctionSpaceType::dimDomain; ++i) {
110 flux[i][i] -= scalarValue;
115 template<
class Entity,
class Po
int>
117 const JacobianRangeType& DuBar,
118 const Entity& entity,
120 const RangeType& value,
121 const JacobianRangeType& jacobian,
122 JacobianRangeType&
flux)
const
130 template<
class Entity,
class Po
int>
133 const RangeType& value,
134 const JacobianRangeType& jacobian,
135 const HessianRangeType& hessian,
136 RangeType& result)
const
138 typename GradientFunctionType::JacobianRangeType
gradient;
139 localFunction_.jacobian(x,
gradient);
146 mutable LocalFunctionType localFunction_;
147 const std::string name_;
150 template<
class Gr
idFunction>
151 struct OperatorPartsTraits<GradientOperatorParts<GridFunction> >
152 :
public DefaultOperatorPartsTraits<typename Fem::ToNewDimRangeFunctionSpace<typename GridFunction::FunctionSpaceType,
153 GridFunction::FunctionSpaceType::dimDomain>::Type>
156 static_assert(GridFunction::DiscreteFunctionSpaceType::FunctionSpaceType::dimRange == 1,
157 "The gradient model is only for scalar grid-functions defined");
164 isSemiDefinite =
true
171 hasRobinFlux =
false,
186 template<
class Gr
idFunction>
188 GradientOperatorParts<GridFunction>
190 const std::string& name =
"")
195 template<
class Gr
idFunction>
197 OperatorPartsAdapterModel<GradientOperatorParts<GridFunction>,
198 typename GridFunction::GridPartType>
199 gradientModel(
const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>& f,
200 const std::string& name =
"")
202 typedef GradientOperatorParts<GridFunction> OperatorPartsType;
203 typedef typename GridFunction::GridPartType GridPartType;
204 return OperatorPartsAdapterModel<OperatorPartsType, GridPartType>(OperatorPartsType(f, name));
Default model implementation.
Definition: operatorparts.hh:387
For a given grid-function define a model implementing the weak gradient.
Definition: gradientmodel.hh:50
Interface class for second order elliptic models.
Definition: operatorparts.hh:92
LocalFunctionWrapper< LocalGradientAdapter< GridFunction >, typename GridFunction::GridPartType > gradient(const Fem::Function< typename GridFunction::FunctionSpaceType, GridFunction > &f_, const std::string &name="")
Take the gradient of a given function.
Definition: basicfunctions.hh:145
void fluxDivergence(const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, const HessianRangeType &hessian, RangeType &result) const
Compute the point-wise value of the flux-part of the operator, meaning the part of the differential o...
Definition: gradientmodel.hh:131
void linearizedFlux(const RangeType &uBar, const JacobianRangeType &DuBar, const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, JacobianRangeType &flux) const
Evaluate the linearized flux in local coordinates.
Definition: gradientmodel.hh:116
StructureFlags
Static flags for the overall structure of the operator.
Definition: gradientmodel.hh:161
void flux(const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, JacobianRangeType &flux) const
Evaluate in local coordinates.
Definition: gradientmodel.hh:97
static GradientOperatorParts< GridFunction > gradientOperatorParts(const Fem::Function< typename GridFunction::FunctionSpaceType, GridFunction > &f, const std::string &name="")
Generate a Gradient-model fitting the specified object.
Definition: gradientmodel.hh:189
ConstituentFlags
Provide information about the constituents of the model.
Definition: gradientmodel.hh:168
Traits-template which has to be specialized for each individual model.
Definition: operatorparts.hh:36