DUNE-ACFEM (unstable)

gradientmodel.hh
1#ifndef __DUNE_ACFEM_MODELS_MODULES_GRADIENTMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_GRADIENTMODEL_HH__
3
4#include <dune/fem/gridpart/common/gridpart.hh>
5
6#include "../../common/gridfunctionspace.hh"
7#include "../../expressions/terminal.hh"
8
9#include "../modelbase.hh"
10
11namespace Dune {
12
13 namespace ACFem::PDEModel {
14
44 template<class FunctionSpace>
46 : public ModelBase<FunctionSpace,
47 typename Fem::ToNewDimRangeFunctionSpace<FunctionSpace, FunctionSpace::dimDomain>::Type>
48 , public Expressions::SelfExpression<GradientModel<FunctionSpace> >
50 {
51 static_assert(FunctionSpace::dimRange == 1, "Domain function space must be scalar");
52 using ThisType = GradientModel;
53 using BaseType = ModelBase<FunctionSpace,
54 typename Fem::ToNewDimRangeFunctionSpace<FunctionSpace, FunctionSpace::dimDomain>::Type>;
55 public:
56 using typename BaseType::DomainType;
57 using typename BaseType::DomainRangeType;
59 using typename BaseType::RangeRangeType;
62
63 GradientModel(const std::string& name)
64 : name_(name == "" ? "(grad p)" : name)
65 {}
66
67 std::string name() const
68 {
69 return name_;
70 }
71
73 auto linearizedFlux(const DomainRangeType& value) const
74 {
75 RangeJacobianRangeType result(0);
76 for (int i = 0; i < rangeDimRange; ++i) {
77 result[i][i] = -value;
78 }
79 return result;
80 }
81
82 auto fluxDivergence(const DomainJacobianRangeType& jacobian) const
83 {
84 return jacobian[0];
85 }
86
87 auto linearizedRobinFlux(const DomainType& unitOuterNormal,
88 const DomainRangeType& value) const
89 {
90 return RangeRangeType(unitOuterNormal) *= value;
91 }
92
94 template<class Intersection>
95 auto classifyBoundary(const Intersection& intersection) const
96 {
97 // true is correct as higher-level code has to take care of
98 // the Dirichlet-(non-Dirichlet) splitting of the boundary.
99 return std::make_pair(true, std::bitset<rangeDimRange>());
100 }
101
102 protected:
103 const std::string name_;
104 };
105
107
108
119 template<class Object,
120 std::enable_if_t<Object::FunctionSpaceType::ScalarFunctionSpaceType::dimRange == 1,
121 int> = 0>
122 static inline auto
123 gradientModel(const Object& object, const std::string& name = "")
124 {
126 }
127
131 template<class GridPartTraits>
132 static inline auto
133 gradientModel(const Fem::GridPartInterface<GridPartTraits>& gridPart,
134 const std::string& name = "")
135 {
136 typedef typename Fem::GridPartInterface<GridPartTraits>::GridPartType GridPartType;
137 return gradientModel(ScalarGridFunctionSpace<GridPartType>{}, name);
138 }
139
141
143
145
146 } // namespace ACFem::PDEModel
147
148 namespace ACFem {
149
151
152 }
153
154} //Namespace Dune
155
156
157#endif // __DUNE_ACFEM_MODELS_MODULES_GRADIENTMODEL_HH__
A gradient model, for example to implement gradient constraints.
Definition: gradientmodel.hh:50
static constexpr int rangeDimRange
Definition: modelbase.hh:90
constexpr decltype(auto) expressionClosure(T &&t)
Do-nothing default implementation for pathologic cases.
Definition: interface.hh:93
auto linearizedFlux(const DomainRangeType &value) const
The linearized source term as function of local coordinates.
Definition: gradientmodel.hh:73
auto classifyBoundary(const Intersection &intersection) const
Bind to the given intersection and classify the components w.r.t.
Definition: gradientmodel.hh:95
static auto gradientModel(const Fem::GridPartInterface< GridPartTraits > &gridPart, const std::string &name="")
Generate a GradientModel from a GridPart, using ctype as field and dimensionWorld as dimension.
Definition: gradientmodel.hh:133
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
static constexpr int rangeDimRange
Definition: modelbase.hh:90
typename DomainFunctionSpaceType::JacobianRangeType DomainJacobianRangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:71
typename RangeFunctionSpaceType::RangeType RangeRangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:77
typename FunctionSpaceType::DomainType DomainType
The type returned by classifyBoundary().
Definition: modelbase.hh:61
typename DomainFunctionSpaceType::RangeType DomainRangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:69
typename RangeFunctionSpaceType::JacobianRangeType RangeJacobianRangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:79
A tag structure signalling that this expression carries its value in its type.
Definition: tags.hh:100
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jan 5, 23:30, 2025)