| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2015 - 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_fe_bernstein_h |
| 16 |
#define dealii_fe_bernstein_h |
| 17 |
|
| 18 |
#include <deal.II/base/config.h> |
| 19 |
|
| 20 |
#include <deal.II/base/tensor_product_polynomials.h> |
| 21 |
|
| 22 |
#include <deal.II/fe/fe_q_base.h> |
| 23 |
|
| 24 |
DEAL_II_NAMESPACE_OPEN |
| 25 |
|
| 26 |
|
| 27 |
/** |
| 28 |
* @addtogroup fe |
| 29 |
* @{ |
| 30 |
*/ |
| 31 |
|
| 32 |
/** |
| 33 |
* Implementation of a scalar Bernstein finite element @p that we call |
| 34 |
* FE_Bernstein in analogy with FE_Q that yields the finite element space of |
| 35 |
* continuous, piecewise Bernstein polynomials of degree @p p in each |
| 36 |
* coordinate direction. This class is realized using tensor product |
| 37 |
* polynomials of Bernstein basis polynomials. |
| 38 |
* |
| 39 |
* |
| 40 |
* The standard constructor of this class takes the degree @p p of this finite |
| 41 |
* element. |
| 42 |
* |
| 43 |
* For more information about the <tt>spacedim</tt> template parameter check |
| 44 |
* the documentation of FiniteElement or the one of Triangulation. |
| 45 |
* |
| 46 |
* <h3>Implementation</h3> |
| 47 |
* |
| 48 |
* The constructor creates a TensorProductPolynomials object that includes the |
| 49 |
* tensor product of @p Bernstein polynomials of degree @p p. This @p |
| 50 |
* TensorProductPolynomials object provides all values and derivatives of the |
| 51 |
* shape functions. |
| 52 |
* |
| 53 |
* <h3>Numbering of the degrees of freedom (DoFs)</h3> |
| 54 |
* |
| 55 |
* The original ordering of the shape functions represented by the |
| 56 |
* TensorProductPolynomials is a tensor product numbering. However, the shape |
| 57 |
* functions on a cell are renumbered beginning with the shape functions whose |
| 58 |
* support points are at the vertices, then on the line, on the quads, and |
| 59 |
* finally (for 3d) on the hexes. See the documentation of FE_Q for more |
| 60 |
* details. |
| 61 |
*/ |
| 62 |
|
| 63 |
template <int dim, int spacedim = dim> |
| 64 |
class FE_Bernstein : public FE_Q_Base<dim, spacedim> |
| 65 |
{ |
| 66 |
public: |
| 67 |
/** |
| 68 |
* Constructor for tensor product polynomials of degree @p p. |
| 69 |
*/ |
| 70 |
FE_Bernstein(const unsigned int p); |
| 71 |
|
| 72 |
/** |
| 73 |
* FE_Bernstein is not interpolatory in the element interior, which prevents |
| 74 |
* this element from defining an interpolation matrix. An exception will be |
| 75 |
* thrown. |
| 76 |
* |
| 77 |
* This function overrides the implementation from FE_Q_Base. |
| 78 |
*/ |
| 79 |
virtual void |
| 80 |
get_interpolation_matrix(const FiniteElement<dim, spacedim> &source, |
| 81 |
FullMatrix<double> &matrix) const override; |
| 82 |
|
| 83 |
/** |
| 84 |
* FE_Bernstein is not interpolatory in the element interior, which prevents |
| 85 |
* this element from defining a restriction matrix. An exception will be |
| 86 |
* thrown. |
| 87 |
* |
| 88 |
* This function overrides the implementation from FE_Q_Base. |
| 89 |
*/ |
| 90 |
virtual const FullMatrix<double> & |
| 91 |
get_restriction_matrix( |
| 92 |
const unsigned int child, |
| 93 |
const RefinementCase<dim> &refinement_case = |
| 94 |
RefinementCase<dim>::isotropic_refinement) const override; |
| 95 |
|
| 96 |
/** |
| 97 |
* FE_Bernstein is not interpolatory in the element interior, which prevents |
| 98 |
* this element from defining a prolongation matrix. An exception will be |
| 99 |
* thrown. |
| 100 |
* |
| 101 |
* This function overrides the implementation from FE_Q_Base. |
| 102 |
*/ |
| 103 |
virtual const FullMatrix<double> & |
| 104 |
get_prolongation_matrix( |
| 105 |
const unsigned int child, |
| 106 |
const RefinementCase<dim> &refinement_case = |
| 107 |
RefinementCase<dim>::isotropic_refinement) const override; |
| 108 |
|
| 109 |
/** |
| 110 |
* Return the matrix interpolating from a face of one element to the face of |
| 111 |
* the neighboring element. The size of the matrix is then |
| 112 |
* <tt>source.dofs_per_face</tt> times <tt>this->dofs_per_face</tt>. The |
| 113 |
* FE_Bernstein element family only provides interpolation matrices for |
| 114 |
* elements of the same type, for elements that have support points, and |
| 115 |
* FE_Nothing. For all other elements, an exception of type |
| 116 |
* FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented is thrown. |
| 117 |
*/ |
| 118 |
virtual void |
| 119 |
get_face_interpolation_matrix(const FiniteElement<dim, spacedim> &source, |
| 120 |
FullMatrix<double> &matrix, |
| 121 |
const unsigned int face_no = 0) const override; |
| 122 |
|
| 123 |
/** |
| 124 |
* Return the matrix interpolating from a face of one element to the face of |
| 125 |
* the neighboring element. The size of the matrix is then |
| 126 |
* <tt>source.dofs_per_face</tt> times <tt>this->dofs_per_face</tt>. The |
| 127 |
* FE_Bernstein element family only provides interpolation matrices for |
| 128 |
* elements of the same type, for elements that have support points, and |
| 129 |
* FE_Nothing. For all other elements, an exception of type |
| 130 |
* FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented is thrown. |
| 131 |
*/ |
| 132 |
virtual void |
| 133 |
get_subface_interpolation_matrix( |
| 134 |
const FiniteElement<dim, spacedim> &source, |
| 135 |
const unsigned int subface, |
| 136 |
FullMatrix<double> &matrix, |
| 137 |
const unsigned int face_no = 0) const override; |
| 138 |
|
| 139 |
/** |
| 140 |
* Return whether this element implements its hanging node constraints in |
| 141 |
* the new way, which has to be used to make elements "hp-compatible". |
| 142 |
*/ |
| 143 |
virtual bool |
| 144 |
hp_constraints_are_implemented() const override; |
| 145 |
|
| 146 |
/** |
| 147 |
* If, on a vertex, several finite elements are active, the hp-code first |
| 148 |
* assigns the degrees of freedom of each of these FEs different global |
| 149 |
* indices. It then calls this function to find out which of them should get |
| 150 |
* identical values, and consequently can receive the same global DoF index. |
| 151 |
* This function therefore returns a list of identities between DoFs of the |
| 152 |
* present finite element object with the DoFs of @p fe_other, which is a |
| 153 |
* reference to a finite element object representing one of the other finite |
| 154 |
* elements active on this particular vertex. The function computes which of |
| 155 |
* the degrees of freedom of the two finite element objects are equivalent, |
| 156 |
* both numbered between zero and the corresponding value of |
| 157 |
* n_dofs_per_vertex() of the two finite elements. The first index of each |
| 158 |
* pair denotes one of the vertex dofs of the present element, whereas the |
| 159 |
* second is the corresponding index of the other finite element. |
| 160 |
*/ |
| 161 |
virtual std::vector<std::pair<unsigned int, unsigned int>> |
| 162 |
hp_vertex_dof_identities( |
| 163 |
const FiniteElement<dim, spacedim> &fe_other) const override; |
| 164 |
|
| 165 |
/** |
| 166 |
* Same as hp_vertex_dof_indices(), except that the function treats degrees |
| 167 |
* of freedom on lines. |
| 168 |
*/ |
| 169 |
virtual std::vector<std::pair<unsigned int, unsigned int>> |
| 170 |
hp_line_dof_identities( |
| 171 |
const FiniteElement<dim, spacedim> &fe_other) const override; |
| 172 |
|
| 173 |
/** |
| 174 |
* Same as hp_vertex_dof_indices(), except that the function treats degrees |
| 175 |
* of freedom on quads. |
| 176 |
*/ |
| 177 |
virtual std::vector<std::pair<unsigned int, unsigned int>> |
| 178 |
hp_quad_dof_identities(const FiniteElement<dim, spacedim> &fe_other, |
| 179 |
const unsigned int face_no = 0) const override; |
| 180 |
|
| 181 |
/** |
| 182 |
* @copydoc FiniteElement::compare_for_domination() |
| 183 |
*/ |
| 184 |
virtual FiniteElementDomination::Domination |
| 185 |
compare_for_domination(const FiniteElement<dim, spacedim> &fe_other, |
| 186 |
const unsigned int codim = 0) const override final; |
| 187 |
|
| 188 |
/** |
| 189 |
* Return a string that uniquely identifies a finite element. This class |
| 190 |
* returns <tt>FE_Bernstein<dim>(degree)</tt>, with @p dim and @p degree |
| 191 |
* replaced by appropriate values. |
| 192 |
*/ |
| 193 |
virtual std::string |
| 194 |
get_name() const override; |
| 195 |
|
| 196 |
virtual std::unique_ptr<FiniteElement<dim, spacedim>> |
| 197 |
clone() const override; |
| 198 |
|
| 199 |
protected: |
| 200 |
/** |
| 201 |
* Only for internal use. Its full name is @p get_dofs_per_object_vector |
| 202 |
* function and it creates the @p dofs_per_object vector that is needed |
| 203 |
* within the constructor to be passed to the constructor of @p |
| 204 |
* FiniteElementData. |
| 205 |
*/ |
| 206 |
static std::vector<unsigned int> |
| 207 |
get_dpo_vector(const unsigned int degree); |
| 208 |
|
| 209 |
/** |
| 210 |
* This function renumbers Bernstein basis functions from hierarchic to |
| 211 |
* lexicographic numbering. |
| 212 |
*/ |
| 213 |
TensorProductPolynomials<dim> |
| 214 |
renumber_bases(const unsigned int degree); |
| 215 |
}; |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
/** @} */ |
| 220 |
|
| 221 |
DEAL_II_NAMESPACE_CLOSE |
| 222 |
|
| 223 |
#endif |