KASKADE 7 development version
Loading...
Searching...
No Matches
boundaryConditions.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the library KASKADE 7 */
4/* https://www.zib.de/research/projects/kaskade7-finite-element-toolbox */
5/* */
6/* Copyright (C) 2019-2025 Zuse Institute Berlin */
7/* */
8/* KASKADE 7 is distributed under the terms of the ZIB Academic License. */
9/* see $KASKADE/academic.txt */
10/* */
11/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12
13#ifndef BOUNDARYCONDITIONS_HH
14#define BOUNDARYCONDITIONS_HH
15
17
18namespace Kaskade
19{
33 template <class Functional>
35 {
36 using Scalar = typename Functional::Scalar;
37 static constexpr int dim = Functional::AnsatzVars::Grid::dimension;
38
39 public:
45 HomogeneousNeumannBoundary(Functional const&, typename Functional::OriginVars::VariableSet const&, int) {}
46
53
54 template <class FaceIterator>
55 void moveTo(FaceIterator const&) {}
56
57 template <class Evaluators>
59
60 Scalar d0() const { return 0; }
61
62 template <int row>
67
68 template <int row, int col>
73 };
74
87 template <class GridView, int components, class ScalarType=typename GridView::ctype>
89 {
90 using Scalar = ScalarType;
91 static constexpr int dim = GridView::dimension;
92 static constexpr int dimworld = GridView::dimensionworld;
93
94 public:
95
97
104 void moveTo(typename GridView::IntersectionIterator const& fi)
105 {
106 // Compute h^{-2}. h is volume^(1/(dim-1)). Take care of special case for dim=1.
107 if (dim > 1)
108 weight = std::pow(fi->geometry().volume(),-2/(dim-1));
109 else
110 weight = 1;
111 }
112
121 void setBoundaryData(Scalar gamma_, Vector const& u, Vector const& ud)
122 {
123 gamma = gamma_;
124 assert(gamma>=0);
125 deviation = u-ud;
126 }
127
128 Scalar d0() const { return 0.5*gamma*weight * (deviation*deviation); }
129
131 {
132 return gamma*weight*argT.value[0]*deviation;
133 }
134
136 d2(VariationalArg<Scalar,dim> const& argTest, VariationalArg<Scalar,dim> const& argAnsatz) const
137 {
138 return gamma*weight*argTest.value[0]*argAnsatz.value[0] * unitMatrix<Scalar,components>();
139 }
140
141 private:
142 Scalar gamma;
143 Scalar weight; // this is h^{-2}
144 Vector deviation;
145 };
146
170 template <class GridView, int components, class ScalarType=typename GridView::ctype>
172 {
173 using Scalar = ScalarType;
174 static constexpr int dim = GridView::dimension;
175 static constexpr int dimworld = GridView::dimensionworld;
176
177 public:
178
180
187 void moveTo(typename GridView::IntersectionIterator const& fi)
188 {
189 face = *fi;
190
191 // Compute h^{-1}. h is volume^(1/(dim-1)). Take care of special case for dim=1.
192 if (dim > 1)
193 weight = std::pow(face.geometry().volume(),-1/(dim-1));
194 else
195 weight = 1;
196 }
197
209 Scalar gamma_, Vector const& u, Vector const& ud, Dune::FieldMatrix<Scalar,components,dim> ux_,
211 {
212 gamma = gamma_;
213 assert(gamma>=0);
214 deviation = u-ud;
215 ux = ux_;
216 kn = kappa * face.unitOuterNormal(xi);
217 }
218
219 Scalar d0() const { return 0.5*weight*gamma*(deviation*deviation) - deviation*(ux*kn); }
220
222 {
223 return weight*gamma*arg.value[0]*deviation - arg.value[0]*(ux*kn) - deviation*(arg.derivative[0]*kn);
224 }
225
227 d2(VariationalArg<Scalar,dim> const& argTest, VariationalArg<Scalar,dim> const& argAnsatz) const
228 {
230
231 Scalar t1 = argTest.value[0]*(argAnsatz.derivative[0]*kn);
232 Scalar t2 = argAnsatz.value[0]*(argTest.derivative[0]*kn);
233
234 return weight*gamma*argTest.value[0]*argAnsatz.value[0] * unitMatrix<Scalar,components>()
235 - (t1+t2)*ones;
236 }
237
238 private:
239 Scalar gamma;
240 Scalar weight; // this is h^{-1}
241 typename GridView::Intersection face;
242 Dune::FieldVector<Scalar,dim> kn; // this is kappa*n
243 Vector deviation;
245 };
246
247
248}
249
250#endif
251
252
Dirichlet boundary conditions by Nitsche's method.
Dune::FieldMatrix< Scalar, components, components > d2(VariationalArg< Scalar, dim > const &argTest, VariationalArg< Scalar, dim > const &argAnsatz) const
void moveTo(typename GridView::IntersectionIterator const &fi)
Moves the boundary condition to a new face.
void setBoundaryData(Dune::FieldVector< typename GridView::ctype, dim-1 > const &xi, Scalar gamma_, Vector const &u, Vector const &ud, Dune::FieldMatrix< Scalar, components, dim > ux_, Dune::FieldMatrix< Scalar, dim, dim > const &kappa)
Defines the data for the boundary condition.
Dune::FieldVector< Scalar, components > Vector
Vector d1(VariationalArg< Scalar, dim > const &arg) const
Dirichlet boundary conditions by the penalty approach.
Dune::FieldMatrix< Scalar, components, components > d2(VariationalArg< Scalar, dim > const &argTest, VariationalArg< Scalar, dim > const &argAnsatz) const
Dune::FieldVector< Scalar, components > Vector
void moveTo(typename GridView::IntersectionIterator const &fi)
Moves the boundary condition to a new face.
Vector d1(VariationalArg< Scalar, dim > const &argT) const
void setBoundaryData(Scalar gamma_, Vector const &u, Vector const &ud)
Defines the data for the boundary condition.
void evaluateAt(Dune::FieldVector< typename Functional::AnsatzVars::Grid::ctype, dim-1 > const &, Evaluators const &)
auto d1(VariationalArg< Scalar, dim > const &) const
HomogeneousNeumannBoundary(Functional const &, typename Functional::OriginVars::VariableSet const &, int)
Constructor.
auto d2(VariationalArg< Scalar, dim > const &, VariationalArg< Scalar, dim > const &) const
typename boost::fusion::result_of::as_vector< typename boost::fusion::result_of::transform< Spaces, GetEvaluatorTypes >::type >::type Evaluators
the heterogeneous sequence type of Evaluators for the given spaces
Dune::FieldMatrix< T, n, n > unitMatrix()
Returns the identity matrix of size n .
Definition fixdune.hh:506
typename GetScalar< Type >::type ScalarType
Extracts the scalar field type from linear algebra data types.
A class that stores values, gradients, and Hessians of evaluated shape functions.
Dune::FieldMatrix< Scalar, components, dim > derivative
The shape function's spatial derivative, a components x dim matrix.
ValueType value
The shape function's value, a vector of dimension components