Debian Codegraph @

include/deal.II/base/polynomials_p.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2004 - 2022 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 #ifndef dealii_polynomials_P_h
16 #define dealii_polynomials_P_h
17
18
19 #include <deal.II/base/config.h>
20
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/point.h>
23 #include <deal.II/base/polynomial.h>
24 #include <deal.II/base/polynomial_space.h>
25 #include <deal.II/base/tensor.h>
26
27 #include <memory>
28 #include <vector>
29
30 DEAL_II_NAMESPACE_OPEN
31 /**
32 * @addtogroup Polynomials
33 * @{
34 */
35
36 /**
37 * This class implements the polynomial space of degree <tt>p</tt> based on
38 * the monomials ${1,x,x^2,...}$. I.e. in <tt>d</tt> dimensions it constructs
39 * all polynomials of the form $\prod_{i=1}^d x_i^{n_i}$, where $\sum_i
40 * n_i\leq p$. The base polynomials are given a specific ordering, e.g. in 2
41 * dimensions: ${1,x,y,xy,x^2,y^2,x^2y,xy^2,x^3,y^3,...}$. The ordering of the
42 * monomials in $P_k1$ matches the ordering of the monomials in $P_k2$ for
43 * $k2>k1$.
44 */
45 template <int dim>
46 class PolynomialsP : public PolynomialSpace<dim>
47 {
48 public:
49 /**
50 * Access to the dimension of this object, for checking and automatic
51 * setting of dimension in other classes.
52 */
53 static constexpr unsigned int dimension = dim;
54
55 /**
56 * Constructor. Creates all basis functions of $P_p$. @arg p: the degree of
57 * the polynomial space
58 */
59 PolynomialsP(const unsigned int p);
60
61 /**
62 * Return the degree <tt>p</tt> of the polynomial space <tt>P_p</tt>.
63 *
64 * Note, that this number is <tt>PolynomialSpace::degree()-1</tt>, compare
65 * definition in PolynomialSpace.
66 */
67 virtual unsigned int
68 degree() const override;
69
70 /**
71 * For the <tt>n</tt>th polynomial $p_n(x,y,z)=x^i y^j z^k$ this function
72 * gives the degrees i,j,k in the x,y,z directions.
73 *
74 * In 1d and 2d, obviously only i and i,j are returned.
75 */
76 std::array<unsigned int, dim>
77 directional_degrees(unsigned int n) const;
78
79 std::unique_ptr<ScalarPolynomialsBase<dim>>
80 clone() const override
81 {
82 return std::make_unique<PolynomialsP<dim>>(*this);
83 }
84
85 private:
86 /**
87 * Fills the <tt>index_map</tt>.
88 */
89 void
90 create_polynomial_ordering(std::vector<unsigned int> &index_map) const;
91
92 /**
93 * Degree <tt>p</tt> of the polynomial space $P_p$, i.e. the number
94 * <tt>p</tt> which was given to the constructor.
95 */
96 const unsigned int p;
97 };
98
99 /** @} */
100
101 template <int dim>
102 inline unsigned int
103 PolynomialsP<dim>::degree() const
104 {
105 return p;
106 }
107
108
109 template <int dim>
110 inline std::array<unsigned int, dim>
111 PolynomialsP<dim>::directional_degrees(unsigned int n) const
112 {
113 return this->compute_index(n);
114 }
115
116 DEAL_II_NAMESPACE_CLOSE
117
118 #endif