deal.II version GIT relicensing-1929-g70a5450eef 2024-10-03 18:00:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
polynomials_rannacher_turek.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2015 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15
16#ifndef dealii_polynomials_rannacher_turek_h
17#define dealii_polynomials_rannacher_turek_h
18
19#include <deal.II/base/config.h>
20
21#include <deal.II/base/point.h>
23#include <deal.II/base/tensor.h>
24
25#include <vector>
26
28
29
40template <int dim>
42{
43public:
47 static constexpr unsigned int dimension = dim;
48
53
57 double
58 compute_value(const unsigned int i, const Point<dim> &p) const override;
59
65 template <int order>
67 compute_derivative(const unsigned int i, const Point<dim> &p) const;
68
72 virtual Tensor<1, dim>
73 compute_1st_derivative(const unsigned int i,
74 const Point<dim> &p) const override;
75
79 virtual Tensor<2, dim>
80 compute_2nd_derivative(const unsigned int i,
81 const Point<dim> &p) const override;
82
86 virtual Tensor<3, dim>
87 compute_3rd_derivative(const unsigned int i,
88 const Point<dim> &p) const override;
89
93 virtual Tensor<4, dim>
94 compute_4th_derivative(const unsigned int i,
95 const Point<dim> &p) const override;
96
101 compute_grad(const unsigned int i, const Point<dim> &p) const override;
102
107 compute_grad_grad(const unsigned int i, const Point<dim> &p) const override;
108
115 void
116 evaluate(const Point<dim> &unit_point,
117 std::vector<double> &values,
118 std::vector<Tensor<1, dim>> &grads,
119 std::vector<Tensor<2, dim>> &grad_grads,
120 std::vector<Tensor<3, dim>> &third_derivatives,
121 std::vector<Tensor<4, dim>> &fourth_derivatives) const override;
122
126 std::string
127 name() const override;
128
132 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
133 clone() const override;
134};
135
136
137namespace internal
138{
139 namespace PolynomialsRannacherTurekImplementation
140 {
141 template <int order, int dim>
142 inline Tensor<order, dim>
143 compute_derivative(const unsigned int, const Point<dim> &)
144 {
145 Assert(dim == 2, ExcNotImplemented());
146 return Tensor<order, dim>();
147 }
148
149
150 template <int order>
151 inline Tensor<order, 2>
152 compute_derivative(const unsigned int i, const Point<2> &p)
153 {
154 const unsigned int dim = 2;
155
156 if constexpr (order == 1)
157 {
158 Tensor<1, dim> derivative;
159 if (i == 0)
160 {
161 derivative[0] = -2.5 + 3 * p[0];
162 derivative[1] = 1.5 - 3 * p[1];
163 }
164 else if (i == 1)
165 {
166 derivative[0] = -0.5 + 3.0 * p[0];
167 derivative[1] = 1.5 - 3.0 * p[1];
168 }
169 else if (i == 2)
170 {
171 derivative[0] = 1.5 - 3.0 * p[0];
172 derivative[1] = -2.5 + 3.0 * p[1];
173 }
174 else if (i == 3)
175 {
176 derivative[0] = 1.5 - 3.0 * p[0];
177 derivative[1] = -0.5 + 3.0 * p[1];
178 }
179 else
180 {
182 }
183 return derivative;
184 }
185 else if constexpr (order == 2)
186 {
187 Tensor<2, dim> derivative;
188 if (i == 0)
189 {
190 derivative[0][0] = 3;
191 derivative[0][1] = 0;
192 derivative[1][0] = 0;
193 derivative[1][1] = -3;
194 }
195 else if (i == 1)
196 {
197 derivative[0][0] = 3;
198 derivative[0][1] = 0;
199 derivative[1][0] = 0;
200 derivative[1][1] = -3;
201 }
202 else if (i == 2)
203 {
204 derivative[0][0] = -3;
205 derivative[0][1] = 0;
206 derivative[1][0] = 0;
207 derivative[1][1] = 3;
208 }
209 else if (i == 3)
210 {
211 derivative[0][0] = -3;
212 derivative[0][1] = 0;
213 derivative[1][0] = 0;
214 derivative[1][1] = 3;
215 }
216 else
217 {
219 }
220 return derivative;
221 }
222 else
223 {
224 // higher derivatives are all zero
225 return {};
226 }
227 }
228 } // namespace PolynomialsRannacherTurekImplementation
229} // namespace internal
230
231
232
233// template functions
234template <int dim>
235template <int order>
243
244
245
246template <int dim>
247inline Tensor<1, dim>
249 const unsigned int i,
250 const Point<dim> &p) const
251{
252 return compute_derivative<1>(i, p);
253}
254
255
256
257template <int dim>
258inline Tensor<2, dim>
260 const unsigned int i,
261 const Point<dim> &p) const
262{
263 return compute_derivative<2>(i, p);
264}
265
266
267
268template <int dim>
269inline Tensor<3, dim>
271 const unsigned int i,
272 const Point<dim> &p) const
273{
274 return compute_derivative<3>(i, p);
275}
276
277
278
279template <int dim>
280inline Tensor<4, dim>
282 const unsigned int i,
283 const Point<dim> &p) const
284{
285 return compute_derivative<4>(i, p);
286}
287
288
289
290template <int dim>
291inline std::string
293{
294 return "RannacherTurek";
295}
296
297
299
300#endif
Definition point.h:111
virtual Tensor< 3, dim > compute_3rd_derivative(const unsigned int i, const Point< dim > &p) const override
virtual Tensor< 1, dim > compute_1st_derivative(const unsigned int i, const Point< dim > &p) const override
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() const override
Tensor< order, dim > compute_derivative(const unsigned int i, const Point< dim > &p) const
void evaluate(const Point< dim > &unit_point, std::vector< double > &values, std::vector< Tensor< 1, dim > > &grads, std::vector< Tensor< 2, dim > > &grad_grads, std::vector< Tensor< 3, dim > > &third_derivatives, std::vector< Tensor< 4, dim > > &fourth_derivatives) const override
std::string name() const override
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const override
virtual Tensor< 4, dim > compute_4th_derivative(const unsigned int i, const Point< dim > &p) const override
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const override
virtual Tensor< 2, dim > compute_2nd_derivative(const unsigned int i, const Point< dim > &p) const override
static constexpr unsigned int dimension
double compute_value(const unsigned int i, const Point< dim > &p) const override
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define DEAL_II_NOT_IMPLEMENTED()
Tensor< order, dim > compute_derivative(const unsigned int, const Point< dim > &)