deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20: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.cc
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
16
17#include <memory>
18
20
21
22template <int dim>
28
29
30
31template <int dim>
32double
34 const Point<dim> &p) const
35{
36 Assert(dim == 2, ExcNotImplemented());
37 if (i == 0)
38 {
39 return (0.75 - 2.5 * p[0] + 1.5 * p[1] +
40 1.5 * (p[0] * p[0] - p[1] * p[1]));
41 }
42 else if (i == 1)
43 {
44 return (-0.25 - 0.5 * p[0] + 1.5 * p[1] +
45 1.5 * (p[0] * p[0] - p[1] * p[1]));
46 }
47 else if (i == 2)
48 {
49 return (0.75 + 1.5 * p[0] - 2.5 * p[1] -
50 1.5 * (p[0] * p[0] - p[1] * p[1]));
51 }
52 else if (i == 3)
53 {
54 return (-0.25 + 1.5 * p[0] - 0.5 * p[1] -
55 1.5 * (p[0] * p[0] - p[1] * p[1]));
56 }
57
59 return 0;
60}
61
62
63
64template <int dim>
67 const Point<dim> &p) const
68{
69 if constexpr (dim == 2)
70 {
71 Tensor<1, dim> grad;
72 if (i == 0)
73 {
74 grad[0] = -2.5 + 3 * p[0];
75 grad[1] = 1.5 - 3 * p[1];
76 }
77 else if (i == 1)
78 {
79 grad[0] = -0.5 + 3.0 * p[0];
80 grad[1] = 1.5 - 3.0 * p[1];
81 }
82 else if (i == 2)
83 {
84 grad[0] = 1.5 - 3.0 * p[0];
85 grad[1] = -2.5 + 3.0 * p[1];
86 }
87 else if (i == 3)
88 {
89 grad[0] = 1.5 - 3.0 * p[0];
90 grad[1] = -0.5 + 3.0 * p[1];
91 }
92 else
93 {
95 }
96
97 return grad;
98 }
99
100 else
101 {
103 return {};
104 }
105}
106
107
108
109template <int dim>
112 const unsigned int i,
113 const Point<dim> & /*p*/) const
114{
115 if constexpr (dim == 2)
116 {
117 Tensor<2, dim> grad_grad;
118 if (i == 0)
119 {
120 grad_grad[0][0] = 3;
121 grad_grad[0][1] = 0;
122 grad_grad[1][0] = 0;
123 grad_grad[1][1] = -3;
124 }
125 else if (i == 1)
126 {
127 grad_grad[0][0] = 3;
128 grad_grad[0][1] = 0;
129 grad_grad[1][0] = 0;
130 grad_grad[1][1] = -3;
131 }
132 else if (i == 2)
133 {
134 grad_grad[0][0] = -3;
135 grad_grad[0][1] = 0;
136 grad_grad[1][0] = 0;
137 grad_grad[1][1] = 3;
138 }
139 else if (i == 3)
140 {
141 grad_grad[0][0] = -3;
142 grad_grad[0][1] = 0;
143 grad_grad[1][0] = 0;
144 grad_grad[1][1] = 3;
145 }
146 return grad_grad;
147 }
148
149 else
150 {
152 return {};
153 }
154}
155
156
157
158template <int dim>
159void
161 const Point<dim> &unit_point,
162 std::vector<double> &values,
163 std::vector<Tensor<1, dim>> &grads,
164 std::vector<Tensor<2, dim>> &grad_grads,
165 std::vector<Tensor<3, dim>> &third_derivatives,
166 std::vector<Tensor<4, dim>> &fourth_derivatives) const
167{
168 const unsigned int n_pols = this->n();
169 Assert(values.size() == n_pols || values.empty(),
170 ExcDimensionMismatch(values.size(), n_pols));
171 Assert(grads.size() == n_pols || grads.empty(),
172 ExcDimensionMismatch(grads.size(), n_pols));
173 Assert(grad_grads.size() == n_pols || grad_grads.empty(),
174 ExcDimensionMismatch(grad_grads.size(), n_pols));
175 Assert(third_derivatives.size() == n_pols || third_derivatives.empty(),
176 ExcDimensionMismatch(third_derivatives.size(), n_pols));
177 Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.empty(),
178 ExcDimensionMismatch(fourth_derivatives.size(), n_pols));
179
180 for (unsigned int i = 0; i < n_pols; ++i)
181 {
182 if (values.size() != 0)
183 {
184 values[i] = compute_value(i, unit_point);
185 }
186 if (grads.size() != 0)
187 {
188 grads[i] = compute_grad(i, unit_point);
189 }
190 if (grad_grads.size() != 0)
191 {
192 grad_grads[i] = compute_grad_grad(i, unit_point);
193 }
194 if (third_derivatives.size() != 0)
195 {
196 third_derivatives[i] = compute_derivative<3>(i, unit_point);
197 }
198 if (fourth_derivatives.size() != 0)
199 {
200 fourth_derivatives[i] = compute_derivative<4>(i, unit_point);
201 }
202 }
203}
204
205
206
207template <int dim>
208std::unique_ptr<ScalarPolynomialsBase<dim>>
210{
211 return std::make_unique<PolynomialsRannacherTurek<dim>>(*this);
212}
213
214
215// explicit instantiations
216#include "base/polynomials_rannacher_turek.inst"
217
Definition point.h:111
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() const override
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
Tensor< 2, dim > compute_grad_grad(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
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)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)