Loading [MathJax]/extensions/TeX/newcommand.js
 deal.II version GIT relicensing-3104-g8c3bc2e695 2025-04-21 18:40: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\}}
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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
22#include <deal.II/base/point.h>
24#include <deal.II/base/tensor.h>
25
26#include <vector>
27
29
30
41template <int dim>
43{
44public:
48 static constexpr unsigned int dimension = dim;
49
54
58 double
59 compute_value(const unsigned int i, const Point<dim> &p) const override;
60
66 template <int order>
68 compute_derivative(const unsigned int i, const Point<dim> &p) const;
69
73 virtual Tensor<1, dim>
74 compute_1st_derivative(const unsigned int i,
75 const Point<dim> &p) const override;
76
80 virtual Tensor<2, dim>
81 compute_2nd_derivative(const unsigned int i,
82 const Point<dim> &p) const override;
83
87 virtual Tensor<3, dim>
88 compute_3rd_derivative(const unsigned int i,
89 const Point<dim> &p) const override;
90
94 virtual Tensor<4, dim>
95 compute_4th_derivative(const unsigned int i,
96 const Point<dim> &p) const override;
97
102 compute_grad(const unsigned int i, const Point<dim> &p) const override;
103
108 compute_grad_grad(const unsigned int i, const Point<dim> &p) const override;
109
116 void
117 evaluate(const Point<dim> &unit_point,
118 std::vector<double> &values,
119 std::vector<Tensor<1, dim>> &grads,
120 std::vector<Tensor<2, dim>> &grad_grads,
121 std::vector<Tensor<3, dim>> &third_derivatives,
122 std::vector<Tensor<4, dim>> &fourth_derivatives) const override;
123
127 std::string
128 name() const override;
129
133 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
134 clone() const override;
135};
136
137
138namespace internal
139{
140 namespace PolynomialsRannacherTurekImplementation
141 {
142 template <int order, int dim>
143 inline Tensor<order, dim>
144 compute_derivative(const unsigned int, const Point<dim> &)
145 {
146 Assert(dim == 2, ExcNotImplemented());
147 return Tensor<order, dim>();
148 }
149
150
151 template <int order>
152 inline Tensor<order, 2>
153 compute_derivative(const unsigned int i, const Point<2> &p)
154 {
155 const unsigned int dim = 2;
156
157 if constexpr (order == 1)
158 {
159 Tensor<1, dim> derivative;
160 if (i == 0)
161 {
162 derivative[0] = -2.5 + 3 * p[0];
163 derivative[1] = 1.5 - 3 * p[1];
164 }
165 else if (i == 1)
166 {
167 derivative[0] = -0.5 + 3.0 * p[0];
168 derivative[1] = 1.5 - 3.0 * p[1];
169 }
170 else if (i == 2)
171 {
172 derivative[0] = 1.5 - 3.0 * p[0];
173 derivative[1] = -2.5 + 3.0 * p[1];
174 }
175 else if (i == 3)
176 {
177 derivative[0] = 1.5 - 3.0 * p[0];
178 derivative[1] = -0.5 + 3.0 * p[1];
179 }
180 else
181 {
183 }
184 return derivative;
185 }
186 else if constexpr (order == 2)
187 {
188 Tensor<2, dim> derivative;
189 if (i == 0)
190 {
191 derivative[0][0] = 3;
192 derivative[0][1] = 0;
193 derivative[1][0] = 0;
194 derivative[1][1] = -3;
195 }
196 else if (i == 1)
197 {
198 derivative[0][0] = 3;
199 derivative[0][1] = 0;
200 derivative[1][0] = 0;
201 derivative[1][1] = -3;
202 }
203 else if (i == 2)
204 {
205 derivative[0][0] = -3;
206 derivative[0][1] = 0;
207 derivative[1][0] = 0;
208 derivative[1][1] = 3;
209 }
210 else if (i == 3)
211 {
212 derivative[0][0] = -3;
213 derivative[0][1] = 0;
214 derivative[1][0] = 0;
215 derivative[1][1] = 3;
216 }
217 else
218 {
220 }
221 return derivative;
222 }
223 else
224 {
225 // higher derivatives are all zero
226 return {};
227 }
228 }
229 } // namespace PolynomialsRannacherTurekImplementation
230} // namespace internal
231
232
233
234// template functions
235template <int dim>
236template <int order>
244
245
246
247template <int dim>
248inline Tensor<1, dim>
250 const unsigned int i,
251 const Point<dim> &p) const
252{
253 return compute_derivative<1>(i, p);
254}
255
256
257
258template <int dim>
259inline Tensor<2, dim>
261 const unsigned int i,
262 const Point<dim> &p) const
263{
264 return compute_derivative<2>(i, p);
265}
266
267
268
269template <int dim>
270inline Tensor<3, dim>
272 const unsigned int i,
273 const Point<dim> &p) const
274{
275 return compute_derivative<3>(i, p);
276}
277
278
279
280template <int dim>
281inline Tensor<4, dim>
283 const unsigned int i,
284 const Point<dim> &p) const
285{
286 return compute_derivative<4>(i, p);
287}
288
289
290
291template <int dim>
292inline std::string
294{
295 return "RannacherTurek";
296}
297
298
300
301#endif
Definition point.h:113
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:35
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:36
#define DEAL_II_NOT_IMPLEMENTED()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
Tensor< order, dim > compute_derivative(const unsigned int, const Point< dim > &)