Reference documentation for deal.II version 9.3.3
\(\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\}}\)
scalar_polynomials_base.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2005 - 2021 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_scalar_polynomials_base_h
17#define dealii_scalar_polynomials_base_h
18
19
20#include <deal.II/base/config.h>
21
23#include <deal.II/base/point.h>
24#include <deal.II/base/tensor.h>
25
26#include <vector>
27
29
60template <int dim>
62{
63public:
68 ScalarPolynomialsBase(const unsigned int deg,
69 const unsigned int n_polynomials);
70
75
80
85 virtual ~ScalarPolynomialsBase() = default;
86
99 virtual void
100 evaluate(const Point<dim> & unit_point,
101 std::vector<double> & values,
102 std::vector<Tensor<1, dim>> &grads,
103 std::vector<Tensor<2, dim>> &grad_grads,
104 std::vector<Tensor<3, dim>> &third_derivatives,
105 std::vector<Tensor<4, dim>> &fourth_derivatives) const = 0;
106
113 virtual double
114 compute_value(const unsigned int i, const Point<dim> &p) const = 0;
115
124 template <int order>
126 compute_derivative(const unsigned int i, const Point<dim> &p) const;
127
134 virtual Tensor<1, dim>
135 compute_1st_derivative(const unsigned int i, const Point<dim> &p) const = 0;
136
143 virtual Tensor<2, dim>
144 compute_2nd_derivative(const unsigned int i, const Point<dim> &p) const = 0;
145
152 virtual Tensor<3, dim>
153 compute_3rd_derivative(const unsigned int i, const Point<dim> &p) const = 0;
154
161 virtual Tensor<4, dim>
162 compute_4th_derivative(const unsigned int i, const Point<dim> &p) const = 0;
163
170 virtual Tensor<1, dim>
171 compute_grad(const unsigned int /*i*/, const Point<dim> & /*p*/) const = 0;
172
179 virtual Tensor<2, dim>
180 compute_grad_grad(const unsigned int /*i*/,
181 const Point<dim> & /*p*/) const = 0;
182
186 unsigned int
187 n() const;
188
194 virtual unsigned int
195 degree() const;
196
207 virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
208 clone() const = 0;
209
213 virtual std::string
214 name() const = 0;
215
219 virtual std::size_t
220 memory_consumption() const;
221
222private:
226 const unsigned int polynomial_degree;
227
231 const unsigned int n_pols;
232};
233
234
235
236template <int dim>
237inline unsigned int
239{
240 return n_pols;
241}
242
243
244
245template <int dim>
246inline unsigned int
248{
249 return polynomial_degree;
250}
251
252
253
254template <int dim>
255template <int order>
258 const Point<dim> & p) const
259{
260 if (order == 1)
261 {
262 auto derivative = compute_1st_derivative(i, p);
263 return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
264 }
265 if (order == 2)
266 {
267 auto derivative = compute_2nd_derivative(i, p);
268 return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
269 }
270 if (order == 3)
271 {
272 auto derivative = compute_3rd_derivative(i, p);
273 return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
274 }
275 if (order == 4)
276 {
277 auto derivative = compute_4th_derivative(i, p);
278 return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
279 }
280 Assert(false, ExcNotImplemented());
281 Tensor<order, dim> empty;
282 return empty;
283}
284
286
287#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 ~ScalarPolynomialsBase()=default
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
ScalarPolynomialsBase(const unsigned int deg, const unsigned int n_polynomials)
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:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
Definition: exceptions.h:1465