KASKADE 7 development version
laplace.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) 2012-2019 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 LAPLACE_OP_HH
14#define LAPLACE_OP_HH
15
16#include <dune/common/fvector.hh>
17#include <dune/common/fmatrix.hh>
18
19#include "fem/fixdune.hh"
21
22namespace Kaskade
23{
24
32 template <class Scalar, int dim, bool isotropic=true>
34 {
35 public:
42 using DiffusionTensor = std::conditional_t<isotropic,
43 Scalar,
50 {
51 if constexpr (isotropic)
52 kappa = 1;
53 else
54 kappa = unitMatrix<Scalar,dim,dim>();
55 }
56
62 {
63 kappa = kappa_;
64 return *this;
65 }
66
71 {
72 du0 = du0_;
73 return *this;
74 }
75
81 Scalar d0() const
82 {
83 auto a = kappa*du0;
84 return 0.5*(a*du0);
85 }
86
88 {
89 auto a = kappa*du0;
90 return arg.derivative*a;
91 }
92
94 {
95 auto a = kappa*arg1.derivative[0];
96 return a*arg2.derivative[0];
97 }
98
99 private:
100 DiffusionTensor kappa; // diffusion constant
101 Dune::FieldVector<Scalar,dim> du0; // gradient of linearization point
102 };
103
111 template <class Scalar, int dim, int components, bool isotropic=true>
112 class Laplace
113 {
114 public:
119 Laplace(): kappa(1), du0(0)
120 {
121 }
122
123 void setDiffusionTensor(Scalar kappa_)
124 {
125 // TODO: shall we enforce kappa > 0? And kappa real?
126 kappa = kappa_;
127 }
128
130 {
131 du0 = du0_;
132 }
133
134 Scalar d0() const
135 {
136 return 0.5*kappa*sp(du0, du0);
137 }
138
140 {
141 return kappa*sp(arg.derivative, du0);
142 }
143
145 {
146 return kappa*sp(arg1.derivative, arg2.derivative);
147 }
148
149 private:
150 // diffusion constant
151 Scalar kappa;
154 };
155
156
157
158}
159
160#endif
Convenience class for handling diffusion terms in elliptic/parabolic equations.
Definition: laplace.hh:113
void setDiffusionTensor(Scalar kappa_)
Definition: laplace.hh:123
Scalar d2(VariationalArg< Scalar, dim, components > const &arg1, VariationalArg< Scalar, dim, components > const &arg2) const
Definition: laplace.hh:144
Laplace()
Constructor The diffusion constant is initialized to 1, the linearization point to .
Definition: laplace.hh:119
Scalar d1(VariationalArg< Scalar, dim, components > const &arg) const
Definition: laplace.hh:139
Scalar d0() const
Definition: laplace.hh:134
void setLinearizationPoint(Dune::FieldMatrix< Scalar, components, dim > const &du0_)
Definition: laplace.hh:129
Convenience class for handling diffusion terms in elliptic/parabolic equations.
Definition: laplace.hh:34
std::conditional_t< isotropic, Scalar, Dune::FieldMatrix< Scalar, dim, dim > > DiffusionTensor
The type of the diffusion tensor.
Definition: laplace.hh:44
Dune::FieldVector< Scalar, 1 > d1(VariationalArg< Scalar, dim > const &arg) const
Definition: laplace.hh:87
ScalarLaplace()
Constructor The diffusion constant is initialized to 1, the linearization point to .
Definition: laplace.hh:49
Laplace & setDiffusionTensor(DiffusionTensor const &kappa_)
Specifies a scalar diffusion constant.
Definition: laplace.hh:61
Dune::FieldMatrix< Scalar, 1, 1 > d2(VariationalArg< Scalar, dim > const &arg1, VariationalArg< Scalar, dim > const &arg2) const
Definition: laplace.hh:93
Laplace & setLinearizationPoint(Dune::FieldVector< Scalar, dim > const &du0_)
Specifies the gradient of the linearization point of the Laplace variational functional.
Definition: laplace.hh:70
Scalar d0() const
Returns the value of the Laplace variational functional. The value returned is.
Definition: laplace.hh:81
This file contains various utility functions that augment the basic functionality of Dune.
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.