DUNE-ACFEM (2.5.1)

weakdivergencemodel.hh
1#ifndef __DUNE_ACFEM_MODELS_MODULES_WEAKDIVERGENCEMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_WEAKDIVERGENCEMODEL_HH__
3
4#include "../operatorparts/modeladapter.hh"
5
6namespace Dune {
7
8 namespace ACFem {
9
47 template<class GridFunction>
49 : public OperatorPartsExpression<WeakDivergenceOperatorParts<GridFunction> >
50 {
55 typedef typename GridFunction::LocalFunctionType LocalFunctionType;
56 public:
57 typedef GridFunction WeakDivergenceFunctionType;
58 typedef typename WeakDivergenceFunctionType::DiscreteFunctionSpaceType::FunctionSpaceType WeakDivergenceFunctionSpaceType;
59 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
60
61 typedef typename FunctionSpaceType::DomainType DomainType;
62 typedef typename FunctionSpaceType::RangeType RangeType;
63 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
64 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
65
66 enum {
67 dimDomain = FunctionSpaceType::dimDomain,
68 dimRange = FunctionSpaceType::dimRange,
69 dimWorld = dimDomain,
70 };
71
72 static_assert(dimRange == 1 && dimDomain == dimWorld,
73 "This is only meant for dimRange == 1 and dimDomain == dimWorld.");
74
75 WeakDivergenceOperatorParts(const Fem::Function<WeakDivergenceFunctionSpaceType, WeakDivergenceFunctionType>& function,
76 const std::string& name = "")
77 : function_(function),
78 localFunction_(function_()),
79 name_(name == "" ? "(div " + function_().name() + ")" : name)
80 {}
81
82 std::string name() const
83 {
84 return name_;
85 }
86
87 // Interface methods that need to be reimplemented
88
89 template<class Entity>
90 void setEntity(const Entity& entity) const
91 {
92 localFunction_.init(entity);
93 }
94
96 template<class Entity, class Point>
97 void flux(const Entity& entity,
98 const Point &x,
99 const RangeType& value,
100 const JacobianRangeType& jacobian,
101 JacobianRangeType& flux) const
102 {
103 typename WeakDivergenceFunctionType::RangeType dataValue;
104 localFunction_.evaluate(x, dataValue);
105
106 flux = 0.;
107
108 // value * IdentityMatrix
109 for (int i = 0; i < FunctionSpaceType::dimRange; ++i) {
110 flux[i] -= dataValue;
111 }
112 }
113
115 template<class Entity, class Point>
116 void linearizedFlux (const RangeType& uBar,
117 const JacobianRangeType& DuBar,
118 const Entity& entity,
119 const Point &x,
120 const RangeType& value,
121 const JacobianRangeType& jacobian,
122 JacobianRangeType& flux) const
123 {
124 flux = 0.;
125 }
126
130 template<class Entity, class Point>
131 void fluxDivergence(const Entity& entity,
132 const Point &x,
133 const RangeType& value,
134 const JacobianRangeType& jacobian,
135 const HessianRangeType& hessian,
136 RangeType& result) const
137 {
138 typename WeakDivergenceFunctionType::JacobianRangeType divergenceData;
139 localFunction_.jacobian(x, divergenceData);
140
141 result[0] = 0.;
142 for (int i = 0; i < dimWorld; ++i) {
143 result[0] += divergenceData[i][i];
144 }
145 }
146
147 protected:
149 mutable LocalFunctionType localFunction_;
150 const std::string name_;
151 };
152
153 template<class GridFunction>
154 struct OperatorPartsTraits<WeakDivergenceOperatorParts<GridFunction> >
155 : public DefaultOperatorPartsTraits<typename GridFunction::FunctionSpaceType::ScalarFunctionSpaceType>
156 {
159 {
160 isLinear = true, // it is even constant
161 isSymmetric = true, // it is even constant
162 isSemiDefinite = true // it is even constant
163 };
164
167 hasFlux = true, // tested by divergence of test functions
168 hasSources = false, // none, after integration by parts
169 hasRobinFlux = false,
170 };
171 };
172
174
175
180 template<class GridFunction>
181 static inline
182 WeakDivergenceOperatorParts<GridFunction>
183 weakDivergenceOperatorParts(const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>& f,
184 const std::string& name = "")
185 {
186 typedef WeakDivergenceOperatorParts<GridFunction> OperatorPartsType;
187 return OperatorPartsType(f, name);
188 }
189
190
195 template<class GridFunction>
196 static inline
197 OperatorPartsAdapterModel<WeakDivergenceOperatorParts<GridFunction>,
198 typename GridFunction::GridPartType>
199 weakDivergenceModel(const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>& f,
200 const std::string& name = "")
201 {
202 typedef WeakDivergenceOperatorParts<GridFunction> OperatorPartsType;
203 typedef typename GridFunction::GridPartType GridPartType;
204 return OperatorPartsAdapterModel<OperatorPartsType, GridPartType>(OperatorPartsType(f, name));
205 }
206
208
210
212
213 } // namespace ACFem
214
215} //Namespace Dune
216
217
218#endif // __DUNE_ACFEM_MODELS_MODULES_WEAKDIVERGENCEMODEL_HH__
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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)