DUNE-ACFEM (2.5.1)

meancurvaturemodel.hh
1#ifndef __DUNE_ACFEM_MODELS_MODULES_MEANCURVATUREMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_MEANCURVATUREMODEL_HH__
3
4#include "../operatorparts/modeladapter.hh"
5#include "../../expressions/parameterinterface.hh"
6
7namespace Dune {
8
9 namespace ACFem {
10
50 template<class FunctionSpace, class Parameter = TrivialParameter<typename FunctionSpace::RangeType> >
52 : public OperatorPartsExpression<MeanCurvatureOperatorParts<FunctionSpace, Parameter> >
53 {
58 public:
59 typedef Parameter ParameterType;
60
61 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
62 typedef typename FunctionSpaceType::DomainType DomainType;
63 typedef typename FunctionSpaceType::RangeType RangeType;
64 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
65 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
66
67 enum {
68 dimDomain = FunctionSpaceType::dimDomain,
69 dimRange = FunctionSpaceType::dimRange
70 };
71
72 typedef typename FunctionSpaceType::DomainFieldType DomainFieldType;
73 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
74
75 // Interface methods that need to be reimplemented
77 const std::string& name = "")
78 : regularization_(eps),
79 name_(name == "" ? "MC" : name)
80 {}
81
82 std::string name() const
83 {
84 return name_;
85 }
86
88 template<class Entity, class Point>
89 void flux(const Entity& entity,
90 const Point &x,
91 const RangeType& value,
92 const JacobianRangeType& jacobian,
93 JacobianRangeType& flux) const
94 {
95 RangeFieldType eps = regularization_().value();
96 RangeFieldType factor = std::sqrt(eps*eps + jacobian.frobenius_norm2());
97
98 flux = jacobian;
99 flux /= factor;
100 }
101
103 template<class Entity, class Point>
104 void linearizedFlux(const RangeType& uBar,
105 const JacobianRangeType& DuBar,
106 const Entity& entity,
107 const Point &x,
108 const RangeType& value,
109 const JacobianRangeType& jacobian,
110 JacobianRangeType& flux) const
111 {
112 RangeFieldType eps = regularization_().value();
113 RangeFieldType factor = std::sqrt(eps*eps + DuBar.frobenius_norm2());
114
115 flux = jacobian;
116 flux /= factor;
117
118 JacobianRangeType correction;
119
120 correction = DuBar;
121 correction *= (DuBar[0] * jacobian[0]) / factor / factor / factor;
122
123 flux -= correction;
124 }
125
127 template<class Entity, class Point>
128 void fluxDivergence(const Entity& entity,
129 const Point &x,
130 const RangeType& value,
131 const JacobianRangeType& jacobian,
132 const HessianRangeType& hessian,
133 RangeType& result) const
134 {
135 RangeFieldType eps = regularization_().value();
136 RangeFieldType factor = std::sqrt(eps*eps + jacobian.frobenius_norm2());
137
138 // This is then the trace of the Hessian
139 result = 0.;
140 for (int j = 0; j < dimDomain; ++j) {
141 result -= hessian[0][j][j];
142 }
143
144 // + the correction from the non-linearity
145 RangeFieldType correction = 0;
146 for (int i = 0; i < dimDomain; ++i) {
147 correction += jacobian[0][i] * hessian[0][i][i] * jacobian[0][i];
148 for (int j = i+1; j < dimDomain; ++j) {
149 correction += 2.0*jacobian[0][i] * hessian[0][i][j] * jacobian[0][j];
150 }
151 }
152 result += correction/factor/factor;
153 result /= factor;
154 }
155
156 protected:
157 ExpressionStorage<ParameterType> regularization_;
158 const std::string name_;
159 };
160
161 template<class FunctionSpace, class Parameter>
162 struct OperatorPartsTraits<MeanCurvatureOperatorParts<FunctionSpace, Parameter> >
163 : public DefaultOperatorPartsTraits<FunctionSpace>
164 {
167 {
168 isLinear = false,
169 isSymmetric = true,
170 isSemiDefinite = true
171 };
172
175 hasFlux = true,
176 hasSources = false,
177 hasRobinFlux = false
178 };
179 };
180
182
196 template<class Object, class Parameter = TrivialParameter<typename Object::FunctionSpaceType::RangeType> >
197 static inline
198 MeanCurvatureOperatorParts<typename Object::FunctionSpaceType, Parameter>
199 meanCurvatureOperatorParts(const Parameter& regularization,
200 const Object& object,
201 const std::string& name = "")
202 {
204 }
205
210 template<class Object, class Parameter = TrivialParameter<typename Object::FunctionSpaceType::RangeType> >
211 static inline
212 OperatorPartsAdapterModel<MeanCurvatureOperatorParts<typename Object::FunctionSpaceType, Parameter>,
213 typename Object::GridPartType>
214 meanCurvatureModel(const Parameter& regularization,
215 const Object& object,
216 const std::string& name = "")
217 {
219 typedef typename Object::GridPartType GridPartType;
220 return OperatorPartsAdapterModel<OperatorPartsType, GridPartType>(OperatorPartsType(regularization, name));
221 }
222
223
225
227
229
230 } // namespace ACFem
231
232} //Namespace Dune
233
234
235#endif // __DUNE_ACFEM_MODELS_MODULES_MEANCURVATUREMODEL_HH__
Default model implementation.
Definition: operatorparts.hh:387
Define a mean-curvature model for graphs and level-sets.
Definition: meancurvaturemodel.hh:53
Interface class for second order elliptic models.
Definition: operatorparts.hh:92
Parameters are quasi-constant quantities, like the time-step size in one time-step when solving trans...
Definition: parameterinterface.hh:80
StructureFlags
Static flags for the overall structure of the operator.
Definition: meancurvaturemodel.hh:167
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: meancurvaturemodel.hh:128
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: meancurvaturemodel.hh:104
static MeanCurvatureOperatorParts< typename Object::FunctionSpaceType, Parameter > meanCurvatureOperatorParts(const Parameter &regularization, const Object &object, const std::string &name="")
Generate a MeanCurvature-model fitting the specified object.
Definition: meancurvaturemodel.hh:199
void flux(const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, JacobianRangeType &flux) const
Evaluate in local coordinates.
Definition: meancurvaturemodel.hh:89
static OperatorPartsAdapterModel< MeanCurvatureOperatorParts< typename Object::FunctionSpaceType, Parameter >, typename Object::GridPartType > meanCurvatureModel(const Parameter &regularization, const Object &object, const std::string &name="")
Generate a mean-curvature-model fitting the specified object.
Definition: meancurvaturemodel.hh:214
ConstituentFlags
Provide information about the constituents of the model.
Definition: meancurvaturemodel.hh:174
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)