1#ifndef __DUNE_ACFEM_MODELS_MODULES_DIVERGENCEMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_DIVERGENCEMODEL_HH__
4#include "../operatorparts/modeladapter.hh"
38 template<
class Gr
idFunction>
40 :
public OperatorPartsExpression<DivergenceOperatorParts<GridFunction> >
46 typedef typename GridFunction::LocalFunctionType LocalFunctionType;
48 typedef GridFunction DivergenceFunctionType;
49 typedef typename DivergenceFunctionType::DiscreteFunctionSpaceType::FunctionSpaceType DivergenceFunctionSpaceType;
50 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
52 typedef typename FunctionSpaceType::DomainType DomainType;
53 typedef typename FunctionSpaceType::RangeType RangeType;
54 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
55 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
58 dimDomain = FunctionSpaceType::dimDomain,
59 dimRange = FunctionSpaceType::dimRange,
63 static_assert(dimRange == 1 && dimDomain == dimWorld,
64 "This is meant for dimRange = 1, i.e. velocity divergences and such.");
67 const std::string& name =
"")
68 : function_(function),
69 localFunction_(function_()),
70 name_(name ==
"" ?
"(div " + function_().name() +
")" : name)
73 std::string name()
const
80 template<
class Entity>
81 void setEntity(
const Entity& entity)
const
83 localFunction_.init(entity);
87 template<
class Entity,
class Po
int>
90 const RangeType& value,
91 const JacobianRangeType& jacobian,
92 RangeType& result)
const
94 typename DivergenceFunctionType::JacobianRangeType divJacobian;
95 localFunction_.jacobian(x, divJacobian);
98 for (
int i = 0; i < FunctionSpaceType::dimDomain; ++i) {
99 result[0] += divJacobian[i][i];
104 template<
class Entity,
class Po
int>
106 const JacobianRangeType& DuBar,
107 const Entity& entity,
109 const RangeType& value,
110 const JacobianRangeType& jacobian,
111 RangeType& result)
const
118 mutable LocalFunctionType localFunction_;
119 const std::string name_;
122 template<
class Gr
idFunction>
123 struct OperatorPartsTraits<DivergenceOperatorParts<GridFunction> >
124 :
public DefaultOperatorPartsTraits<typename Fem::ToNewDimRangeFunctionSpace<typename GridFunction::FunctionSpaceType, 1>::Type>
127 static_assert(GridFunction::DiscreteFunctionSpaceType::FunctionSpaceType::dimRange
129 GridFunction::DiscreteFunctionSpaceType::FunctionSpaceType::dimDomain,
130 "The divergence model is only for dimDomain-valued grid-functions defined");
137 isSemiDefinite =
true,
144 hasRobinFlux =
false,
155 template<
class Gr
idFunction>
157 DivergenceOperatorParts<GridFunction>
158 divergenceOperatorParts(
const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>& f,
159 const std::string& name =
"")
161 typedef DivergenceOperatorParts<GridFunction> OperatorPartsType;
162 return OperatorPartsType(f, name);
169 template<
class Gr
idFunction>
171 OperatorPartsAdapterModel<DivergenceOperatorParts<GridFunction>,
172 typename GridFunction::GridPartType>
173 divergenceModel(
const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>& f,
174 const std::string& name =
"")
177 typedef typename GridFunction::GridPartType GridPartType;
178 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 divergence.
Definition: divergencemodel.hh:41
Interface class for second order elliptic models.
Definition: operatorparts.hh:92
ConstituentFlags
Provide information about the constituents of the model.
Definition: divergencemodel.hh:141
void source(const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, RangeType &result) const
The zero-order term as function of local coordinates.
Definition: divergencemodel.hh:88
void linearizedSource(const RangeType &uBar, const JacobianRangeType &DuBar, const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, RangeType &result) const
The linearized source term as function of local coordinates.
Definition: divergencemodel.hh:105
StructureFlags
Static flags for the overall structure of the operator.
Definition: divergencemodel.hh:134
static OperatorPartsAdapterModel< DivergenceOperatorParts< GridFunction >, typename GridFunction::GridPartType > divergenceModel(const Fem::Function< typename GridFunction::FunctionSpaceType, GridFunction > &f, const std::string &name="")
Generate a Laplacian-model fitting the specified object.
Definition: divergencemodel.hh:173
Traits-template which has to be specialized for each individual model.
Definition: operatorparts.hh:36