Reference documentation for deal.II version GIT f6a5d312c9 2023-10-04 08:50:02+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\}}\)
scalar_polynomials_base.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2005 - 2022 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 <memory>
27 #include <string>
28 #include <vector>
29 
31 
62 template <int dim>
64 {
65 public:
70  ScalarPolynomialsBase(const unsigned int deg,
71  const unsigned int n_polynomials);
72 
77 
82 
87  virtual ~ScalarPolynomialsBase() = default;
88 
101  virtual void
102  evaluate(const Point<dim> &unit_point,
103  std::vector<double> &values,
104  std::vector<Tensor<1, dim>> &grads,
105  std::vector<Tensor<2, dim>> &grad_grads,
106  std::vector<Tensor<3, dim>> &third_derivatives,
107  std::vector<Tensor<4, dim>> &fourth_derivatives) const = 0;
108 
115  virtual double
116  compute_value(const unsigned int i, const Point<dim> &p) const = 0;
117 
126  template <int order>
128  compute_derivative(const unsigned int i, const Point<dim> &p) const;
129 
136  virtual Tensor<1, dim>
137  compute_1st_derivative(const unsigned int i, const Point<dim> &p) const = 0;
138 
145  virtual Tensor<2, dim>
146  compute_2nd_derivative(const unsigned int i, const Point<dim> &p) const = 0;
147 
154  virtual Tensor<3, dim>
155  compute_3rd_derivative(const unsigned int i, const Point<dim> &p) const = 0;
156 
163  virtual Tensor<4, dim>
164  compute_4th_derivative(const unsigned int i, const Point<dim> &p) const = 0;
165 
172  virtual Tensor<1, dim>
173  compute_grad(const unsigned int /*i*/, const Point<dim> & /*p*/) const = 0;
174 
181  virtual Tensor<2, dim>
182  compute_grad_grad(const unsigned int /*i*/,
183  const Point<dim> & /*p*/) const = 0;
184 
188  unsigned int
189  n() const;
190 
196  virtual unsigned int
197  degree() const;
198 
209  virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
210  clone() const = 0;
211 
215  virtual std::string
216  name() const = 0;
217 
221  virtual std::size_t
222  memory_consumption() const;
223 
224 private:
228  const unsigned int polynomial_degree;
229 
233  const unsigned int n_pols;
234 };
235 
236 
237 
238 template <int dim>
239 inline unsigned int
241 {
242  return n_pols;
243 }
244 
245 
246 
247 template <int dim>
248 inline unsigned int
250 {
251  return polynomial_degree;
252 }
253 
254 
255 
256 template <int dim>
257 template <int order>
258 inline Tensor<order, dim>
260  const Point<dim> &p) const
261 {
262  if (order == 1)
263  {
264  auto derivative = compute_1st_derivative(i, p);
265  return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
266  }
267  if (order == 2)
268  {
269  auto derivative = compute_2nd_derivative(i, p);
270  return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
271  }
272  if (order == 3)
273  {
274  auto derivative = compute_3rd_derivative(i, p);
275  return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
276  }
277  if (order == 4)
278  {
279  auto derivative = compute_4th_derivative(i, p);
280  return *reinterpret_cast<Tensor<order, dim> *>(&derivative);
281  }
282  Assert(false, ExcNotImplemented());
283  Tensor<order, dim> empty;
284  return empty;
285 }
286 
288 
289 #endif
Definition: point.h:112
ScalarPolynomialsBase(ScalarPolynomialsBase< dim > &&)=default
virtual Tensor< 2, dim > compute_grad_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 Tensor< 3, dim > compute_3rd_derivative(const unsigned int i, const Point< dim > &p) const =0
virtual unsigned int degree() const
virtual Tensor< 1, dim > compute_grad(const unsigned int, const Point< dim > &) const =0
virtual Tensor< 1, dim > compute_1st_derivative(const unsigned int i, const Point< dim > &p) const =0
ScalarPolynomialsBase(const unsigned int deg, const unsigned int n_polynomials)
virtual Tensor< 2, dim > compute_2nd_derivative(const unsigned int i, const Point< dim > &p) const =0
const unsigned int polynomial_degree
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 double compute_value(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
virtual Tensor< 4, dim > compute_4th_derivative(const unsigned int i, const Point< dim > &p) const =0
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
#define Assert(cond, exc)
Definition: exceptions.h:1616
static ::ExceptionBase & ExcNotImplemented()