Reference documentation for deal.II version GIT relicensing-43-g3fc2fae7c3 2024-03-03 21:10:02+00:00
Searching...
No Matches
polynomials_rannacher_turek.cc
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
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
18
19#include <memory>
20
22
23
24template <int dim>
26 : ScalarPolynomialsBase<dim>(2, ::GeometryInfo<dim>::faces_per_cell)
27{
28 Assert(dim == 2, ExcNotImplemented());
29}
30
31
32
33template <int dim>
34double
36 const Point<dim> &p) const
37{
38 Assert(dim == 2, ExcNotImplemented());
39 if (i == 0)
40 {
41 return (0.75 - 2.5 * p[0] + 1.5 * p[1] +
42 1.5 * (p[0] * p[0] - p[1] * p[1]));
43 }
44 else if (i == 1)
45 {
46 return (-0.25 - 0.5 * p[0] + 1.5 * p[1] +
47 1.5 * (p[0] * p[0] - p[1] * p[1]));
48 }
49 else if (i == 2)
50 {
51 return (0.75 + 1.5 * p[0] - 2.5 * p[1] -
52 1.5 * (p[0] * p[0] - p[1] * p[1]));
53 }
54 else if (i == 3)
55 {
56 return (-0.25 + 1.5 * p[0] - 0.5 * p[1] -
57 1.5 * (p[0] * p[0] - p[1] * p[1]));
58 }
59
61 return 0;
62}
63
64
65
66template <int dim>
69 const Point<dim> &p) const
70{
71 if constexpr (dim == 2)
72 {
74 if (i == 0)
75 {
76 grad[0] = -2.5 + 3 * p[0];
77 grad[1] = 1.5 - 3 * p[1];
78 }
79 else if (i == 1)
80 {
81 grad[0] = -0.5 + 3.0 * p[0];
82 grad[1] = 1.5 - 3.0 * p[1];
83 }
84 else if (i == 2)
85 {
86 grad[0] = 1.5 - 3.0 * p[0];
87 grad[1] = -2.5 + 3.0 * p[1];
88 }
89 else if (i == 3)
90 {
91 grad[0] = 1.5 - 3.0 * p[0];
92 grad[1] = -0.5 + 3.0 * p[1];
93 }
94 else
95 {
97 }
98
100 }
101
102 else
103 {
105 return {};
106 }
107}
108
109
110
111template <int dim>
114 const unsigned int i,
115 const Point<dim> & /*p*/) const
116{
117 if constexpr (dim == 2)
118 {
120 if (i == 0)
121 {
126 }
127 else if (i == 1)
128 {
133 }
134 else if (i == 2)
135 {
140 }
141 else if (i == 3)
142 {
147 }
149 }
150
151 else
152 {
154 return {};
155 }
156}
157
158
159
160template <int dim>
161void
163 const Point<dim> &unit_point,
164 std::vector<double> &values,
167 std::vector<Tensor<3, dim>> &third_derivatives,
168 std::vector<Tensor<4, dim>> &fourth_derivatives) const
169{
170 const unsigned int n_pols = this->n();
171 Assert(values.size() == n_pols || values.empty(),
172 ExcDimensionMismatch(values.size(), n_pols));
177 Assert(third_derivatives.size() == n_pols || third_derivatives.empty(),
178 ExcDimensionMismatch(third_derivatives.size(), n_pols));
179 Assert(fourth_derivatives.size() == n_pols || fourth_derivatives.empty(),
180 ExcDimensionMismatch(fourth_derivatives.size(), n_pols));
181
182 for (unsigned int i = 0; i < n_pols; ++i)
183 {
184 if (values.size() != 0)
185 {
186 values[i] = compute_value(i, unit_point);
187 }
189 {
191 }
193 {
195 }
196 if (third_derivatives.size() != 0)
197 {
198 third_derivatives[i] = compute_derivative<3>(i, unit_point);
199 }
200 if (fourth_derivatives.size() != 0)
201 {
202 fourth_derivatives[i] = compute_derivative<4>(i, unit_point);
203 }
204 }
205}
206
207
208
209template <int dim>
210std::unique_ptr<ScalarPolynomialsBase<dim>>
212{
213 return std::make_unique<PolynomialsRannacherTurek<dim>>(*this);
214}
215
216
217// explicit instantiations
218#include "polynomials_rannacher_turek.inst"
219
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:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define DEAL_II_NOT_IMPLEMENTED()