DUNE-ACFEM (unstable)

meancurvaturemodel.hh
1#ifndef __DUNE_ACFEM_MODELS_MODULES_MEANCURVATUREMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_MEANCURVATUREMODEL_HH__
3
4#include "../../tensors/tensor.hh"
5#include "../modelbase.hh"
6#include "../expressiontraits.hh"
7
8namespace Dune {
9
10 namespace ACFem::PDEModel {
11
12 using namespace Literals;
13
53 template<class FunctionSpace, class Regularization = Tensor::FieldVectorTensor<typename FunctionSpace::RangeFieldType> >
55 : public ModelBase<FunctionSpace>
56 , public Expressions::SelfExpression<MeanCurvatureModel<FunctionSpace, Regularization> >
57 , public MPL::UniqueTags<ConditionalType<ExpressionTraits<Regularization>::isVolatile, VolatileExpression, void>,
58 ConditionalType<IsConstantExprArg<Regularization>::value, ConstantExpression, void>,
59 ConditionalType<IsTypedValue<Regularization>::value, TypedValueExpression, void>,
60 SemiPositiveExpression, SymmetricModel>
61 {
64 public:
65 using RegularizationType = Regularization;
66
67 using typename BaseType::RangeFieldType;
68 using typename BaseType::RangeType;
69 using typename BaseType::JacobianRangeType;
70 using typename BaseType::HessianRangeType;
72
73 template<class RegularizationArg,
74 std::enable_if_t<(std::is_constructible<RegularizationType, RegularizationArg>::value
75 && std::is_constructible<RegularizationArg, decltype(1_f)>::value
76 ), int> = 0>
77 MeanCurvatureModel(RegularizationArg&& eps = 1_f, const std::string& name = "")
78 : regularization_(std::forward<RegularizationArg>(eps)),
79 name_(name == "" ? "MC" : name)
80 {}
81
82 template<class RegularizationArg,
83 std::enable_if_t<(std::is_constructible<RegularizationType, RegularizationArg>::value
84 && !std::is_constructible<RegularizationArg, decltype(1_f)>::value
85 ), int> = 0>
86 MeanCurvatureModel(RegularizationArg&& eps, const std::string& name = "")
87 : regularization_(std::forward<RegularizationArg>(eps)),
88 name_(name == "" ? "MC" : name)
89 {}
90
91 std::string name() const
92 {
93 return name_;
94 }
95
97 JacobianRangeType flux(const JacobianRangeType& jacobian) const
98 {
99 auto eps = regularization_;
100 return jacobian / sqrt(eps*eps + jacobian.frobenius_norm2());
101 }
102
104 JacobianRangeType linearizedFlux(const JacobianRangeType& DuBar,
105 const JacobianRangeType& jacobian) const
106 {
107 RangeFieldType eps = regularization_;
108 auto factor = sqrt(eps*eps + DuBar.frobenius_norm2());
109 return jacobian / factor - DuBar * contractInner<2>(DuBar, jacobian) / factor / factor / factor;
110 }
111
113 RangeType fluxDivergence(const JacobianRangeType& jacobian,
114 const HessianRangeType& hessian) const
115 {
116 auto eps = regularization_;
117 auto factor = std::sqrt(eps*eps + jacobian.frobenius_norm2());
118
119 // This is then the trace of the Hessian
120 RangeType result = -trace(hessian[0]);
121
122 // + the correction from the non-linearity
123 RangeFieldType correction = 0;
124 for (int i = 0; i < dimDomain; ++i) {
125 correction += jacobian[0][i] * hessian[0][i][i] * jacobian[0][i];
126 for (int j = i+1; j < dimDomain; ++j) {
127 correction += 2.0*jacobian[0][i] * hessian[0][i][j] * jacobian[0][j];
128 }
129 }
130 result += correction/factor/factor;
131 return result /= factor;
132 }
133
134 protected:
135 RegularizationType regularization_;
136 std::string name_;
137 };
138
140
154 template<class Object, class Regularization = Tensor::FieldVectorTensor<typename Object::FunctionSpaceType::RangeFieldType> >
155 auto
156 meanCurvatureModel(Regularization&& regularization,
157 const Object& object,
158 const std::string& name = "")
159 {
160 return expressionClosure(MeanCurvatureModel<typename Object::FunctionSpaceType, Regularization>(std::forward<Regularization>(regularization), name));
161 }
162
164
166
168
169 } // namespace ACFem::PDEModel
170
171 namespace ACFem {
172
174
175 }
176
177} //Namespace Dune
178
179
180#endif // __DUNE_ACFEM_MODELS_MODULES_MEANCURVATUREMODEL_HH__
Define a mean-curvature model for graphs and level-sets.
Definition: meancurvaturemodel.hh:61
constexpr decltype(auto) expressionClosure(T &&t)
Do-nothing default implementation for pathologic cases.
Definition: interface.hh:93
RangeType fluxDivergence(const JacobianRangeType &jacobian, const HessianRangeType &hessian) const
Compute the point-wise value of the flux-part of the operator, meaning the part of the differential o...
Definition: meancurvaturemodel.hh:113
JacobianRangeType flux(const JacobianRangeType &jacobian) const
Evaluate in local coordinates.
Definition: meancurvaturemodel.hh:97
JacobianRangeType linearizedFlux(const JacobianRangeType &DuBar, const JacobianRangeType &jacobian) const
Evaluate the linearized flux in local coordinates.
Definition: meancurvaturemodel.hh:104
auto meanCurvatureModel(Regularization &&regularization, const Object &object, const std::string &name="")
Generate a MeanCurvature-model fitting the specified object.
Definition: meancurvaturemodel.hh:156
constexpr auto trace(T &&t)
Trace is the contraction over all indices with the eye tensor.
Definition: expressions.hh:145
Terminals may derive from this class to express that they are expressions.
Definition: terminal.hh:25
A structure defining some basic default types and methods.
Definition: modelbase.hh:41
typename FunctionSpaceType::JacobianRangeType JacobianRangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:63
typename FunctionSpaceType::RangeType RangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:62
HessianRangeSelector< FunctionSpaceType > HessianRangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:65
typename FunctionSpaceType::RangeFieldType RangeFieldType
The type returned by classifyBoundary().
Definition: modelbase.hh:67
static constexpr int dimDomain
The type returned by classifyBoundary().
Definition: modelbase.hh:85
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)