1#ifndef __DUNE_ACFEM_MODELS_MODULES_WEAKDIVERGENCEMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_WEAKDIVERGENCEMODEL_HH__
4#include "../operatorparts/modeladapter.hh"
47 template<
class Gr
idFunction>
49 :
public OperatorPartsExpression<WeakDivergenceOperatorParts<GridFunction> >
55 typedef typename GridFunction::LocalFunctionType LocalFunctionType;
57 typedef GridFunction WeakDivergenceFunctionType;
58 typedef typename WeakDivergenceFunctionType::DiscreteFunctionSpaceType::FunctionSpaceType WeakDivergenceFunctionSpaceType;
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(dimRange == 1 && dimDomain == dimWorld,
73 "This is only meant for dimRange == 1 and dimDomain == dimWorld.");
76 const std::string& name =
"")
77 : function_(function),
78 localFunction_(function_()),
79 name_(name ==
"" ?
"(div " + 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 WeakDivergenceFunctionType::RangeType dataValue;
104 localFunction_.evaluate(x, dataValue);
109 for (
int i = 0; i < FunctionSpaceType::dimRange; ++i) {
110 flux[i] -= dataValue;
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 WeakDivergenceFunctionType::JacobianRangeType divergenceData;
139 localFunction_.jacobian(x, divergenceData);
142 for (
int i = 0; i < dimWorld; ++i) {
143 result[0] += divergenceData[i][i];
149 mutable LocalFunctionType localFunction_;
150 const std::string name_;
153 template<
class Gr
idFunction>
154 struct OperatorPartsTraits<WeakDivergenceOperatorParts<GridFunction> >
155 :
public DefaultOperatorPartsTraits<typename GridFunction::FunctionSpaceType::ScalarFunctionSpaceType>
162 isSemiDefinite =
true
169 hasRobinFlux =
false,
180 template<
class Gr
idFunction>
182 WeakDivergenceOperatorParts<GridFunction>
183 weakDivergenceOperatorParts(
const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>& f,
184 const std::string& name =
"")
186 typedef WeakDivergenceOperatorParts<GridFunction> OperatorPartsType;
187 return OperatorPartsType(f, name);
195 template<
class Gr
idFunction>
197 OperatorPartsAdapterModel<WeakDivergenceOperatorParts<GridFunction>,
198 typename GridFunction::GridPartType>
200 const std::string& name =
"")
203 typedef typename GridFunction::GridPartType GridPartType;
204 return OperatorPartsAdapterModel<OperatorPartsType, GridPartType>(OperatorPartsType(f, name));
Default model implementation.
Definition: operatorparts.hh:387
Interface class for second order elliptic models.
Definition: operatorparts.hh:92
For a given grid-function define a model implementing the weak divergence.
Definition: weakdivergencemodel.hh:50
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: weakdivergencemodel.hh:131
StructureFlags
Static flags for the overall structure of the operator.
Definition: weakdivergencemodel.hh:159
void flux(const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, JacobianRangeType &flux) const
Evaluate in local coordinates.
Definition: weakdivergencemodel.hh:97
static OperatorPartsAdapterModel< WeakDivergenceOperatorParts< GridFunction >, typename GridFunction::GridPartType > weakDivergenceModel(const Fem::Function< typename GridFunction::FunctionSpaceType, GridFunction > &f, const std::string &name="")
Generate a weak divergence model fitting the specified object.
Definition: weakdivergencemodel.hh:199
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: weakdivergencemodel.hh:116
ConstituentFlags
Provide information about the constituents of the model.
Definition: weakdivergencemodel.hh:166
Traits-template which has to be specialized for each individual model.
Definition: operatorparts.hh:36