Reference documentation for deal.II version GIT 29f9da0a34 2023-12-07 10: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\}}\)
tensor_product_polynomials_const.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2012 - 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_tensor_product_polynomials_const_h
17 #define dealii_tensor_product_polynomials_const_h
18 
19 
20 #include <deal.II/base/config.h>
21 
23 #include <deal.II/base/point.h>
25 #include <deal.II/base/tensor.h>
27 #include <deal.II/base/utilities.h>
28 
29 #include <vector>
30 
32 
33 
45 template <int dim>
47 {
48 public:
53  static constexpr unsigned int dimension = dim;
54 
60  template <class Pol>
61  TensorProductPolynomialsConst(const std::vector<Pol> &pols);
62 
66  void
67  output_indices(std::ostream &out) const;
68 
74  void
75  set_numbering(const std::vector<unsigned int> &renumber);
76 
80  const std::vector<unsigned int> &
81  get_numbering() const;
82 
86  const std::vector<unsigned int> &
88 
101  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 override;
108 
121  double
122  compute_value(const unsigned int i, const Point<dim> &p) const override;
123 
138  template <int order>
140  compute_derivative(const unsigned int i, const Point<dim> &p) const;
141 
145  virtual Tensor<1, dim>
146  compute_1st_derivative(const unsigned int i,
147  const Point<dim> &p) const override;
148 
152  virtual Tensor<2, dim>
153  compute_2nd_derivative(const unsigned int i,
154  const Point<dim> &p) const override;
155 
159  virtual Tensor<3, dim>
160  compute_3rd_derivative(const unsigned int i,
161  const Point<dim> &p) const override;
162 
166  virtual Tensor<4, dim>
167  compute_4th_derivative(const unsigned int i,
168  const Point<dim> &p) const override;
169 
183  compute_grad(const unsigned int i, const Point<dim> &p) const override;
184 
198  compute_grad_grad(const unsigned int i, const Point<dim> &p) const override;
199 
204  unsigned int
205  n() const;
206 
211  std::string
212  name() const override;
213 
217  virtual std::unique_ptr<ScalarPolynomialsBase<dim>>
218  clone() const override;
219 
220 private:
225 
229  std::vector<unsigned int> index_map;
230 
234  std::vector<unsigned int> index_map_inverse;
235 };
236 
240 /* ---------------- template and inline functions ---------- */
241 
242 #ifndef DOXYGEN
243 
244 template <int dim>
245 template <class Pol>
247  const std::vector<Pol> &pols)
248  : ScalarPolynomialsBase<dim>(1, Utilities::fixed_power<dim>(pols.size()) + 1)
249  , tensor_polys(pols)
250  , index_map(tensor_polys.n() + 1)
251  , index_map_inverse(tensor_polys.n() + 1)
252 {}
253 
254 
255 
256 template <int dim>
257 inline unsigned int
259 {
260  return tensor_polys.n() + 1;
261 }
262 
263 
264 
265 template <int dim>
266 inline const std::vector<unsigned int> &
268 {
269  return index_map;
270 }
271 
272 
273 template <int dim>
274 inline const std::vector<unsigned int> &
276 {
277  return index_map_inverse;
278 }
279 
280 
281 template <int dim>
282 inline std::string
284 {
285  return "TensorProductPolynomialsConst";
286 }
287 
288 
289 template <>
290 inline unsigned int
292 {
294 }
295 
296 
297 template <int dim>
298 template <int order>
301  const unsigned int i,
302  const Point<dim> &p) const
303 {
304  const unsigned int max_indices = tensor_polys.n();
305  Assert(i <= max_indices, ExcInternalError());
306 
307  // treat the regular basis functions
308  if (i < max_indices)
309  return tensor_polys.template compute_derivative<order>(i, p);
310  else
311  // this is for the constant function
312  return Tensor<order, dim>();
313 }
314 
315 
316 
317 template <int dim>
318 inline Tensor<1, dim>
320  const unsigned int i,
321  const Point<dim> &p) const
322 {
323  return compute_derivative<1>(i, p);
324 }
325 
326 
327 
328 template <int dim>
329 inline Tensor<2, dim>
331  const unsigned int i,
332  const Point<dim> &p) const
333 {
334  return compute_derivative<2>(i, p);
335 }
336 
337 
338 
339 template <int dim>
340 inline Tensor<3, dim>
342  const unsigned int i,
343  const Point<dim> &p) const
344 {
345  return compute_derivative<3>(i, p);
346 }
347 
348 
349 
350 template <int dim>
351 inline Tensor<4, dim>
353  const unsigned int i,
354  const Point<dim> &p) const
355 {
356  return compute_derivative<4>(i, p);
357 }
358 
359 #endif // DOXYGEN
361 
362 #endif
Definition: point.h:112
void output_indices(std::ostream &out) const
virtual Tensor< 2, dim > compute_2nd_derivative(const unsigned int i, const Point< dim > &p) const override
const std::vector< unsigned int > & get_numbering_inverse() const
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
const std::vector< unsigned int > & get_numbering() const
double compute_value(const unsigned int i, const Point< dim > &p) const override
Tensor< order, dim > compute_derivative(const unsigned int i, const Point< dim > &p) const
Tensor< 1, dim > compute_grad(const unsigned int i, const Point< dim > &p) const override
std::string name() const override
virtual std::unique_ptr< ScalarPolynomialsBase< dim > > clone() const override
void set_numbering(const std::vector< unsigned int > &renumber)
virtual Tensor< 4, dim > compute_4th_derivative(const unsigned int i, const Point< dim > &p) const override
Tensor< 2, dim > compute_grad_grad(const unsigned int i, const Point< dim > &p) const override
TensorProductPolynomials< dim > tensor_polys
TensorProductPolynomialsConst(const std::vector< Pol > &pols)
virtual Tensor< 1, dim > compute_1st_derivative(const unsigned int i, const Point< dim > &p) const override
unsigned int n() const
virtual Tensor< 3, dim > compute_3rd_derivative(const unsigned int i, const Point< dim > &p) const override
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
static ::ExceptionBase & ExcInternalError()
#define Assert(cond, exc)
Definition: exceptions.h:1631
T fixed_power(const T t)
Definition: utilities.h:975
static const unsigned int invalid_unsigned_int
Definition: types.h:221