DUNE-ACFEM (unstable)

pmassmodel.hh
1#ifndef __DUNE_ACFEM_MODELS_MODULES_PMASSMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_PMASSMODEL_HH__
3
4#include "../../common/literals.hh"
5#include "../../expressions/terminal.hh"
6
7#include "../modelbase.hh"
8#include "../expressiontraits.hh"
9
10namespace Dune {
11
12 namespace ACFem::PDEModel {
13
14 using namespace Literals;
15
43 template<class FunctionSpace, class PField>
45 : public ModelBase<FunctionSpace>
46 , public Expressions::SelfExpression<P_MassModel<FunctionSpace, PField> >
47 , public MPL::UniqueTags<ConditionalType<ExpressionTraits<PField>::isVolatile, VolatileExpression, void>,
48 ConditionalType<IsConstantExprArg<PField>::value, ConstantExpression, void>,
49 ConditionalType<IsTypedValue<PField>::value, TypedValueExpression, void>,
50 PositiveExpression,
51 SymmetricModel>
52 {
53 using ThisType = P_MassModel;
55 public:
56 using typename BaseType::RangeFieldType;
57 using typename BaseType::RangeType;
58 using PFieldType = PField;
59 using ExponentType = std::decay_t<decltype(std::declval<PFieldType>() - 2_f)>;
60
61 template<class P, std::enable_if_t<std::is_constructible<PFieldType, P>::value, int> = 0>
62 P_MassModel(P&& exponent, const std::string& name = "")
63 : exponent_(PFieldType(exponent) - 2_f),
64 name_(name == "" ? "(|U|^" + toString(exponent_) + " U)" : name)
65 {}
66
67 std::string name() const
68 {
69 return name_;
70 }
71
73 RangeType source(const RangeType& value) const
74 {
75 auto factor = std::pow(value.two_norm2(), 0.5*exponent_);
76
77 auto result = value;
78 return result *= factor;
79 }
80
83 const RangeType& value) const
84 {
85 auto norm = uBar.two_norm2();
86
87 auto result = value;
88
89 if (exponent_ == 0.0) {
90 return result;
91 }
92
93 result *= std::pow(norm, 0.5 * exponent_);
94
95 auto tmp = uBar;
96
97 tmp *= exponent_*std::pow(norm, 0.5*exponent_ - 1.) * (uBar * value);
98
99 return result += tmp;
100 }
101
102 const ExponentType& exponent() const { return exponent_; }
103
104 constexpr auto p() const { return exponent_ + 2_f; }
105
106 protected:
107 ExponentType exponent_;
108 std::string name_;
109 };
110
112
127 template<class Object, class PField>
128 constexpr auto p_MassModel(PField&& p, const Object& object, const std::string& name = "")
129 {
131 }
132
134
136
138
139 } // namespace ACFem::PDEModel
140
141 namespace ACFem {
142
144
145 }
146
147} //Namespace Dune
148
149
150#endif // __DUNE_ACFEM_MODELS_MODULES_PMASSMODEL_HH__
A simplistic non-linear example.
Definition: pmassmodel.hh:52
constexpr decltype(auto) expressionClosure(T &&t)
Do-nothing default implementation for pathologic cases.
Definition: interface.hh:93
RangeType source(const RangeType &value) const
The zero-order term as function of local coordinates.
Definition: pmassmodel.hh:73
RangeType linearizedSource(const RangeType &uBar, const RangeType &value) const
The linearized source term as function of local coordinates.
Definition: pmassmodel.hh:82
constexpr auto p_MassModel(PField &&p, const Object &object, const std::string &name="")
Generate Model for a (weak, of course) Mass.
Definition: pmassmodel.hh:128
auto pow(T1 &&t1, T2 &&t2)
Power operations with scalar exponents are promoted to component-wise power operations by multiplying...
Definition: expressions.hh:525
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::RangeType RangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:62
typename FunctionSpaceType::RangeFieldType RangeFieldType
The type returned by classifyBoundary().
Definition: modelbase.hh:67
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)