DUNE-ACFEM (unstable)

fluidselftransportmodel.hh
1#ifndef __DUNE_ACFEM_MODELS_MODULES_FLUIDSELFTRANSPORTMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_FLUIDSELFTRANSPORTMODEL_HH__
3
4#include <dune/fem/function/localfunction/const.hh>
5
6#include "../../expressions/expressionoperations.hh"
7#include "../../expressions/terminal.hh"
8
9#include "../modelbase.hh"
10
11namespace Dune {
12
13 namespace ACFem::PDEModel {
14
53 template<class FunctionSpace>
55 : public ModelBase<FunctionSpace>
56 , public Expressions::SelfExpression<FluidSelfTransportModel<FunctionSpace> >
58 {
61 public:
62 using typename BaseType::RangeFieldType;
63 using typename BaseType::DomainType;
64 using typename BaseType::RangeType;
65 using typename BaseType::JacobianRangeType;
68
69 enum {
70 dimWorld = dimDomain
71 };
72
73 static_assert(dimDomain == dimRange && dimDomain == dimWorld,
74 "This is meant for dimensionworld vector-fields, "
75 "like fluids, deformations etc.");
76
77 // Interface methods that need to be reimplemented
78
79 FluidSelfTransportModel(const std::string& name = "")
80 : name_(name == "" ? "(-U_iU_jD_iPhi_j+Bndry)" : name)
81 {}
82
83 std::string name() const
84 {
85 return name_;
86 }
87
89 template<class Intersection>
90 auto classifyBoundary(const Intersection& intersection)
91 {
92 // true is correct as higher-level code has to take care of
93 // the Dirichlet-(non-Dirichlet) splitting of the boundary.
94 return std::make_pair(true, std::bitset<dimRange>());
95 }
96
98 JacobianRangeType flux(const RangeType& value) const
99 {
100 // We need to provide the tensor-product of value with itself.
102 for (int i = 0; i < dimWorld; ++i) {
103 flux[i][i] = value[i] * value[i];
104 for (int j = i+1; j < dimWorld; ++j) {
105 flux[i][j] = flux[j][i] = - (value[i] * value[j]);
106 }
107 }
108 return flux;
109 }
110
112 template<class Point>
113 JacobianRangeType linearizedFlux(const RangeType& uBar, const RangeType& value) const
114 {
115 // actually the sum of tensor products ...
117 for (int i = 0; i < dimWorld; ++i) {
118 flux[i][i] = 2.0 * uBar[i] * value[i];
119 for (int j = i+1; j < dimWorld; ++j) {
120 flux[i][j] = flux[j][i] = - (uBar[i] * value[j] + uBar[j] * value[i]);
121 }
122 }
123 return flux;
124 }
125
127 RangeType fluxDivergence(const RangeType& value, const JacobianRangeType& jacobian) const
128 {
129 // I think this is correct then ....
130 RangeType result;
131 jacobian.mv(value, result);
132 return result;
133 }
134
135 RangeType robinFlux(const DomainType& unitOuterNormal,
136 const RangeType& value) const
137 {
138 RangeType result = value;
139 return result *= (value * unitOuterNormal); // scalar product
140 }
141
142 RangeType linearizedRobinFlux(const RangeType& uBar,
143 const DomainType& unitOuterNormal,
144 const RangeType& value) const
145 {
146 RangeType result;
147 RangeFieldType flowBar(0), flow(0);
148 for (int i = 0; i < dimWorld; ++i) {
149 flowBar += unitOuterNormal[i] * uBar[i];
150 flow += unitOuterNormal[i] * value[i];
151 }
152 for (int i = 0; i < dimWorld; ++i) {
153 result[i] = flow * uBar[i] + flowBar * value[i];
154 }
155 return result;
156 }
157
158 protected:
159 std::string name_;
160 };
161
163
173 template<class Object>
174 static inline auto
175 fluidSelfTransportModel(const Object& object, const std::string& name = "")
176 {
178 }
179
181
183
185
186 } // namespace ACFem::PDEModel
187
188 namespace ACFem {
189
191
192 }
193
194} //Namespace Dune
195
196
197#endif // __DUNE_ACFEM_MODELS_MODULES_FLUIDSELFTRANSPORTMODEL_HH__
Define a model for the "Navier-Stokes" non-lineariry.
Definition: fluidselftransportmodel.hh:58
constexpr decltype(auto) expressionClosure(T &&t)
Do-nothing default implementation for pathologic cases.
Definition: interface.hh:93
JacobianRangeType flux(const RangeType &value) const
Evaluate in local coordinates.
Definition: fluidselftransportmodel.hh:98
auto classifyBoundary(const Intersection &intersection)
Bind to the given intersection and classify the components w.r.t.
Definition: fluidselftransportmodel.hh:90
static auto fluidSelfTransportModel(const Object &object, const std::string &name="")
Generate a Navier-Stokes non-linearity fitting the given object.
Definition: fluidselftransportmodel.hh:175
RangeType fluxDivergence(const RangeType &value, const JacobianRangeType &jacobian) const
Compute the point-wise value of the flux-part of the operator, meaning the part of the differential o...
Definition: fluidselftransportmodel.hh:127
JacobianRangeType linearizedFlux(const RangeType &uBar, const RangeType &value) const
Evaluate the linearized flux in local coordinates.
Definition: fluidselftransportmodel.hh:113
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::DomainType DomainType
The type returned by classifyBoundary().
Definition: modelbase.hh:61
typename FunctionSpaceType::RangeType RangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:62
static constexpr int dimRange
The type returned by classifyBoundary().
Definition: modelbase.hh:86
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
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 (Jul 15, 22:36, 2024)