Debian Codegraph @

include/deal.II/base/polynomials_bdm.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2004 - 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_polynomials_BDM_h
16 #define dealii_polynomials_BDM_h
17
18
19 #include <deal.II/base/config.h>
20
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/mutex.h>
23 #include <deal.II/base/point.h>
24 #include <deal.II/base/polynomial.h>
25 #include <deal.II/base/polynomial_space.h>
26 #include <deal.II/base/tensor.h>
27 #include <deal.II/base/tensor_polynomials_base.h>
28
29 #include <vector>
30
31 DEAL_II_NAMESPACE_OPEN
32
33 /**
34 * This class implements the <i>H<sup>div</sup></i>-conforming, vector-valued
35 * Brezzi-Douglas-Marini (<i> BDM </i>) polynomials described in Brezzi and
36 * Fortin's <i>Mixed and Hybrid Finite Element Methods</i> (refer to pages
37 * 119 - 124).
38 *
39 * The <i> BDM </i> polynomial space contain the entire $(P_{k})^{n}$
40 * space (constructed with PolynomialSpace Legendre polynomials) as well as
41 * part of $(P_{k+1})^{n}$
42 * (ie. $(P_{k})^{n} \subset BDM_{k} \subset (P_{k+1})^{n}$). Furthermore,
43 * $BDM_{k}$ elements are designed so that
44 * $\nabla \cdot q \in P_{k-1} (K)$ and $q \cdot n |_{e_{i}} \in P_{k}(e_{i})$.
45 * More details
46 * of two and three dimensional $BDM_{k}$ elements are given below.
47 *<dl>
48 * <dt> In 2d:
49 * <dd> $ BDM_{k} = \{\mathbf{q} | \mathbf{q} = p_{k} (x,y) +
50 * r \; \text{curl} (x^{k+1}y) + s \;
51 * \text{curl} (xy^{k+1}), p_{k} \in (P_{k})^{2} \}$.
52 *
53 * Note: the curl of a scalar function is given by $\text{curl}(f(x,y)) =
54 * \begin{pmatrix} f_{y}(x,y) \\ -f_{x}(x,y) \end{pmatrix}$.
55 *
56 * The basis used to construct the $BDM_{1}$ shape functions is
57 * @f{align*}{
58 * \phi_0 = \begin{pmatrix} 1 \\ 0 \end{pmatrix},
59 * \phi_1 = \begin{pmatrix} -\sqrt{3}+2\sqrt{3}x \\ 0 \end{pmatrix},
60 * \phi_2 = \begin{pmatrix} -\sqrt{3}+2\sqrt{3}y \\ 0 \end{pmatrix},
61 * \phi_3 = \begin{pmatrix} 0 \\ 1 \end{pmatrix},
62 * \phi_4 = \begin{pmatrix} 0 \\ -\sqrt{3}+2\sqrt{3}x \end{pmatrix},
63 * \phi_5 = \begin{pmatrix} 0 \\ -\sqrt{3}+2\sqrt{3}y \end{pmatrix},
64 * \phi_6 = \begin{pmatrix} x^2 \\ -2xy \end{pmatrix},
65 * \phi_7 = \begin{pmatrix} 2xy \\ -y^2 \end{pmatrix}.
66 * @f}
67 *
68 * The dimension of the $BDM_{k}$ space is
69 * $(k+1)(k+2)+2$, with $k+1$ unknowns per
70 * edge and $k(k-1)$ interior unknowns.
71 *
72 * <dt> In 3d:
73 * <dd> $ BDM_{k} =
74 * \{\mathbf{q} | \mathbf{q} = p_{k} (x,y,z)
75 * + \sum_{i=0}^{k} (
76 * r_{i} \; \text{curl}
77 * \begin{pmatrix} 0\\0\\xy^{i+1}z^{k-i} \end{pmatrix}
78 * + s_{i} \; \text{curl}
79 * \begin{pmatrix} yz^{i+1}x^{k-i}\\0\\0 \end{pmatrix}
80 * + t_{i} \; \text{curl}
81 * \begin{pmatrix}0\\zx^{i+1}y^{k-i}\\0\end{pmatrix})
82 * , p_{k} \in (P_{k})^{3} \}$.
83 *
84 * Note: the 3d description of $BDM_{k}$ is not unique. See <i>Mixed and
85 * Hybrid Finite Element Methods</i> page 122 for an alternative definition.
86 *
87 * The dimension of the $BDM_{k}$ space is
88 * $\dfrac{(k+1)(k+2)(k+3)}{2}+3(k+1)$, with $\dfrac{(k+1)(k+2)}{2}$
89 * unknowns per face and $\dfrac{(k-1)k(k+1)}{2}$ interior unknowns.
90 *
91 *</dl>
92 *
93 *
94 *
95 * @ingroup Polynomials
96 */
97 template <int dim>
98 class PolynomialsBDM : public TensorPolynomialsBase<dim>
99 {
100 public:
101 /**
102 * Constructor. Creates all basis functions for BDM polynomials of given
103 * degree.
104 *
105 * @arg k: the degree of the BDM-space, which is the degree of the largest
106 * complete polynomial space <i>P<sub>k</sub></i> contained in the BDM-
107 * space.
108 */
109 PolynomialsBDM(const unsigned int k);
110
111 /**
112 * Compute the value and the first and second derivatives of each BDM
113 * polynomial at @p unit_point.
114 *
115 * The size of the vectors must either be zero or equal <tt>n()</tt>. In
116 * the first case, the function will not compute these values.
117 */
118 void
119 evaluate(const Point<dim> &unit_point,
120 std::vector<Tensor<1, dim>> &values,
121 std::vector<Tensor<2, dim>> &grads,
122 std::vector<Tensor<3, dim>> &grad_grads,
123 std::vector<Tensor<4, dim>> &third_derivatives,
124 std::vector<Tensor<5, dim>> &fourth_derivatives) const override;
125
126 /**
127 * Return the name of the space, which is <tt>BDM</tt>.
128 */
129 std::string
130 name() const override;
131
132 /**
133 * Return the number of polynomials in the space <tt>BDM(degree)</tt>
134 * without requiring to build an object of PolynomialsBDM. This is required
135 * by the FiniteElement classes.
136 */
137 static unsigned int
138 n_polynomials(const unsigned int degree);
139
140 /**
141 * @copydoc TensorPolynomialsBase::clone()
142 */
143 virtual std::unique_ptr<TensorPolynomialsBase<dim>>
144 clone() const override;
145
146 private:
147 /**
148 * An object representing the polynomial space used here. The constructor
149 * fills this with the monomial basis.
150 */
151 const PolynomialSpace<dim> polynomial_space;
152
153 /**
154 * Storage for monomials. In 2d, this is just the polynomial of order
155 * <i>k</i>. In 3d, we need all polynomials from degree zero to <i>k</i>.
156 */
157 std::vector<Polynomials::Polynomial<double>> monomials;
158
159 /**
160 * A mutex that guards the following scratch arrays.
161 */
162 mutable Threads::Mutex mutex;
163
164 /**
165 * Auxiliary memory.
166 */
167 mutable std::vector<double> p_values;
168
169 /**
170 * Auxiliary memory.
171 */
172 mutable std::vector<Tensor<1, dim>> p_grads;
173
174 /**
175 * Auxiliary memory.
176 */
177 mutable std::vector<Tensor<2, dim>> p_grad_grads;
178
179 /**
180 * Auxiliary memory.
181 */
182 mutable std::vector<Tensor<3, dim>> p_third_derivatives;
183
184 /**
185 * Auxiliary memory.
186 */
187 mutable std::vector<Tensor<4, dim>> p_fourth_derivatives;
188 };
189
190
191 template <int dim>
192 inline std::string
193 PolynomialsBDM<dim>::name() const
194 {
195 return "BDM";
196 }
197
198
199 DEAL_II_NAMESPACE_CLOSE
200
201 #endif