Debian Codegraph @

include/deal.II/base/tensor_polynomials_base.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2019 - 2023 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_tensor_polynomials_base_h
16 #define dealii_tensor_polynomials_base_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/tensor.h>
24
25 #include <memory>
26 #include <string>
27 #include <vector>
28
29 DEAL_II_NAMESPACE_OPEN
30
31 /**
32 * This class provides a framework for the finite element polynomial
33 * classes for use with finite element classes that are derived from
34 * FE_PolyTensor. An object of this type (or rather of a type derived
35 * from this class) is stored as a member variable in each object of
36 * type FE_PolyTensor.
37 *
38 * <h3>Deriving classes</h3>
39 *
40 * Any derived class must provide the most basic properties for shape
41 * functions evaluated on the reference cell. This includes, but is not
42 * limited to, implementing the evaluate(), name(), and
43 * clone() member functions. These functions are necessary to store the
44 * most basic information of how the polynomials in the derived class evaluate
45 * at a given point on the reference cell. More information on each function can
46 * be found in the corresponding function's documentation.
47 *
48 * Some classes that derive from this class include
49 * <ul>
50 * <li> <tt>PolynomialsABF</tt>
51 * <li> <tt>PolynomialsBDM</tt>
52 * <li> <tt>PolynomialsBernardiRaugel</tt>
53 * <li> <tt>PolynomialsNedelec</tt>
54 * <li> <tt>PolynomialsRaviartThomas</tt>
55 * <li> <tt>PolynomialsRT_Bubbles</tt>
56 * </ul>
57 *
58 * @ingroup Polynomials
59 */
60 template <int dim>
61 class TensorPolynomialsBase
62 {
63 public:
64 /**
65 * Constructor. This takes the degree of the space, @p deg from the finite element
66 * class, and @p n, the number of polynomials for the space.
67 */
68 TensorPolynomialsBase(const unsigned int deg,
69 const unsigned int n_polynomials);
70
71 /**
72 * Move constructor.
73 */
74 TensorPolynomialsBase(TensorPolynomialsBase<dim> &&) = default; // NOLINT
75
76 /**
77 * Copy constructor.
78 */
79 TensorPolynomialsBase(const TensorPolynomialsBase<dim> &) = default;
80
81 /**
82 * Virtual destructor. Makes sure that pointers to this class are deleted
83 * properly.
84 */
85 virtual ~TensorPolynomialsBase() = default;
86
87 /**
88 * Compute the value and the derivatives of the polynomials at
89 * @p unit_point.
90 *
91 * The size of the vectors must either be zero or equal <tt>n()</tt>. In
92 * the first case, the function will not compute these values.
93 */
94 virtual void
95 evaluate(const Point<dim> &unit_point,
96 std::vector<Tensor<1, dim>> &values,
97 std::vector<Tensor<2, dim>> &grads,
98 std::vector<Tensor<3, dim>> &grad_grads,
99 std::vector<Tensor<4, dim>> &third_derivatives,
100 std::vector<Tensor<5, dim>> &fourth_derivatives) const = 0;
101
102 /**
103 * Return the number of polynomials.
104 */
105 unsigned int
106 n() const;
107
108 /**
109 * Return the highest polynomial degree of polynomials represented by this
110 * class. A derived class may override this if its value is different from
111 * @p my_degree.
112 */
113 unsigned int
114 degree() const;
115
116 /**
117 * A sort of virtual copy constructor, this function returns a copy of
118 * the polynomial space object. Derived classes need to override the function
119 * here in this base class and return an object of the same type as the
120 * derived class.
121 *
122 * Some places in the library, for example the constructors of FE_PolyTensor,
123 * need to make copies of polynomial spaces without knowing their exact type.
124 * They do so through this function.
125 */
126 virtual std::unique_ptr<TensorPolynomialsBase<dim>>
127 clone() const = 0;
128
129 /**
130 * Return the name of the space.
131 */
132 virtual std::string
133 name() const = 0;
134
135 private:
136 /**
137 * The highest polynomial degree of this functions represented by this object.
138 */
139 const unsigned int polynomial_degree;
140
141 /**
142 * The number of polynomials represented by this object.
143 */
144 const unsigned int n_pols;
145 };
146
147
148
149 template <int dim>
150 inline unsigned int
151 TensorPolynomialsBase<dim>::n() const
152 {
153 return n_pols;
154 }
155
156
157
158 template <int dim>
159 inline unsigned int
160 TensorPolynomialsBase<dim>::degree() const
161 {
162 return polynomial_degree;
163 }
164
165
166
167 DEAL_II_NAMESPACE_CLOSE
168
169 #endif