| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2023 - 2024 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_hermite_h |
| 16 |
#define dealii_fe_hermite_h |
| 17 |
|
| 18 |
#include <deal.II/base/config.h> |
| 19 |
|
| 20 |
#include <deal.II/base/polynomials_hermite.h> |
| 21 |
|
| 22 |
#include <deal.II/fe/fe_poly.h> |
| 23 |
|
| 24 |
#include <string> |
| 25 |
#include <vector> |
| 26 |
|
| 27 |
DEAL_II_NAMESPACE_OPEN |
| 28 |
|
| 29 |
/** |
| 30 |
* @addtogroup fe |
| 31 |
* @{ |
| 32 |
*/ |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
/** |
| 37 |
* This class implements a Hermite interpolation basis of maximum regularity |
| 38 |
* elements (see @cite CiarletRiavart1972interpolation). These bases are always |
| 39 |
* of odd polynomial degree, have regularity $r=\frac{p-1}{2}$ and are defined |
| 40 |
* up to polynomial degree $p=13$, with larger degrees currently being |
| 41 |
* ill-conditioned. |
| 42 |
* |
| 43 |
* Each node has $(r+1)^{d}$ degrees of freedom (DoFs) assigned to it, |
| 44 |
* corresponding to various derivatives up to order $r$ in each direction. |
| 45 |
* DoFs at each node are not consecutive in lexicographic ordering for |
| 46 |
* $d>1$ due to the tensor product construction of the basis. The |
| 47 |
* ordering is determined by the direction of the derivative each function |
| 48 |
* corresponds to; first by $x$-derivatives, then $y$, then $z$. Locally over |
| 49 |
* each element the DoFs are ordered similarly. See below for the local ordering |
| 50 |
* for $r=1$, where DoFs are ordered from 0 to $(2r+2)^{d}-1$: |
| 51 |
* |
| 52 |
* <code>FE_Hermite<1>(3)</code> |
| 53 |
* |
| 54 |
* @verbatim |
| 55 |
* (0)________________(2) |
| 56 |
* (1) (3) |
| 57 |
* @endverbatim |
| 58 |
* |
| 59 |
* <code>FE_Hermite<2>(3)</code>: |
| 60 |
* |
| 61 |
* @verbatim |
| 62 |
* ( 8, 9)__________(10,11) |
| 63 |
* (12,13) (14,15) |
| 64 |
* | | |
| 65 |
* | | |
| 66 |
* | | |
| 67 |
* | | |
| 68 |
* | | |
| 69 |
* | | |
| 70 |
* ( 0, 1)__________( 2, 3) |
| 71 |
* ( 4, 5) ( 6, 7) |
| 72 |
* @endverbatim |
| 73 |
* |
| 74 |
* <code>FE_Hermite<3>(3)</code>: |
| 75 |
* |
| 76 |
* @verbatim |
| 77 |
* (40,41,44,45)__(42,43,46,47) (40,41,44,45)__(42,43,46,47) |
| 78 |
* (56,57,60,61) (58,59,62,63) (56,57,60,61) (58,59,62,63) |
| 79 |
* / | | / / | |
| 80 |
* / | | / / | |
| 81 |
* / | | / / | |
| 82 |
* (32,33,36,37)| | (32,33,36,37)__(34,35,38,39) |
| 83 |
* (48,49,52,53)| | (48,49,52,53) (50,51,54,55) |
| 84 |
* | | | | | | |
| 85 |
* |( 8,9,12,13 )__(10,11,14,15) | |(10,11,14,15) |
| 86 |
* |(24,25,28,29) (26,27,30,31) | |(26,27,30,31) |
| 87 |
* | / / | | / |
| 88 |
* | / / | | / |
| 89 |
* | / / | | / |
| 90 |
* ( 0,1,4,5 )___( 2,3,6,7 ) ( 0,1,4,5 )___( 2,3,6,7 ) |
| 91 |
* (16,17,20,21) (18,19,22,23) (16,17,20,21) (18,19,22,23) |
| 92 |
* @endverbatim |
| 93 |
* |
| 94 |
* Due to the increased regularity constraints many of these functions are |
| 95 |
* shared between elements, leading to fewer DoFs overall. |
| 96 |
*/ |
| 97 |
template <int dim, int spacedim = dim> |
| 98 |
class FE_Hermite : public FE_Poly<dim, spacedim> |
| 99 |
{ |
| 100 |
public: |
| 101 |
/** |
| 102 |
* Constructor that creates an Hermite finite element object with |
| 103 |
* continuity in derivatives up to and including order |
| 104 |
* <code>(fe_degree - 1)/2</code>. |
| 105 |
* Throws an exception if @p fe_degree is not an odd positive integer. |
| 106 |
*/ |
| 107 |
FE_Hermite(const unsigned int fe_degree); |
| 108 |
|
| 109 |
// Other functions |
| 110 |
/** |
| 111 |
* Returns <code>FE_Hermite<dim,spacedim>(fe_degree)</code> as a |
| 112 |
* <code>std::string</code> with @p dim, @p spacedim and @p fe_degree |
| 113 |
* replaced with the correct values. |
| 114 |
*/ |
| 115 |
virtual std::string |
| 116 |
get_name() const override; |
| 117 |
|
| 118 |
/** |
| 119 |
* @copydoc dealii::FiniteElement::clone() |
| 120 |
*/ |
| 121 |
virtual std::unique_ptr<FiniteElement<dim, spacedim>> |
| 122 |
clone() const override; |
| 123 |
|
| 124 |
/** |
| 125 |
* @copydoc dealii::FiniteElement::requires_update_flags() |
| 126 |
*/ |
| 127 |
virtual UpdateFlags |
| 128 |
requires_update_flags(const UpdateFlags update_flags) const override; |
| 129 |
|
| 130 |
/** |
| 131 |
* @copydoc dealii::FiniteElement::hp_vertex_dof_identities() |
| 132 |
*/ |
| 133 |
virtual std::vector<std::pair<unsigned int, unsigned int>> |
| 134 |
hp_vertex_dof_identities( |
| 135 |
const FiniteElement<dim, spacedim> &fe_other) const override; |
| 136 |
|
| 137 |
/** |
| 138 |
* @copydoc dealii::FiniteElement::hp_line_dof_identities() |
| 139 |
*/ |
| 140 |
virtual std::vector<std::pair<unsigned int, unsigned int>> |
| 141 |
hp_line_dof_identities( |
| 142 |
const FiniteElement<dim, spacedim> &fe_other) const override; |
| 143 |
|
| 144 |
/** |
| 145 |
* @copydoc dealii::FiniteElement::hp_quad_dof_identities() |
| 146 |
*/ |
| 147 |
virtual std::vector<std::pair<unsigned int, unsigned int>> |
| 148 |
hp_quad_dof_identities(const FiniteElement<dim, spacedim> &fe_other, |
| 149 |
const unsigned int face_no = 0) const override; |
| 150 |
|
| 151 |
/** |
| 152 |
* @copydoc FiniteElement::compare_for_domination() |
| 153 |
*/ |
| 154 |
virtual FiniteElementDomination::Domination |
| 155 |
compare_for_domination(const FiniteElement<dim, spacedim> &other_fe, |
| 156 |
const unsigned int codim) const override; |
| 157 |
|
| 158 |
/** |
| 159 |
* Returns the mapping between lexicographic and hierarchic numbering |
| 160 |
* schemes for Hermite. See the class documentation for diagrams of |
| 161 |
* examples of lexicographic numbering for Hermite elements. |
| 162 |
*/ |
| 163 |
std::vector<unsigned int> |
| 164 |
get_lexicographic_to_hierarchic_numbering() const; |
| 165 |
|
| 166 |
/** |
| 167 |
* This re-implements FiniteElement::fill_fe_values() for a Hermite |
| 168 |
* polynomial basis, to account for the more complicated shape function |
| 169 |
* re-scaling that a Hermite basis requires. On a non-uniform grid, |
| 170 |
* failing to rescale function values will lead to discontinuities across |
| 171 |
* element boundaries in derivatives if elements have different sizes. |
| 172 |
* |
| 173 |
* At present this is done by only allowing certain cell mappings |
| 174 |
* (currently only MappingCartesian) which guarantee |
| 175 |
* rectangular cells, which ensures that the directions of derivatives |
| 176 |
* does not change. The derivative continuity can then be enforced by |
| 177 |
* re-scaling shape functions so that the magnitude of each derivative is |
| 178 |
* equivalent to the derivative on the reference interval. |
| 179 |
*/ |
| 180 |
virtual void |
| 181 |
fill_fe_values( |
| 182 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 183 |
const CellSimilarity::Similarity cell_similarity, |
| 184 |
const Quadrature<dim> &quadrature, |
| 185 |
const Mapping<dim, spacedim> &mapping, |
| 186 |
const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal, |
| 187 |
const dealii::internal::FEValuesImplementation::MappingRelatedData<dim, |
| 188 |
spacedim> |
| 189 |
&mapping_data, |
| 190 |
const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal, |
| 191 |
dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim, |
| 192 |
spacedim> |
| 193 |
&output_data) const override; |
| 194 |
|
| 195 |
using FiniteElement<dim, spacedim>::fill_fe_face_values; |
| 196 |
|
| 197 |
/** |
| 198 |
* This re-implements FiniteElement::fill_fe_face_values() for |
| 199 |
* Hermite polynomial bases, for the same reasons as described for |
| 200 |
* FEHermite::fill_fe_values(). |
| 201 |
*/ |
| 202 |
virtual void |
| 203 |
fill_fe_face_values( |
| 204 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 205 |
const unsigned int face_no, |
| 206 |
const hp::QCollection<dim - 1> &quadrature, |
| 207 |
const Mapping<dim, spacedim> &mapping, |
| 208 |
const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal, |
| 209 |
const dealii::internal::FEValuesImplementation::MappingRelatedData<dim, |
| 210 |
spacedim> |
| 211 |
&mapping_data, |
| 212 |
const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal, |
| 213 |
dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim, |
| 214 |
spacedim> |
| 215 |
&output_data) const override; |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
protected: |
| 220 |
/** |
| 221 |
* Wrapper function for FE_Poly::get_data() that ensures relevant |
| 222 |
* shape value data is copied to the new data object as well. |
| 223 |
*/ |
| 224 |
virtual std::unique_ptr< |
| 225 |
typename FiniteElement<dim, spacedim>::InternalDataBase> |
| 226 |
get_data( |
| 227 |
const UpdateFlags update_flags, |
| 228 |
const Mapping<dim, spacedim> &mapping, |
| 229 |
const Quadrature<dim> &quadrature, |
| 230 |
dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim, |
| 231 |
spacedim> |
| 232 |
&output_data) const override |
| 233 |
{ |
| 234 |
std::unique_ptr<typename FiniteElement<dim, spacedim>::InternalDataBase> |
| 235 |
data_ptr = FE_Poly<dim, spacedim>::get_data(update_flags, |
| 236 |
mapping, |
| 237 |
quadrature, |
| 238 |
output_data); |
| 239 |
auto &data = |
| 240 |
dynamic_cast<typename FE_Poly<dim, spacedim>::InternalData &>(*data_ptr); |
| 241 |
|
| 242 |
const unsigned int n_q_points = quadrature.size(); |
| 243 |
|
| 244 |
if ((update_flags & update_values) && |
| 245 |
((output_data.shape_values.n_rows() > 0) && |
| 246 |
(output_data.shape_values.n_cols() == n_q_points))) |
| 247 |
data.shape_values = output_data.shape_values; |
| 248 |
|
| 249 |
return data_ptr; |
| 250 |
} |
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
private: |
| 255 |
/** |
| 256 |
* Variable storing the order of the highest derivative that the current |
| 257 |
* FE_Hermite object can enforce continuity for. Here the order |
| 258 |
* of derivative only counts in one spatial direction, so the derivative |
| 259 |
* $\frac{d^{2}f}{dx \; dy}$ would be counted as a first order derivative |
| 260 |
* of $f$, as an example. |
| 261 |
*/ |
| 262 |
unsigned int regularity; |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
public: |
| 267 |
/** |
| 268 |
* Returns the regularity of the Hermite FE basis. |
| 269 |
*/ |
| 270 |
inline unsigned int |
| 271 |
get_regularity() const |
| 272 |
{ |
| 273 |
return this->regularity; |
| 274 |
}; |
| 275 |
}; |
| 276 |
|
| 277 |
/** @} */ |
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
DEAL_II_NAMESPACE_CLOSE |
| 282 |
|
| 283 |
#endif |