deal.II version GIT relicensing-6842-g793a97d2aa 2026-10-02 14:00: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
scalar_polynomials_base.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) 2019 - 2024 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#ifndef dealii_scalar_polynomials_base_h
14#define dealii_scalar_polynomials_base_h
15
16
17#include <deal.II/base/config.h>
18
20#include <deal.II/base/point.h>
21#include <deal.II/base/tensor.h>
22
23#include <memory>
24#include <string>
25#include <vector>
26
28
59template <int dim>
61{
62public:
67 ScalarPolynomialsBase(const unsigned int deg,
68 const unsigned int n_polynomials);
69
74
79
85
98 virtual void
99 evaluate(const Point<dim> &unit_point,
100 std::vector<double> &values,
101 std::vector<Tensor<1, dim>> &grads,
102 std::vector<Tensor<2, dim>> &grad_grads,
103 std::vector<Tensor<3, dim>> &third_derivatives,
104 std::vector<Tensor<4, dim>> &fourth_derivatives) const = 0;
105
112 virtual double
113 compute_value(const unsigned int i, const Point<dim> &p) const = 0;
114
123 template <int order>
125 compute_derivative(const unsigned int i, const Point<dim> &p) const;
126
133 virtual Tensor<1, dim>
134 compute_1st_derivative(const unsigned int i, const Point<dim> &p) const = 0;
135
142 virtual Tensor<2, dim>
143 compute_2nd_derivative(const unsigned int i, const Point<dim> &p) const = 0;
144
151 virtual Tensor<3, dim>
152 compute_3rd_derivative(const unsigned int i, const Point<dim> &p) const = 0;
153
160 virtual Tensor<4, dim>
161 compute_4th_derivative(const unsigned int i, const Point<dim> &p) const = 0;
162
169 virtual Tensor<1, dim>
170 compute_grad(const unsigned int /*i*/, const Point<dim> & /*p*/) const = 0;
171
178 virtual Tensor<2, dim>
179 compute_grad_grad(const unsigned int /*i*/,
180 const Point<dim> & /*p*/) const = 0;
181
185 unsigned int
186 n() const;
187
193 virtual unsigned int
194 degree() const;
195
206 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
207 clone() const = 0;
208
212 virtual std::string
213 name() const = 0;
214
218 virtual std::size_t
219 memory_consumption() const;
220
221private:
225 const unsigned int polynomial_degree;
226
230 const unsigned int n_pols;
231};
232
233
234//
235// We "default" the destructor out of line here to work around a sublety
236// when compiling with Clang in CUDA mode:
237//
238// A destructor defaulted on its *first* declaration is treated like an
239// *implicit* destructor and inferred to be __host__ __device__. That
240// inference would propagate to the implicit destructors of all derived
241// classes and fail "device" compilation, because Polynomials::Polynomial's
242// destructor is a host-only function.
243//
244// A destructor defaulted outside the class is user-provided and remains a
245// host function.
246//
247template <int dim>
249
250
251
252template <int dim>
253inline unsigned int
255{
256 return n_pols;
257}
258
259
260
261template <int dim>
262inline unsigned int
264{
265 return polynomial_degree;
266}
267
268
269
270template <int dim>
271template <int order>
274 const Point<dim> &p) const
275{
276 if constexpr (order == 1)
277 {
278 return compute_1st_derivative(i, p);
279 }
280 else if constexpr (order == 2)
281 {
282 return compute_2nd_derivative(i, p);
283 }
284 else if constexpr (order == 3)
285 {
286 return compute_3rd_derivative(i, p);
287 }
288 else if constexpr (order == 4)
289 {
290 return compute_4th_derivative(i, p);
291 }
292 else
293 {
295 return {};
296 }
297}
298
300
301#endif
Definition point.h:111
ScalarPolynomialsBase(ScalarPolynomialsBase< dim > &&)=default
virtual Tensor< 2, dim > compute_grad_grad(const unsigned int, const Point< dim > &) const =0
virtual Tensor< 4, dim > compute_4th_derivative(const unsigned int i, const Point< dim > &p) const =0
virtual Tensor< 1, dim > compute_grad(const unsigned int, const Point< dim > &) const =0
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() const =0
virtual std::string name() const =0
virtual 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 =0
virtual Tensor< 3, dim > compute_3rd_derivative(const unsigned int i, const Point< dim > &p) const =0
virtual Tensor< 1, dim > compute_1st_derivative(const unsigned int i, const Point< dim > &p) const =0
virtual unsigned int degree() const
virtual ~ScalarPolynomialsBase()
const unsigned int polynomial_degree
virtual double compute_value(const unsigned int i, const Point< dim > &p) const =0
virtual Tensor< 2, dim > compute_2nd_derivative(const unsigned int i, const Point< dim > &p) const =0
virtual std::size_t memory_consumption() const
ScalarPolynomialsBase(const ScalarPolynomialsBase< dim > &)=default
Tensor< order, dim > compute_derivative(const unsigned int i, const Point< dim > &p) const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_NOT_IMPLEMENTED()