DUNE-ACFEM (2.5.1)

divergencemodel.hh
1#ifndef __DUNE_ACFEM_MODELS_MODULES_DIVERGENCEMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_DIVERGENCEMODEL_HH__
3
4#include "../operatorparts/modeladapter.hh"
5
6namespace Dune {
7
8 namespace ACFem {
9
38 template<class GridFunction>
40 : public OperatorPartsExpression<DivergenceOperatorParts<GridFunction> >
41 {
46 typedef typename GridFunction::LocalFunctionType LocalFunctionType;
47 public:
48 typedef GridFunction DivergenceFunctionType;
49 typedef typename DivergenceFunctionType::DiscreteFunctionSpaceType::FunctionSpaceType DivergenceFunctionSpaceType;
50 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
51
52 typedef typename FunctionSpaceType::DomainType DomainType;
53 typedef typename FunctionSpaceType::RangeType RangeType;
54 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
55 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
56
57 enum {
58 dimDomain = FunctionSpaceType::dimDomain,
59 dimRange = FunctionSpaceType::dimRange,
60 dimWorld = dimDomain
61 };
62
63 static_assert(dimRange == 1 && dimDomain == dimWorld,
64 "This is meant for dimRange = 1, i.e. velocity divergences and such.");
65
66 DivergenceOperatorParts(const Fem::Function<DivergenceFunctionSpaceType, DivergenceFunctionType>& function,
67 const std::string& name = "")
68 : function_(function),
69 localFunction_(function_()),
70 name_(name == "" ? "(div " + function_().name() + ")" : name)
71 {}
72
73 std::string name() const
74 {
75 return name_;
76 }
77
78 // Interface methods that need to be reimplemented
79
80 template<class Entity>
81 void setEntity(const Entity& entity) const
82 {
83 localFunction_.init(entity);
84 }
85
87 template<class Entity, class Point>
88 void source(const Entity& entity,
89 const Point &x,
90 const RangeType& value,
91 const JacobianRangeType& jacobian,
92 RangeType& result) const
93 {
94 typename DivergenceFunctionType::JacobianRangeType divJacobian;
95 localFunction_.jacobian(x, divJacobian);
96
97 result = 0;
98 for (int i = 0; i < FunctionSpaceType::dimDomain; ++i) {
99 result[0] += divJacobian[i][i];
100 }
101 }
102
104 template<class Entity, class Point>
105 void linearizedSource(const RangeType& uBar,
106 const JacobianRangeType& DuBar,
107 const Entity& entity,
108 const Point &x,
109 const RangeType& value,
110 const JacobianRangeType& jacobian,
111 RangeType& result) const
112 {
113 result = 0;
114 }
115
116 protected:
118 mutable LocalFunctionType localFunction_;
119 const std::string name_;
120 };
121
122 template<class GridFunction>
123 struct OperatorPartsTraits<DivergenceOperatorParts<GridFunction> >
124 : public DefaultOperatorPartsTraits<typename Fem::ToNewDimRangeFunctionSpace<typename GridFunction::FunctionSpaceType, 1>::Type>
125 {
126 //Only for scalar GridFunction classes
127 static_assert(GridFunction::DiscreteFunctionSpaceType::FunctionSpaceType::dimRange
128 ==
129 GridFunction::DiscreteFunctionSpaceType::FunctionSpaceType::dimDomain,
130 "The divergence model is only for dimDomain-valued grid-functions defined");
131
134 {
135 isLinear = true, // it is even constant
136 isSymmetric = true, // it is even constant
137 isSemiDefinite = true, // it is even constant
138 };
139
142 hasFlux = false,
143 hasSources = true,
144 hasRobinFlux = false,
145 };
146 };
147
149
150
155 template<class GridFunction>
156 static inline
157 DivergenceOperatorParts<GridFunction>
158 divergenceOperatorParts(const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>& f,
159 const std::string& name = "")
160 {
161 typedef DivergenceOperatorParts<GridFunction> OperatorPartsType;
162 return OperatorPartsType(f, name);
163 }
164
169 template<class GridFunction>
170 static inline
171 OperatorPartsAdapterModel<DivergenceOperatorParts<GridFunction>,
172 typename GridFunction::GridPartType>
173 divergenceModel(const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>& f,
174 const std::string& name = "")
175 {
176 typedef DivergenceOperatorParts<GridFunction> OperatorPartsType;
177 typedef typename GridFunction::GridPartType GridPartType;
178 return OperatorPartsAdapterModel<OperatorPartsType, GridPartType>(OperatorPartsType(f, name));
179 }
180
182
184
186
187 } // namespace ACFem
188
189} //Namespace Dune
190
191
192#endif // __DUNE_ACFEM_MODELS_MODULES_DIVERGENCEMODEL_HH__
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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Aug 13, 22:30, 2024)