deal.II version GIT relicensing-6868-gafcc71a9cb 2026-10-12 01:10:01+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: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2015 - 2025 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
14#ifndef dealii_polynomials_rannacher_turek_h
15#define dealii_polynomials_rannacher_turek_h
16
17#include <deal.II/base/config.h>
18
20#include <deal.II/base/point.h>
22#include <deal.II/base/tensor.h>
23
24#include <vector>
25
27
28
39template <int dim>
41{
42public:
46 static constexpr unsigned int dimension = dim;
47
52
56 double
57 compute_value(const unsigned int i, const Point<dim> &p) const override;
58
64 template <int order>
66 compute_derivative(const unsigned int i, const Point<dim> &p) const;
67
71 virtual Tensor<1, dim>
72 compute_1st_derivative(const unsigned int i,
73 const Point<dim> &p) const override;
74
78 virtual Tensor<2, dim>
79 compute_2nd_derivative(const unsigned int i,
80 const Point<dim> &p) const override;
81
85 virtual Tensor<3, dim>
86 compute_3rd_derivative(const unsigned int i,
87 const Point<dim> &p) const override;
88
92 virtual Tensor<4, dim>
93 compute_4th_derivative(const unsigned int i,
94 const Point<dim> &p) const override;
95
100 compute_grad(const unsigned int i, const Point<dim> &p) const override;
101
106 compute_grad_grad(const unsigned int i, const Point<dim> &p) const override;
107
114 void
115 evaluate(const Point<dim> &unit_point,
116 std::vector<double> &values,
117 std::vector<Tensor<1, dim>> &grads,
118 std::vector<Tensor<2, dim>> &grad_grads,
119 std::vector<Tensor<3, dim>> &third_derivatives,
120 std::vector<Tensor<4, dim>> &fourth_derivatives) const override;
121
125 std::string
126 name() const override;
127
131 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
132 clone() const override;
133};
134
135
136namespace internal
137{
138 namespace PolynomialsRannacherTurekImplementation
139 {
140 template <int order, int dim>
141 inline Tensor<order, dim>
142 compute_derivative(const unsigned int, const Point<dim> &)
143 {
144 Assert(dim == 2, ExcNotImplemented());
145 return Tensor<order, dim>();
146 }
147
148
149 template <int order>
150 inline Tensor<order, 2>
151 compute_derivative(const unsigned int i, const Point<2> &p)
152 {
153 const unsigned int dim = 2;
154
155 if constexpr (order == 1)
156 {
157 Tensor<1, dim> derivative;
158 if (i == 0)
159 {
160 derivative[0] = -2.5 + 3 * p[0];
161 derivative[1] = 1.5 - 3 * p[1];
162 }
163 else if (i == 1)
164 {
165 derivative[0] = -0.5 + 3.0 * p[0];
166 derivative[1] = 1.5 - 3.0 * p[1];
167 }
168 else if (i == 2)
169 {
170 derivative[0] = 1.5 - 3.0 * p[0];
171 derivative[1] = -2.5 + 3.0 * p[1];
172 }
173 else if (i == 3)
174 {
175 derivative[0] = 1.5 - 3.0 * p[0];
176 derivative[1] = -0.5 + 3.0 * p[1];
177 }
178 else
179 {
181 }
182 return derivative;
183 }
184 else if constexpr (order == 2)
185 {
186 Tensor<2, dim> derivative;
187 if (i == 0)
188 {
189 derivative[0][0] = 3;
190 derivative[0][1] = 0;
191 derivative[1][0] = 0;
192 derivative[1][1] = -3;
193 }
194 else if (i == 1)
195 {
196 derivative[0][0] = 3;
197 derivative[0][1] = 0;
198 derivative[1][0] = 0;
199 derivative[1][1] = -3;
200 }
201 else if (i == 2)
202 {
203 derivative[0][0] = -3;
204 derivative[0][1] = 0;
205 derivative[1][0] = 0;
206 derivative[1][1] = 3;
207 }
208 else if (i == 3)
209 {
210 derivative[0][0] = -3;
211 derivative[0][1] = 0;
212 derivative[1][0] = 0;
213 derivative[1][1] = 3;
214 }
215 else
216 {
218 }
219 return derivative;
220 }
221 else
222 {
223 // higher derivatives are all zero
224 return {};
225 }
226 }
227 } // namespace PolynomialsRannacherTurekImplementation
228} // namespace internal
229
230
231
232// template functions
233template <int dim>
234template <int order>
242
243
244
245template <int dim>
246inline Tensor<1, dim>
248 const unsigned int i,
249 const Point<dim> &p) const
250{
251 return compute_derivative<1>(i, p);
252}
253
254
255
256template <int dim>
257inline Tensor<2, dim>
259 const unsigned int i,
260 const Point<dim> &p) const
261{
262 return compute_derivative<2>(i, p);
263}
264
265
266
267template <int dim>
268inline Tensor<3, dim>
270 const unsigned int i,
271 const Point<dim> &p) const
272{
273 return compute_derivative<3>(i, p);
274}
275
276
277
278template <int dim>
279inline Tensor<4, dim>
281 const unsigned int i,
282 const Point<dim> &p) const
283{
284 return compute_derivative<4>(i, p);
285}
286
287
288
289template <int dim>
290inline std::string
292{
293 return "RannacherTurek";
294}
295
296
298
299#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:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_NOT_IMPLEMENTED()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
Tensor< order, dim > compute_derivative(const unsigned int, const Point< dim > &)