KASKADE 7 development version
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-2022 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>
63 auto d1(VariationalArg<Scalar,dim> const& ) const
64 {
66 }
67
68 template <int row, int col>
70 {
72 }
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 u = u_;
126 deviation = u-ud;
127 }
128
129 Scalar d0() const { return 0.5*gamma*weight * (deviation*deviation); }
130
132 {
133 return gamma*weight*argT.value[0]*deviation;
134 }
135
137 d2(VariationalArg<Scalar,dim> const& argTest, VariationalArg<Scalar,dim> const& argAnsatz) const
138 {
139 return gamma*weight*argTest.value[0]*argAnsatz.value[0] * unitMatrix<Scalar,components>();
140 }
141
142 private:
143 Scalar gamma;
144 Scalar weight; // this is h^{-2}
145 Vector u, deviation;
146 };
147
171 template <class GridView, int components, class ScalarType=typename GridView::ctype>
173 {
174 using Scalar = ScalarType;
175 static constexpr int dim = GridView::dimension;
176 static constexpr int dimworld = GridView::dimensionworld;
177
178 public:
179
181
188 void moveTo(typename GridView::IntersectionIterator const& fi)
189 {
190 face = *fi;
191
192 // Compute h^{-1}. h is volume^(1/(dim-1)). Take care of special case for dim=1.
193 if (dim > 1)
194 weight = std::pow(face.geometry().volume(),-1/(dim-1));
195 else
196 weight = 1;
197 }
198
210 Scalar gamma_, Vector const& u, Vector const& ud, Dune::FieldMatrix<Scalar,components,dim> ux_,
212 {
213 gamma = gamma_;
214 assert(gamma>=0);
215 deviation = u-ud;
216 ux = ux_;
217 kn = kappa * face.unitOuterNormal(xi);
218 }
219
220 Scalar d0() const { return 0.5*weight*gamma*(deviation*deviation) - deviation*(ux*kn); }
221
223 {
224 return weight*gamma*arg.value[0]*deviation - arg.value[0]*(ux*kn) - deviation*(arg.derivative[0]*kn);
225 }
226
228 d2(VariationalArg<Scalar,dim> const& argTest, VariationalArg<Scalar,dim> const& argAnsatz) const
229 {
231
232 Scalar t1 = argTest.value[0]*(argAnsatz.derivative[0]*kn);
233 Scalar t2 = argAnsatz.value[0]*(argTest.derivative[0]*kn);
234
235 return weight*gamma*argTest.value[0]*argAnsatz.value[0] * unitMatrix<Scalar,components>()
236 - (t1+t2)*ones;
237 }
238
239 private:
240 Scalar gamma;
241 Scalar weight; // this is h^{-1}
242 typename GridView::Intersection face;
243 Dune::FieldVector<Scalar,dim> kn; // this is kappa*n
244 Vector deviation;
246 };
247
248
249}
250
251#endif
252
253
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.
A simple boundary cache implementing homogeneous Neumann boundary conditions.
void moveTo(FaceIterator const &)
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
typename GetScalar< Type >::type ScalarType
Extracts the scalar field type from linear algebra data types.
Helper class for specifying the number of components of a variable.
Definition: variables.hh:100
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