| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2012 - 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 |
|
| 16 |
#ifndef dealii_fe_q_dg0_h |
| 17 |
#define dealii_fe_q_dg0_h |
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <deal.II/base/tensor_product_polynomials_const.h> |
| 22 |
|
| 23 |
#include <deal.II/fe/fe_q_base.h> |
| 24 |
|
| 25 |
DEAL_II_NAMESPACE_OPEN |
| 26 |
|
| 27 |
|
| 28 |
/** |
| 29 |
* @addtogroup fe |
| 30 |
* @{ |
| 31 |
*/ |
| 32 |
|
| 33 |
/** |
| 34 |
* Implementation of a scalar Lagrange finite element @p Qp+DG0 that yields |
| 35 |
* the finite element space of continuous, piecewise polynomials of degree @p |
| 36 |
* p in each coordinate direction plus the space of locally constant |
| 37 |
* functions. This class is realized using tensor product polynomials based on |
| 38 |
* equidistant or given support points. |
| 39 |
* |
| 40 |
* The standard constructor of this class takes the degree @p p of this finite |
| 41 |
* element. Alternatively, it can take a quadrature formula @p points defining |
| 42 |
* the support points of the Lagrange interpolation in one coordinate |
| 43 |
* direction. |
| 44 |
* |
| 45 |
* For more information about the <tt>spacedim</tt> template parameter check |
| 46 |
* the documentation of FiniteElement or the one of Triangulation. |
| 47 |
* |
| 48 |
* For more information regarding this element see @cite Boffi2012 . |
| 49 |
* |
| 50 |
* <h3>Implementation</h3> |
| 51 |
* |
| 52 |
* The constructor creates a TensorProductPolynomials object that includes the |
| 53 |
* tensor product of @p LagrangeEquidistant polynomials of degree @p p plus |
| 54 |
* the locally constant function. This @p TensorProductPolynomialsConst object |
| 55 |
* provides all values and derivatives of the shape functions. In case a |
| 56 |
* quadrature rule is given, the constructor creates a |
| 57 |
* TensorProductPolynomialsConst object that includes the tensor product of @p |
| 58 |
* Lagrange polynomials with the support points from @p points and a locally |
| 59 |
* constant function. |
| 60 |
* |
| 61 |
* Furthermore the constructor fills the @p interface_constrains, the @p |
| 62 |
* prolongation (embedding) and the @p restriction matrices. |
| 63 |
* |
| 64 |
* <h3>Numbering of the degrees of freedom (DoFs)</h3> |
| 65 |
* |
| 66 |
* The original ordering of the shape functions represented by the |
| 67 |
* TensorProductPolynomialsConst is a tensor product numbering. However, the |
| 68 |
* shape functions on a cell are renumbered beginning with the shape functions |
| 69 |
* whose support points are at the vertices, then on the line, on the quads, |
| 70 |
* and finally (for 3d) on the hexes. Finally there is a support point for the |
| 71 |
* discontinuous shape function in the middle of the cell. To be explicit, |
| 72 |
* these numberings are listed in the following: |
| 73 |
* |
| 74 |
* <h4>Q1 elements</h4> |
| 75 |
* <ul> |
| 76 |
* <li> 1d case: |
| 77 |
* @verbatim |
| 78 |
* 0---2---1 |
| 79 |
* @endverbatim |
| 80 |
* |
| 81 |
* <li> 2d case: |
| 82 |
* @verbatim |
| 83 |
* 2-------3 |
| 84 |
* | | |
| 85 |
* | 5 | |
| 86 |
* | | |
| 87 |
* 0-------1 |
| 88 |
* @endverbatim |
| 89 |
* |
| 90 |
* <li> 3d case: |
| 91 |
* @verbatim |
| 92 |
* 6-------7 6-------7 |
| 93 |
* /| | / /| |
| 94 |
* / | | / / | |
| 95 |
* / | | / / | |
| 96 |
* 4 | 8 | 4-------5 | |
| 97 |
* | 2-------3 | | 3 |
| 98 |
* | / / | | / |
| 99 |
* | / / | | / |
| 100 |
* |/ / | |/ |
| 101 |
* 0-------1 0-------1 |
| 102 |
* @endverbatim |
| 103 |
* |
| 104 |
* The respective coordinate values of the support points of the degrees of |
| 105 |
* freedom are as follows: |
| 106 |
* <ul> |
| 107 |
* <li> Index 0: <tt>[ 0, 0, 0]</tt>; |
| 108 |
* <li> Index 1: <tt>[ 1, 0, 0]</tt>; |
| 109 |
* <li> Index 2: <tt>[ 0, 1, 0]</tt>; |
| 110 |
* <li> Index 3: <tt>[ 1, 1, 0]</tt>; |
| 111 |
* <li> Index 4: <tt>[ 0, 0, 1]</tt>; |
| 112 |
* <li> Index 5: <tt>[ 1, 0, 1]</tt>; |
| 113 |
* <li> Index 6: <tt>[ 0, 1, 1]</tt>; |
| 114 |
* <li> Index 7: <tt>[ 1, 1, 1]</tt>; |
| 115 |
* <li> Index 8: <tt>[1/2, 1/2, 1/2]</tt>; |
| 116 |
* </ul> |
| 117 |
* </ul> |
| 118 |
* <h4>Q2 elements</h4> |
| 119 |
* <ul> |
| 120 |
* <li> 1d case: |
| 121 |
* @verbatim |
| 122 |
* 0---2---1 |
| 123 |
* @endverbatim |
| 124 |
* Index 3 has the same coordinates as index 2 |
| 125 |
* |
| 126 |
* <li> 2d case: |
| 127 |
* @verbatim |
| 128 |
* 2---7---3 |
| 129 |
* | | |
| 130 |
* 4 8 5 |
| 131 |
* | | |
| 132 |
* 0---6---1 |
| 133 |
* @endverbatim |
| 134 |
* Index 9 has the same coordinates as index 2 |
| 135 |
* |
| 136 |
* <li> 3d case: |
| 137 |
* @verbatim |
| 138 |
* 6--15---7 6--15---7 |
| 139 |
* /| | / /| |
| 140 |
* 12 | 19 12 1319 |
| 141 |
* / 18 | / / | |
| 142 |
* 4 | | 4---14--5 | |
| 143 |
* | 2---11--3 | | 3 |
| 144 |
* | / / | 17 / |
| 145 |
* 16 8 9 16 | 9 |
| 146 |
* |/ / | |/ |
| 147 |
* 0---10--1 0---8---1 |
| 148 |
* |
| 149 |
* *-------* *-------* |
| 150 |
* /| | / /| |
| 151 |
* / | 23 | / 25 / | |
| 152 |
* / | | / / | |
| 153 |
* * | | *-------* | |
| 154 |
* |20 *-------* | |21 * |
| 155 |
* | / / | 22 | / |
| 156 |
* | / 24 / | | / |
| 157 |
* |/ / | |/ |
| 158 |
* *-------* *-------* |
| 159 |
* @endverbatim |
| 160 |
* The center vertices have number 26 and 27. |
| 161 |
* |
| 162 |
* The respective coordinate values of the support points of the degrees of |
| 163 |
* freedom are as follows: |
| 164 |
* <ul> |
| 165 |
* <li> Index 0: <tt>[0, 0, 0]</tt>; |
| 166 |
* <li> Index 1: <tt>[1, 0, 0]</tt>; |
| 167 |
* <li> Index 2: <tt>[0, 1, 0]</tt>; |
| 168 |
* <li> Index 3: <tt>[1, 1, 0]</tt>; |
| 169 |
* <li> Index 4: <tt>[0, 0, 1]</tt>; |
| 170 |
* <li> Index 5: <tt>[1, 0, 1]</tt>; |
| 171 |
* <li> Index 6: <tt>[0, 1, 1]</tt>; |
| 172 |
* <li> Index 7: <tt>[1, 1, 1]</tt>; |
| 173 |
* <li> Index 8: <tt>[0, 1/2, 0]</tt>; |
| 174 |
* <li> Index 9: <tt>[1, 1/2, 0]</tt>; |
| 175 |
* <li> Index 10: <tt>[1/2, 0, 0]</tt>; |
| 176 |
* <li> Index 11: <tt>[1/2, 1, 0]</tt>; |
| 177 |
* <li> Index 12: <tt>[0, 1/2, 1]</tt>; |
| 178 |
* <li> Index 13: <tt>[1, 1/2, 1]</tt>; |
| 179 |
* <li> Index 14: <tt>[1/2, 0, 1]</tt>; |
| 180 |
* <li> Index 15: <tt>[1/2, 1, 1]</tt>; |
| 181 |
* <li> Index 16: <tt>[0, 0, 1/2]</tt>; |
| 182 |
* <li> Index 17: <tt>[1, 0, 1/2]</tt>; |
| 183 |
* <li> Index 18: <tt>[0, 1, 1/2]</tt>; |
| 184 |
* <li> Index 19: <tt>[1, 1, 1/2]</tt>; |
| 185 |
* <li> Index 20: <tt>[0, 1/2, 1/2]</tt>; |
| 186 |
* <li> Index 21: <tt>[1, 1/2, 1/2]</tt>; |
| 187 |
* <li> Index 22: <tt>[1/2, 0, 1/2]</tt>; |
| 188 |
* <li> Index 23: <tt>[1/2, 1, 1/2]</tt>; |
| 189 |
* <li> Index 24: <tt>[1/2, 1/2, 0]</tt>; |
| 190 |
* <li> Index 25: <tt>[1/2, 1/2, 1]</tt>; |
| 191 |
* <li> Index 26: <tt>[1/2, 1/2, 1/2]</tt>; |
| 192 |
* <li> Index 27: <tt>[1/2, 1/2, 1/2]</tt>; |
| 193 |
* </ul> |
| 194 |
* </ul> |
| 195 |
* <h4>Q3 elements</h4> |
| 196 |
* <ul> |
| 197 |
* <li> 1d case: |
| 198 |
* @verbatim |
| 199 |
* 0--2-4-3--1 |
| 200 |
* @endverbatim |
| 201 |
* |
| 202 |
* <li> 2d case: |
| 203 |
* @verbatim |
| 204 |
* 2--10-11-3 |
| 205 |
* | | |
| 206 |
* 5 14 15 7 |
| 207 |
* | 16 | |
| 208 |
* 4 12 13 6 |
| 209 |
* | | |
| 210 |
* 0--8--9--1 |
| 211 |
* @endverbatim |
| 212 |
* </ul> |
| 213 |
* <h4>Q4 elements</h4> |
| 214 |
* <ul> |
| 215 |
* <li> 1d case: |
| 216 |
* @verbatim |
| 217 |
* 0--2--3--4--1 |
| 218 |
* @endverbatim |
| 219 |
* Index 5 has the same coordinates as index 3 |
| 220 |
* |
| 221 |
* <li> 2d case: |
| 222 |
* @verbatim |
| 223 |
* 2--13-14-15-3 |
| 224 |
* | | |
| 225 |
* 6 22 23 24 9 |
| 226 |
* | | |
| 227 |
* 5 19 20 21 8 |
| 228 |
* | | |
| 229 |
* 4 16 17 18 7 |
| 230 |
* | | |
| 231 |
* 0--10-11-12-1 |
| 232 |
* @endverbatim |
| 233 |
* Index 21 has the same coordinates as index 20 |
| 234 |
* </ul> |
| 235 |
*/ |
| 236 |
template <int dim, int spacedim = dim> |
| 237 |
class FE_Q_DG0 : public FE_Q_Base<dim, spacedim> |
| 238 |
{ |
| 239 |
public: |
| 240 |
/** |
| 241 |
* Constructor for tensor product polynomials of degree @p p plus locally |
| 242 |
* constant functions. |
| 243 |
*/ |
| 244 |
FE_Q_DG0(const unsigned int p); |
| 245 |
|
| 246 |
/** |
| 247 |
* Constructor for tensor product polynomials with support points @p points |
| 248 |
* plus locally constant functions based on a one-dimensional quadrature |
| 249 |
* formula. The degree of the finite element is <tt>points.size()-1</tt>. |
| 250 |
* Note that the first point has to be 0 and the last one 1. |
| 251 |
*/ |
| 252 |
FE_Q_DG0(const Quadrature<1> &points); |
| 253 |
|
| 254 |
/** |
| 255 |
* Return a string that uniquely identifies a finite element. This class |
| 256 |
* returns <tt>FE_Q_DG0<dim>(degree)</tt>, with @p dim and @p degree |
| 257 |
* replaced by appropriate values. |
| 258 |
*/ |
| 259 |
virtual std::string |
| 260 |
get_name() const override; |
| 261 |
|
| 262 |
// documentation inherited from the base class |
| 263 |
virtual void |
| 264 |
convert_generalized_support_point_values_to_dof_values( |
| 265 |
const std::vector<Vector<double>> &support_point_values, |
| 266 |
std::vector<double> &nodal_values) const override; |
| 267 |
|
| 268 |
/** |
| 269 |
* Return the matrix interpolating from the given finite element to the |
| 270 |
* present one. The size of the matrix is then @p dofs_per_cell times |
| 271 |
* <tt>source.n_dofs_per_cell()</tt>. |
| 272 |
* |
| 273 |
* These matrices are only available if the source element is also a @p |
| 274 |
* FE_Q_DG0 element. Otherwise, an exception of type |
| 275 |
* FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented is thrown. |
| 276 |
*/ |
| 277 |
virtual void |
| 278 |
get_interpolation_matrix(const FiniteElement<dim, spacedim> &source, |
| 279 |
FullMatrix<double> &matrix) const override; |
| 280 |
|
| 281 |
|
| 282 |
/** |
| 283 |
* This function returns @p true, if the shape function @p shape_index has |
| 284 |
* non-zero function values somewhere on the face @p face_index. |
| 285 |
*/ |
| 286 |
virtual bool |
| 287 |
has_support_on_face(const unsigned int shape_index, |
| 288 |
const unsigned int face_index) const override; |
| 289 |
|
| 290 |
/** |
| 291 |
* Return a list of constant modes of the element. For this element, there |
| 292 |
* are two constant modes despite the element is scalar: The first constant |
| 293 |
* mode is all ones for the usual FE_Q basis and the second one only using |
| 294 |
* the discontinuous part. |
| 295 |
*/ |
| 296 |
virtual std::pair<Table<2, bool>, std::vector<unsigned int>> |
| 297 |
get_constant_modes() const override; |
| 298 |
|
| 299 |
virtual std::unique_ptr<FiniteElement<dim, spacedim>> |
| 300 |
clone() const override; |
| 301 |
|
| 302 |
/** |
| 303 |
* @copydoc FiniteElement::compare_for_domination() |
| 304 |
*/ |
| 305 |
virtual FiniteElementDomination::Domination |
| 306 |
compare_for_domination(const FiniteElement<dim, spacedim> &fe_other, |
| 307 |
const unsigned int codim = 0) const override final; |
| 308 |
|
| 309 |
private: |
| 310 |
/** |
| 311 |
* Return the restriction_is_additive flags. Only the last component is |
| 312 |
* true. |
| 313 |
*/ |
| 314 |
static std::vector<bool> |
| 315 |
get_riaf_vector(const unsigned int degree); |
| 316 |
|
| 317 |
/** |
| 318 |
* Only for internal use. Its full name is @p get_dofs_per_object_vector |
| 319 |
* function and it creates the @p dofs_per_object vector that is needed |
| 320 |
* within the constructor to be passed to the constructor of @p |
| 321 |
* FiniteElementData. |
| 322 |
*/ |
| 323 |
static std::vector<unsigned int> |
| 324 |
get_dpo_vector(const unsigned int degree); |
| 325 |
}; |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
/** @} */ |
| 330 |
|
| 331 |
|
| 332 |
DEAL_II_NAMESPACE_CLOSE |
| 333 |
|
| 334 |
#endif |