| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2001 - 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_data_h |
| 16 |
#define dealii_fe_data_h |
| 17 |
|
| 18 |
#include <deal.II/base/config.h> |
| 19 |
|
| 20 |
#include <deal.II/base/exceptions.h> |
| 21 |
|
| 22 |
#include <deal.II/grid/reference_cell.h> |
| 23 |
|
| 24 |
#include <deal.II/lac/block_indices.h> |
| 25 |
|
| 26 |
#include <vector> |
| 27 |
|
| 28 |
DEAL_II_NAMESPACE_OPEN |
| 29 |
|
| 30 |
// Forward declarations: |
| 31 |
#ifndef DOXYGEN |
| 32 |
template <int dim> |
| 33 |
class FiniteElementData; |
| 34 |
#endif |
| 35 |
|
| 36 |
/** |
| 37 |
* A namespace solely for the purpose of defining the Domination enum as well |
| 38 |
* as associated operators. |
| 39 |
*/ |
| 40 |
namespace FiniteElementDomination |
| 41 |
{ |
| 42 |
/** |
| 43 |
* An enum that describes the outcome of comparing two elements for mutual |
| 44 |
* domination. If one element dominates another, then the restriction of the |
| 45 |
* space described by the dominated element to a face of the cell is |
| 46 |
* strictly larger than that of the dominating element. For example, in 2-d |
| 47 |
* Q(2) elements dominate Q(4) elements, because the traces of Q(4) elements |
| 48 |
* are quartic polynomials which is a space strictly larger than the |
| 49 |
* quadratic polynomials (the restriction of the Q(2) element). Similar |
| 50 |
* reasonings apply for vertices and cells as well. In general, Q(k) dominates |
| 51 |
* Q(k') if $k\le k'$. |
| 52 |
* |
| 53 |
* This enum is used in the FiniteElement::compare_for_domination() function |
| 54 |
* that is used in the context of hp-finite element methods when determining |
| 55 |
* what to do at faces where two different finite elements meet (see the |
| 56 |
* @ref hp_paper "hp-paper" |
| 57 |
* for a more detailed description of the following). In that case, the |
| 58 |
* degrees of freedom of one side need to be constrained to those on the |
| 59 |
* other side. The determination which side is which is based on the outcome |
| 60 |
* of a comparison for mutual domination: the dominated side is constrained |
| 61 |
* to the dominating one. |
| 62 |
* |
| 63 |
* Note that there are situations where neither side dominates. The |
| 64 |
* @ref hp_paper "hp-paper" |
| 65 |
* lists two case, with the simpler one being that a $Q_2\times Q_1$ |
| 66 |
* vector-valued element (i.e. a <code>FESystem(FE_Q(2),1,FE_Q(1),1)</code>) |
| 67 |
* meets a $Q_1\times Q_2$ element: here, for each of the two |
| 68 |
* vector-components, we can define a domination relationship, but it is |
| 69 |
* different for the two components. |
| 70 |
* |
| 71 |
* It is clear that the concept of domination doesn't matter for |
| 72 |
* discontinuous elements. However, discontinuous elements may be part of |
| 73 |
* vector-valued elements and may therefore be compared against each other |
| 74 |
* for domination. They should return |
| 75 |
* <code>either_element_can_dominate</code> in that case. Likewise, when |
| 76 |
* comparing two identical finite elements, they should return this code; |
| 77 |
* the reason is that we can not decide which element will dominate at the |
| 78 |
* time we look at the first component of, for example, two $Q_2\times Q_1$ |
| 79 |
* and $Q_2\times Q_2$ elements, and have to keep our options open until we |
| 80 |
* get to the second base element. |
| 81 |
* |
| 82 |
* Finally, the code no_requirements exists for cases where elements impose |
| 83 |
* no continuity requirements. The case is primarily meant for FE_Nothing |
| 84 |
* which is an element that has no degrees of freedom in a subdomain. It |
| 85 |
* could also be used by discontinuous elements, for example. |
| 86 |
* |
| 87 |
* More details on domination can be found in the |
| 88 |
* @ref hp_paper "hp-paper". |
| 89 |
*/ |
| 90 |
enum Domination |
| 91 |
{ |
| 92 |
/** |
| 93 |
* The current element dominates. |
| 94 |
*/ |
| 95 |
this_element_dominates, |
| 96 |
/** |
| 97 |
* The other element dominates. |
| 98 |
*/ |
| 99 |
other_element_dominates, |
| 100 |
/** |
| 101 |
* Neither element dominates. |
| 102 |
*/ |
| 103 |
neither_element_dominates, |
| 104 |
/** |
| 105 |
* Either element may dominate. |
| 106 |
*/ |
| 107 |
either_element_can_dominate, |
| 108 |
/** |
| 109 |
* There are no requirements. |
| 110 |
*/ |
| 111 |
no_requirements |
| 112 |
}; |
| 113 |
|
| 114 |
|
| 115 |
/** |
| 116 |
* A generalization of the binary <code>and</code> operator to a comparison |
| 117 |
* relationship. The way this works is pretty much as when you would want to |
| 118 |
* define a comparison relationship for vectors: either all elements of the |
| 119 |
* first vector are smaller, equal, or larger than those of the second |
| 120 |
* vector, or some are and some are not. |
| 121 |
* |
| 122 |
* This operator is pretty much the same: if both arguments are |
| 123 |
* <code>this_element_dominates</code> or |
| 124 |
* <code>other_element_dominates</code>, then the returned value is that |
| 125 |
* value. On the other hand, if one of the values is |
| 126 |
* <code>either_element_can_dominate</code>, then the returned value is that |
| 127 |
* of the other argument. If either argument is |
| 128 |
* <code>neither_element_dominates</code>, or if the two arguments are |
| 129 |
* <code>this_element_dominates</code> and |
| 130 |
* <code>other_element_dominates</code>, then the returned value is |
| 131 |
* <code>neither_element_dominates</code>. |
| 132 |
*/ |
| 133 |
inline Domination |
| 134 |
operator&(const Domination d1, const Domination d2); |
| 135 |
} // namespace FiniteElementDomination |
| 136 |
|
| 137 |
namespace internal |
| 138 |
{ |
| 139 |
/** |
| 140 |
* Internal data structure for setting up FiniteElementData. It stores for |
| 141 |
* each object the (inclusive/exclusive) number of degrees of freedoms, as |
| 142 |
* well as the index of its first degree of freedom within a cell and the |
| 143 |
* index of the first d-dimensional object within each face. Here, inclusive |
| 144 |
* means "the number of DoFs located on this object as well as the |
| 145 |
* lower-dimensional objects that bound it", and exclusive is then the |
| 146 |
* number not including the lower-dimensional objects. |
| 147 |
* |
| 148 |
* The information is saved as a vector of vectors. One can query the |
| 149 |
* inclusive number of dofs of the i-th d-dimensional object via: |
| 150 |
* dofs_per_object_inclusive[d][i]. |
| 151 |
* |
| 152 |
* As an example, the data is shown for a quadratic wedge. Which consists of |
| 153 |
* 6 vertices, 9 lines, and 5 faces (two triangles and three quadrilaterals). |
| 154 |
* @code |
| 155 |
* vertices lines faces cell |
| 156 |
* dpo_excl 1 1 1 1 1 1 | 1 1 1 1 1 1 1 1 1 | 0 0 1 1 1 | 0 |
| 157 |
* dpo_incl 1 1 1 1 1 1 | 3 3 3 3 3 3 3 3 3 | 6 6 9 9 9 | 18 |
| 158 |
* obj_index 0 1 2 3 4 5 | 6 7 8 9 10 11 12 13 14 | 15 15 15 16 17 | 18 |
| 159 |
* @endcode |
| 160 |
* |
| 161 |
* The above table has these numbers because of the following considerations: |
| 162 |
* |
| 163 |
* - For each triangular face: |
| 164 |
* @code |
| 165 |
* dpo_excl 1 1 1 | 1 1 1 | 0 |
| 166 |
* obj_index 0 1 2 | 3 4 5 | 6 |
| 167 |
* @endcode |
| 168 |
* |
| 169 |
* - For each quadrilateral face: |
| 170 |
* @code |
| 171 |
* dpo_excl 1 1 1 1 | 1 1 1 1 | 1 |
| 172 |
* obj_index 0 1 2 3 | 4 5 6 7 | 8 |
| 173 |
* @endcode |
| 174 |
* |
| 175 |
* The index of the first d-dimensional object within each face results as: |
| 176 |
* @code |
| 177 |
* vertices lines face |
| 178 |
* first_obj_index_on_face 0 0 0 0 0 | 3 3 4 4 4 | 6 6 8 8 8 |
| 179 |
* @endcode |
| 180 |
* |
| 181 |
*/ |
| 182 |
struct GenericDoFsPerObject |
| 183 |
{ |
| 184 |
/** |
| 185 |
* Exclusive number of degrees of freedom per object. |
| 186 |
*/ |
| 187 |
std::vector<std::vector<unsigned int>> dofs_per_object_exclusive; |
| 188 |
|
| 189 |
/** |
| 190 |
* Inclusive number of degrees of freedom per object. |
| 191 |
*/ |
| 192 |
std::vector<std::vector<unsigned int>> dofs_per_object_inclusive; |
| 193 |
|
| 194 |
/** |
| 195 |
* First index of an object. |
| 196 |
*/ |
| 197 |
std::vector<std::vector<unsigned int>> object_index; |
| 198 |
|
| 199 |
/** |
| 200 |
* First index of an object within a face. |
| 201 |
*/ |
| 202 |
std::vector<std::vector<unsigned int>> first_object_index_on_face; |
| 203 |
|
| 204 |
/** |
| 205 |
* Function that fills the fields based on a provided finite element. |
| 206 |
*/ |
| 207 |
template <int dim> |
| 208 |
static GenericDoFsPerObject |
| 209 |
generate(const FiniteElementData<dim> &fe); |
| 210 |
}; |
| 211 |
} // namespace internal |
| 212 |
|
| 213 |
/** |
| 214 |
* A class that declares a number of scalar constant variables that describe |
| 215 |
* basic properties of a finite element implementation. This includes, for |
| 216 |
* example, the number of degrees of freedom per vertex, line, or cell; the |
| 217 |
* number of vector components; etc. |
| 218 |
* |
| 219 |
* The kind of information stored here is computed during initialization of a |
| 220 |
* finite element object and is passed down to this class via its constructor. |
| 221 |
* The data stored by this class is part of the public interface of the |
| 222 |
* FiniteElement class (which derives from the current class). See there for |
| 223 |
* more information. |
| 224 |
* |
| 225 |
* @ingroup febase |
| 226 |
*/ |
| 227 |
template <int dim> |
| 228 |
class FiniteElementData |
| 229 |
{ |
| 230 |
public: |
| 231 |
/** |
| 232 |
* Enumerator for the different types of continuity a finite element may |
| 233 |
* have. Continuity is measured by the Sobolev space containing the |
| 234 |
* constructed finite element space and is also called this way. |
| 235 |
* |
| 236 |
* Note that certain continuities may imply others. For instance, a function |
| 237 |
* in <i>H<sup>1</sup></i> is in <i>H<sup>curl</sup></i> and |
| 238 |
* <i>H<sup>div</sup></i> as well. |
| 239 |
* |
| 240 |
* If you are interested in continuity in the classical sense, then the |
| 241 |
* following relations hold: |
| 242 |
* |
| 243 |
* <ol> |
| 244 |
* |
| 245 |
* <li> <i>H<sup>1</sup></i> implies that the function is continuous over |
| 246 |
* cell boundaries. |
| 247 |
* |
| 248 |
* <li> <i>H<sup>2</sup></i> implies that the function is continuously |
| 249 |
* differentiable over cell boundaries. |
| 250 |
* |
| 251 |
* <li> <i>L<sup>2</sup></i> indicates that the element is discontinuous. |
| 252 |
* Since discontinuous elements have no topological couplings between grid |
| 253 |
* cells and code may actually depend on this property, <i>L<sup>2</sup></i> |
| 254 |
* conformity is handled in a special way in the sense that it is <b>not</b> |
| 255 |
* implied by any higher conformity. |
| 256 |
* </ol> |
| 257 |
* |
| 258 |
* In order to test if a finite element conforms to a certain space, use |
| 259 |
* FiniteElementData<dim>::conforms(). |
| 260 |
*/ |
| 261 |
enum Conformity |
| 262 |
{ |
| 263 |
/** |
| 264 |
* Indicates incompatible continuities of a system. |
| 265 |
*/ |
| 266 |
unknown = 0x00, |
| 267 |
|
| 268 |
/** |
| 269 |
* Discontinuous elements. See above! |
| 270 |
*/ |
| 271 |
L2 = 0x01, |
| 272 |
|
| 273 |
/** |
| 274 |
* Conformity with the space <i>H<sup>curl</sup></i> (continuous |
| 275 |
* tangential component of a vector field) |
| 276 |
*/ |
| 277 |
Hcurl = 0x02, |
| 278 |
|
| 279 |
/** |
| 280 |
* Conformity with the space <i>H<sup>div</sup></i> (continuous normal |
| 281 |
* component of a vector field) |
| 282 |
*/ |
| 283 |
Hdiv = 0x04, |
| 284 |
|
| 285 |
/** |
| 286 |
* Conformity with the space <i>H<sup>1</sup></i> (continuous) |
| 287 |
*/ |
| 288 |
H1 = Hcurl | Hdiv, |
| 289 |
|
| 290 |
/** |
| 291 |
* Conformity with the space <i>H<sup>2</sup></i> (continuously |
| 292 |
* differentiable) |
| 293 |
*/ |
| 294 |
H2 = 0x0e |
| 295 |
}; |
| 296 |
|
| 297 |
/** |
| 298 |
* The dimension of the finite element, which is the template parameter |
| 299 |
* <tt>dim</tt> |
| 300 |
*/ |
| 301 |
static constexpr unsigned int dimension = dim; |
| 302 |
|
| 303 |
private: |
| 304 |
/** |
| 305 |
* Reference cell type. |
| 306 |
*/ |
| 307 |
const ReferenceCell reference_cell_kind; |
| 308 |
|
| 309 |
/** |
| 310 |
* Number of unique two-dimensional sub-objects. If all |
| 311 |
* two-dimensional sub-objects have the same type, the value is one; |
| 312 |
* else it equals the number of quads. |
| 313 |
*/ |
| 314 |
const unsigned int number_of_unique_2d_subobjects; |
| 315 |
|
| 316 |
/** |
| 317 |
* Number of unique faces. If all faces have the same type, the value is |
| 318 |
* one; else it equals the number of faces. |
| 319 |
*/ |
| 320 |
const unsigned int number_unique_faces; |
| 321 |
|
| 322 |
public: |
| 323 |
/** |
| 324 |
* Number of degrees of freedom on a vertex. |
| 325 |
*/ |
| 326 |
const unsigned int dofs_per_vertex; |
| 327 |
|
| 328 |
/** |
| 329 |
* Number of degrees of freedom in a line; not including the degrees of |
| 330 |
* freedom on the vertices of the line. |
| 331 |
*/ |
| 332 |
const unsigned int dofs_per_line; |
| 333 |
|
| 334 |
private: |
| 335 |
/** |
| 336 |
* Number of degrees of freedom on quads. If all quads have the same |
| 337 |
* number of degrees freedoms the values equal dofs_per_quad. |
| 338 |
*/ |
| 339 |
const std::vector<unsigned int> n_dofs_on_quad; |
| 340 |
|
| 341 |
public: |
| 342 |
/** |
| 343 |
* Number of degrees of freedom in a quadrilateral; not including the |
| 344 |
* degrees of freedom on the lines and vertices of the quadrilateral. |
| 345 |
*/ |
| 346 |
const unsigned int dofs_per_quad; |
| 347 |
|
| 348 |
private: |
| 349 |
/** |
| 350 |
* Maximum number of degrees of freedom on any quad. |
| 351 |
*/ |
| 352 |
const unsigned int dofs_per_quad_max; |
| 353 |
|
| 354 |
public: |
| 355 |
/** |
| 356 |
* Number of degrees of freedom in a hexahedron; not including the degrees |
| 357 |
* of freedom on the quadrilaterals, lines and vertices of the hexahedron. |
| 358 |
*/ |
| 359 |
const unsigned int dofs_per_hex; |
| 360 |
|
| 361 |
/** |
| 362 |
* First index of dof on a line. |
| 363 |
*/ |
| 364 |
const unsigned int first_line_index; |
| 365 |
|
| 366 |
private: |
| 367 |
/** |
| 368 |
* First index of a quad. If all quads have the same number of degrees of |
| 369 |
* freedom, only the first index of the first quad is stored since the |
| 370 |
* indices of the others can be simply recomputed. |
| 371 |
*/ |
| 372 |
const std::vector<unsigned int> first_index_of_quads; |
| 373 |
|
| 374 |
public: |
| 375 |
/** |
| 376 |
* First index of dof on a quad. |
| 377 |
*/ |
| 378 |
const unsigned int first_quad_index; |
| 379 |
|
| 380 |
/** |
| 381 |
* First index of dof on a hexahedron. |
| 382 |
*/ |
| 383 |
const unsigned int first_hex_index; |
| 384 |
|
| 385 |
private: |
| 386 |
/** |
| 387 |
* Index of the first line of all faces. |
| 388 |
*/ |
| 389 |
const std::vector<unsigned int> first_line_index_of_faces; |
| 390 |
|
| 391 |
public: |
| 392 |
/** |
| 393 |
* First index of dof on a line for face data. |
| 394 |
*/ |
| 395 |
const unsigned int first_face_line_index; |
| 396 |
|
| 397 |
private: |
| 398 |
/** |
| 399 |
* Index of the first quad of all faces. |
| 400 |
*/ |
| 401 |
const std::vector<unsigned int> first_quad_index_of_faces; |
| 402 |
|
| 403 |
public: |
| 404 |
/** |
| 405 |
* First index of dof on a quad for face data. |
| 406 |
*/ |
| 407 |
const unsigned int first_face_quad_index; |
| 408 |
|
| 409 |
private: |
| 410 |
/** |
| 411 |
* Number of degrees of freedom on faces. If all faces have the same |
| 412 |
* number of degrees freedoms the values equal dofs_per_quad. |
| 413 |
*/ |
| 414 |
const std::vector<unsigned int> n_dofs_on_face; |
| 415 |
|
| 416 |
public: |
| 417 |
/** |
| 418 |
* Number of degrees of freedom on a face. This is the accumulated number of |
| 419 |
* degrees of freedom on all the objects of dimension up to <tt>dim-1</tt> |
| 420 |
* constituting a face. |
| 421 |
*/ |
| 422 |
const unsigned int dofs_per_face; |
| 423 |
|
| 424 |
private: |
| 425 |
/** |
| 426 |
* Maximum number of degrees of freedom on any face. |
| 427 |
*/ |
| 428 |
const unsigned int dofs_per_face_max; |
| 429 |
|
| 430 |
public: |
| 431 |
/** |
| 432 |
* Total number of degrees of freedom on a cell. This is the accumulated |
| 433 |
* number of degrees of freedom on all the objects of dimension up to |
| 434 |
* <tt>dim</tt> constituting a cell. |
| 435 |
*/ |
| 436 |
const unsigned int dofs_per_cell; |
| 437 |
|
| 438 |
/** |
| 439 |
* Number of vector components of this finite element, and dimension of the |
| 440 |
* image space. For vector-valued finite elements (i.e. when this number is |
| 441 |
* greater than one), the number of vector components is in many cases equal |
| 442 |
* to the number of base elements glued together with the help of the |
| 443 |
* FESystem class. However, for elements like the Nedelec element, the |
| 444 |
* number is greater than one even though we only have one base element. |
| 445 |
*/ |
| 446 |
const unsigned int components; |
| 447 |
|
| 448 |
/** |
| 449 |
* Maximal polynomial degree of a shape function in a single coordinate |
| 450 |
* direction. |
| 451 |
*/ |
| 452 |
const unsigned int degree; |
| 453 |
|
| 454 |
/** |
| 455 |
* Indicate the space this element conforms to. |
| 456 |
*/ |
| 457 |
const Conformity conforming_space; |
| 458 |
|
| 459 |
/** |
| 460 |
* Storage for an object describing the sizes of each block of a compound |
| 461 |
* element. For an element which is not an FESystem, this contains only a |
| 462 |
* single block with length #dofs_per_cell. |
| 463 |
*/ |
| 464 |
const BlockIndices block_indices_data; |
| 465 |
|
| 466 |
/** |
| 467 |
* Constructor, computing all necessary values from the distribution of dofs |
| 468 |
* to geometrical objects. |
| 469 |
* |
| 470 |
* @param[in] dofs_per_object A vector that describes the number of degrees |
| 471 |
* of freedom on geometrical objects for each dimension. This vector must |
| 472 |
* have size dim+1, and entry 0 describes the number of degrees of freedom |
| 473 |
* per vertex, entry 1 the number of degrees of freedom per line, etc. As an |
| 474 |
* example, for the common $Q_1$ Lagrange element in 2d, this vector would |
| 475 |
* have elements <code>(1,0,0)</code>. On the other hand, for a $Q_3$ |
| 476 |
* element in 3d, it would have entries <code>(1,2,4,8)</code>. |
| 477 |
* |
| 478 |
* @param[in] n_components Number of vector components of the element. |
| 479 |
* |
| 480 |
* @param[in] degree The maximal polynomial degree of any of the shape |
| 481 |
* functions of this element in any variable on the reference element. For |
| 482 |
* example, for the $Q_1$ element (in any space dimension), this would be |
| 483 |
* one; this is so despite the fact that the element has a shape function of |
| 484 |
* the form $\hat x\hat y$ (in 2d) and $\hat x\hat y\hat z$ (in 3d), which, |
| 485 |
* although quadratic and cubic polynomials, are still only linear in each |
| 486 |
* reference variable separately. The information provided by this variable |
| 487 |
* is typically used in determining what an appropriate quadrature formula |
| 488 |
* is. |
| 489 |
* |
| 490 |
* @param[in] conformity A variable describing which Sobolev space this |
| 491 |
* element conforms to. For example, the $Q_p$ Lagrange elements |
| 492 |
* (implemented by the FE_Q class) are $H^1$ conforming, whereas the |
| 493 |
* Raviart-Thomas element (implemented by the FE_RaviartThomas class) is |
| 494 |
* $H_\text{div}$ conforming; finally, completely discontinuous elements |
| 495 |
* (implemented by the FE_DGQ class) are only $L_2$ conforming. |
| 496 |
* |
| 497 |
* @param[in] block_indices An argument that describes how the base elements |
| 498 |
* of a finite element are grouped. The default value constructs a single |
| 499 |
* block that consists of all @p dofs_per_cell degrees of freedom. This is |
| 500 |
* appropriate for all "atomic" elements (including non-primitive ones) and |
| 501 |
* these can therefore omit this argument. On the other hand, composed |
| 502 |
* elements such as FESystem will want to pass a different value here. |
| 503 |
*/ |
| 504 |
FiniteElementData(const std::vector<unsigned int> &dofs_per_object, |
| 505 |
const unsigned int n_components, |
| 506 |
const unsigned int degree, |
| 507 |
const Conformity conformity = unknown, |
| 508 |
const BlockIndices &block_indices = BlockIndices()); |
| 509 |
|
| 510 |
/** |
| 511 |
* The same as above but with the difference that also the type of the |
| 512 |
* underlying geometric entity can be specified. |
| 513 |
*/ |
| 514 |
FiniteElementData(const std::vector<unsigned int> &dofs_per_object, |
| 515 |
const ReferenceCell reference_cell, |
| 516 |
const unsigned int n_components, |
| 517 |
const unsigned int degree, |
| 518 |
const Conformity conformity = unknown, |
| 519 |
const BlockIndices &block_indices = BlockIndices()); |
| 520 |
|
| 521 |
/** |
| 522 |
* The same as above but instead of passing a vector containing the degrees |
| 523 |
* of freedoms per object a struct of type GenericDoFsPerObject. This allows |
| 524 |
* that 2d objects might have different number of degrees of freedoms, which |
| 525 |
* is particular useful for cells with triangles and quadrilaterals as faces. |
| 526 |
*/ |
| 527 |
FiniteElementData(const internal::GenericDoFsPerObject &data, |
| 528 |
const ReferenceCell reference_cell, |
| 529 |
const unsigned int n_components, |
| 530 |
const unsigned int degree, |
| 531 |
const Conformity conformity = unknown, |
| 532 |
const BlockIndices &block_indices = BlockIndices()); |
| 533 |
|
| 534 |
/** |
| 535 |
* Return the kind of reference cell this element is defined on: For |
| 536 |
* example, whether the element's reference cell is a square or |
| 537 |
* triangle, or similar choices in higher dimensions. |
| 538 |
*/ |
| 539 |
ReferenceCell |
| 540 |
reference_cell() const; |
| 541 |
|
| 542 |
/** |
| 543 |
* Number of unique 2d subobjects. If all two-dimensional subobjects |
| 544 |
* are of the same kind, the value is one; else it equals the number |
| 545 |
* of two-dimensional subobjects. For example, for hex reference |
| 546 |
* cells with the usual finite elements, each face has the same |
| 547 |
* geometric shape (a square) and each face has the same number and |
| 548 |
* kind of shape functions associated with it; as a consequence, the |
| 549 |
* returned value is one. On the other hand, for a wedge element, |
| 550 |
* the two-dimensional subobjects can be both quadrilaterals and |
| 551 |
* triangles, and so the returned value equals the number of faces |
| 552 |
* of these objects (i.e., five). |
| 553 |
*/ |
| 554 |
unsigned int |
| 555 |
n_unique_2d_subobjects() const; |
| 556 |
|
| 557 |
/** |
| 558 |
* Number of unique faces. If all faces have the same type (i.e., |
| 559 |
* have the same shape and also have the same kind and number of |
| 560 |
* DoFs associated with them), the value is one; else it equals the |
| 561 |
* number of faces. |
| 562 |
*/ |
| 563 |
unsigned int |
| 564 |
n_unique_faces() const; |
| 565 |
|
| 566 |
/** |
| 567 |
* Number of dofs per vertex. |
| 568 |
*/ |
| 569 |
unsigned int |
| 570 |
n_dofs_per_vertex() const; |
| 571 |
|
| 572 |
/** |
| 573 |
* Number of dofs per line. Not including dofs on lower dimensional objects. |
| 574 |
*/ |
| 575 |
unsigned int |
| 576 |
n_dofs_per_line() const; |
| 577 |
|
| 578 |
/** |
| 579 |
* Number of dofs per quad. Not including dofs on lower dimensional objects. |
| 580 |
*/ |
| 581 |
unsigned int |
| 582 |
n_dofs_per_quad(unsigned int face_no = 0) const; |
| 583 |
|
| 584 |
/** |
| 585 |
* Maximum number of dofs per quad. Not including dofs on lower dimensional |
| 586 |
* objects. |
| 587 |
*/ |
| 588 |
unsigned int |
| 589 |
max_dofs_per_quad() const; |
| 590 |
|
| 591 |
/** |
| 592 |
* Number of dofs per hex. Not including dofs on lower dimensional objects. |
| 593 |
*/ |
| 594 |
unsigned int |
| 595 |
n_dofs_per_hex() const; |
| 596 |
|
| 597 |
/** |
| 598 |
* Number of dofs per face, accumulating degrees of freedom of all lower |
| 599 |
* dimensional objects. |
| 600 |
*/ |
| 601 |
unsigned int |
| 602 |
n_dofs_per_face(unsigned int face_no = 0, unsigned int child = 0) const; |
| 603 |
|
| 604 |
/** |
| 605 |
* Maximum number of dofs per face, accumulating degrees of freedom of all |
| 606 |
* lower dimensional objects. |
| 607 |
*/ |
| 608 |
unsigned int |
| 609 |
max_dofs_per_face() const; |
| 610 |
|
| 611 |
/** |
| 612 |
* Number of dofs per cell, accumulating degrees of freedom of all lower |
| 613 |
* dimensional objects. |
| 614 |
*/ |
| 615 |
unsigned int |
| 616 |
n_dofs_per_cell() const; |
| 617 |
|
| 618 |
/** |
| 619 |
* Return the number of degrees per structdim-dimensional object. For |
| 620 |
* structdim==0, the function therefore returns dofs_per_vertex, for |
| 621 |
* structdim==1 dofs_per_line, etc. This function is mostly used to allow |
| 622 |
* some template trickery for functions that should work on all sorts of |
| 623 |
* objects without wanting to use the different names (vertex, line, ...) |
| 624 |
* associated with these objects. |
| 625 |
*/ |
| 626 |
template <int structdim> |
| 627 |
unsigned int |
| 628 |
n_dofs_per_object(const unsigned int i = 0) const; |
| 629 |
|
| 630 |
/** |
| 631 |
* Number of components. See |
| 632 |
* @ref GlossComponent "the glossary" |
| 633 |
* for more information. |
| 634 |
*/ |
| 635 |
unsigned int |
| 636 |
n_components() const; |
| 637 |
|
| 638 |
/** |
| 639 |
* Number of blocks. See |
| 640 |
* @ref GlossBlock "the glossary" |
| 641 |
* for more information. |
| 642 |
*/ |
| 643 |
unsigned int |
| 644 |
n_blocks() const; |
| 645 |
|
| 646 |
/** |
| 647 |
* Detailed information on block sizes. |
| 648 |
*/ |
| 649 |
const BlockIndices & |
| 650 |
block_indices() const; |
| 651 |
|
| 652 |
/** |
| 653 |
* Maximal polynomial degree of a shape function in a single coordinate |
| 654 |
* direction. |
| 655 |
* |
| 656 |
* This function can be used to determine the optimal quadrature rule. |
| 657 |
*/ |
| 658 |
unsigned int |
| 659 |
tensor_degree() const; |
| 660 |
|
| 661 |
/** |
| 662 |
* Test whether a finite element space conforms to a certain Sobolev space. |
| 663 |
* |
| 664 |
* @note This function will return a true value even if the finite element |
| 665 |
* space has higher regularity than asked for. |
| 666 |
*/ |
| 667 |
bool |
| 668 |
conforms(const Conformity) const; |
| 669 |
|
| 670 |
/** |
| 671 |
* Comparison operator. |
| 672 |
*/ |
| 673 |
bool |
| 674 |
operator==(const FiniteElementData &) const; |
| 675 |
|
| 676 |
/** |
| 677 |
* Return first index of dof on a line. |
| 678 |
*/ |
| 679 |
unsigned int |
| 680 |
get_first_line_index() const; |
| 681 |
|
| 682 |
/** |
| 683 |
* Return first index of dof on a quad. |
| 684 |
*/ |
| 685 |
unsigned int |
| 686 |
get_first_quad_index(const unsigned int quad_no = 0) const; |
| 687 |
|
| 688 |
/** |
| 689 |
* Return first index of dof on a hexahedron. |
| 690 |
*/ |
| 691 |
unsigned int |
| 692 |
get_first_hex_index() const; |
| 693 |
|
| 694 |
/** |
| 695 |
* Return first index of dof on a line for face data. |
| 696 |
*/ |
| 697 |
unsigned int |
| 698 |
get_first_face_line_index(const unsigned int face_no = 0) const; |
| 699 |
|
| 700 |
/** |
| 701 |
* Return first index of dof on a quad for face data. |
| 702 |
*/ |
| 703 |
unsigned int |
| 704 |
get_first_face_quad_index(const unsigned int face_no = 0) const; |
| 705 |
}; |
| 706 |
|
| 707 |
namespace internal |
| 708 |
{ |
| 709 |
/** |
| 710 |
* Utility function to convert "dofs per object" information |
| 711 |
* of a @p dim dimensional reference cell @p reference_cell. |
| 712 |
*/ |
| 713 |
internal::GenericDoFsPerObject |
| 714 |
expand(const unsigned int dim, |
| 715 |
const std::vector<unsigned int> &dofs_per_object, |
| 716 |
const ReferenceCell reference_cell); |
| 717 |
} // namespace internal |
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
// --------- inline and template functions --------------- |
| 722 |
|
| 723 |
|
| 724 |
#ifndef DOXYGEN |
| 725 |
|
| 726 |
namespace FiniteElementDomination |
| 727 |
{ |
| 728 |
inline Domination |
| 729 |
operator&(const Domination d1, const Domination d2) |
| 730 |
{ |
| 731 |
// go through the entire list of possibilities. note that if we were into |
| 732 |
// speed, obfuscation and cared enough, we could implement this operator |
| 733 |
// by doing a bitwise & (and) if we gave these values to the enum values: |
| 734 |
// neither_element_dominates=0, this_element_dominates=1, |
| 735 |
// other_element_dominates=2, either_element_can_dominate=3 |
| 736 |
// =this_element_dominates|other_element_dominates |
| 737 |
switch (d1) |
| 738 |
{ |
| 739 |
case this_element_dominates: |
| 740 |
if ((d2 == this_element_dominates) || |
| 741 |
(d2 == either_element_can_dominate) || (d2 == no_requirements)) |
| 742 |
return this_element_dominates; |
| 743 |
else |
| 744 |
return neither_element_dominates; |
| 745 |
|
| 746 |
case other_element_dominates: |
| 747 |
if ((d2 == other_element_dominates) || |
| 748 |
(d2 == either_element_can_dominate) || (d2 == no_requirements)) |
| 749 |
return other_element_dominates; |
| 750 |
else |
| 751 |
return neither_element_dominates; |
| 752 |
|
| 753 |
case neither_element_dominates: |
| 754 |
return neither_element_dominates; |
| 755 |
|
| 756 |
case either_element_can_dominate: |
| 757 |
if (d2 == no_requirements) |
| 758 |
return either_element_can_dominate; |
| 759 |
else |
| 760 |
return d2; |
| 761 |
|
| 762 |
case no_requirements: |
| 763 |
return d2; |
| 764 |
|
| 765 |
default: |
| 766 |
// shouldn't get here |
| 767 |
DEAL_II_ASSERT_UNREACHABLE(); |
| 768 |
} |
| 769 |
|
| 770 |
return neither_element_dominates; |
| 771 |
} |
| 772 |
} // namespace FiniteElementDomination |
| 773 |
|
| 774 |
|
| 775 |
template <int dim> |
| 776 |
inline ReferenceCell |
| 777 |
FiniteElementData<dim>::reference_cell() const |
| 778 |
{ |
| 779 |
return reference_cell_kind; |
| 780 |
} |
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
template <int dim> |
| 785 |
inline unsigned int |
| 786 |
FiniteElementData<dim>::n_unique_2d_subobjects() const |
| 787 |
{ |
| 788 |
return number_of_unique_2d_subobjects; |
| 789 |
} |
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
template <int dim> |
| 794 |
inline unsigned int |
| 795 |
FiniteElementData<dim>::n_unique_faces() const |
| 796 |
{ |
| 797 |
return number_unique_faces; |
| 798 |
} |
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
template <int dim> |
| 803 |
inline unsigned int |
| 804 |
FiniteElementData<dim>::n_dofs_per_vertex() const |
| 805 |
{ |
| 806 |
return dofs_per_vertex; |
| 807 |
} |
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
template <int dim> |
| 812 |
inline unsigned int |
| 813 |
FiniteElementData<dim>::n_dofs_per_line() const |
| 814 |
{ |
| 815 |
return dofs_per_line; |
| 816 |
} |
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
template <int dim> |
| 821 |
inline unsigned int |
| 822 |
FiniteElementData<dim>::n_dofs_per_quad(unsigned int face_no) const |
| 823 |
{ |
| 824 |
return n_dofs_on_quad[n_dofs_on_quad.size() == 1 ? 0 : face_no]; |
| 825 |
} |
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
template <int dim> |
| 830 |
inline unsigned int |
| 831 |
FiniteElementData<dim>::max_dofs_per_quad() const |
| 832 |
{ |
| 833 |
return dofs_per_quad_max; |
| 834 |
} |
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
template <int dim> |
| 839 |
inline unsigned int |
| 840 |
FiniteElementData<dim>::n_dofs_per_hex() const |
| 841 |
{ |
| 842 |
return dofs_per_hex; |
| 843 |
} |
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
template <int dim> |
| 848 |
inline unsigned int |
| 849 |
FiniteElementData<dim>::n_dofs_per_face(unsigned int face_no, |
| 850 |
unsigned int child_no) const |
| 851 |
{ |
| 852 |
(void)child_no; |
| 853 |
|
| 854 |
return n_dofs_on_face[n_dofs_on_face.size() == 1 ? 0 : face_no]; |
| 855 |
} |
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
template <int dim> |
| 860 |
inline unsigned int |
| 861 |
FiniteElementData<dim>::max_dofs_per_face() const |
| 862 |
{ |
| 863 |
return dofs_per_face_max; |
| 864 |
} |
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
template <int dim> |
| 869 |
inline unsigned int |
| 870 |
FiniteElementData<dim>::n_dofs_per_cell() const |
| 871 |
{ |
| 872 |
return dofs_per_cell; |
| 873 |
} |
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
template <int dim> |
| 878 |
template <int structdim> |
| 879 |
inline unsigned int |
| 880 |
FiniteElementData<dim>::n_dofs_per_object(const unsigned int i) const |
| 881 |
{ |
| 882 |
switch (structdim) |
| 883 |
{ |
| 884 |
case 0: |
| 885 |
return n_dofs_per_vertex(); |
| 886 |
case 1: |
| 887 |
return n_dofs_per_line(); |
| 888 |
case 2: |
| 889 |
return n_dofs_per_quad((structdim == 2 && dim == 3) ? i : 0); |
| 890 |
case 3: |
| 891 |
return n_dofs_per_hex(); |
| 892 |
default: |
| 893 |
DEAL_II_ASSERT_UNREACHABLE(); |
| 894 |
} |
| 895 |
return numbers::invalid_unsigned_int; |
| 896 |
} |
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
template <int dim> |
| 901 |
inline unsigned int |
| 902 |
FiniteElementData<dim>::n_components() const |
| 903 |
{ |
| 904 |
return components; |
| 905 |
} |
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
template <int dim> |
| 910 |
inline const BlockIndices & |
| 911 |
FiniteElementData<dim>::block_indices() const |
| 912 |
{ |
| 913 |
return block_indices_data; |
| 914 |
} |
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
template <int dim> |
| 919 |
inline unsigned int |
| 920 |
FiniteElementData<dim>::n_blocks() const |
| 921 |
{ |
| 922 |
return block_indices_data.size(); |
| 923 |
} |
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
template <int dim> |
| 928 |
inline unsigned int |
| 929 |
FiniteElementData<dim>::tensor_degree() const |
| 930 |
{ |
| 931 |
return degree; |
| 932 |
} |
| 933 |
|
| 934 |
|
| 935 |
template <int dim> |
| 936 |
inline bool |
| 937 |
FiniteElementData<dim>::conforms(const Conformity space) const |
| 938 |
{ |
| 939 |
return ((space & conforming_space) == space); |
| 940 |
} |
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
template <int dim> |
| 945 |
unsigned int |
| 946 |
FiniteElementData<dim>::get_first_line_index() const |
| 947 |
{ |
| 948 |
return first_line_index; |
| 949 |
} |
| 950 |
|
| 951 |
template <int dim> |
| 952 |
unsigned int |
| 953 |
FiniteElementData<dim>::get_first_quad_index(const unsigned int quad_no) const |
| 954 |
{ |
| 955 |
if (first_index_of_quads.size() == 1) |
| 956 |
return first_index_of_quads[0] + quad_no * n_dofs_per_quad(0); |
| 957 |
else |
| 958 |
return first_index_of_quads[quad_no]; |
| 959 |
} |
| 960 |
|
| 961 |
template <int dim> |
| 962 |
unsigned int |
| 963 |
FiniteElementData<dim>::get_first_hex_index() const |
| 964 |
{ |
| 965 |
return first_hex_index; |
| 966 |
} |
| 967 |
|
| 968 |
template <int dim> |
| 969 |
unsigned int |
| 970 |
FiniteElementData<dim>::get_first_face_line_index( |
| 971 |
const unsigned int face_no) const |
| 972 |
{ |
| 973 |
return first_line_index_of_faces[first_line_index_of_faces.size() == 1 ? |
| 974 |
0 : |
| 975 |
face_no]; |
| 976 |
} |
| 977 |
|
| 978 |
template <int dim> |
| 979 |
unsigned int |
| 980 |
FiniteElementData<dim>::get_first_face_quad_index( |
| 981 |
const unsigned int face_no) const |
| 982 |
{ |
| 983 |
return first_quad_index_of_faces[first_quad_index_of_faces.size() == 1 ? |
| 984 |
0 : |
| 985 |
face_no]; |
| 986 |
} |
| 987 |
|
| 988 |
template <int dim> |
| 989 |
internal::GenericDoFsPerObject |
| 990 |
internal::GenericDoFsPerObject::generate(const FiniteElementData<dim> &fe) |
| 991 |
{ |
| 992 |
const auto reference_cell = fe.reference_cell(); |
| 993 |
|
| 994 |
internal::GenericDoFsPerObject result; |
| 995 |
|
| 996 |
result.dofs_per_object_exclusive.resize(4); |
| 997 |
result.dofs_per_object_inclusive.resize(4); |
| 998 |
result.object_index.resize(4); |
| 999 |
|
| 1000 |
unsigned int counter = 0; |
| 1001 |
|
| 1002 |
for (const unsigned int v : reference_cell.vertex_indices()) |
| 1003 |
{ |
| 1004 |
const auto c = fe.template n_dofs_per_object<0>(v); |
| 1005 |
|
| 1006 |
result.dofs_per_object_exclusive[0].emplace_back(c); |
| 1007 |
result.dofs_per_object_inclusive[0].emplace_back(c); |
| 1008 |
result.object_index[0].emplace_back(counter); |
| 1009 |
|
| 1010 |
counter += c; |
| 1011 |
} |
| 1012 |
|
| 1013 |
if (dim >= 2) |
| 1014 |
for (const unsigned int l : reference_cell.line_indices()) |
| 1015 |
{ |
| 1016 |
const auto c = fe.template n_dofs_per_object<1>(l); |
| 1017 |
|
| 1018 |
result.dofs_per_object_exclusive[1].emplace_back(c); |
| 1019 |
result.dofs_per_object_inclusive[1].emplace_back( |
| 1020 |
c + 2 * fe.template n_dofs_per_object<0>()); |
| 1021 |
result.object_index[1].emplace_back(counter); |
| 1022 |
|
| 1023 |
counter += c; |
| 1024 |
} |
| 1025 |
|
| 1026 |
if (dim == 3) |
| 1027 |
for (const unsigned int f : reference_cell.face_indices()) |
| 1028 |
{ |
| 1029 |
const auto c = fe.template n_dofs_per_object<2>(f); |
| 1030 |
|
| 1031 |
result.dofs_per_object_exclusive[2].emplace_back(c); |
| 1032 |
result.dofs_per_object_inclusive[2].emplace_back(fe.n_dofs_per_face(f)); |
| 1033 |
result.object_index[2].emplace_back(counter); |
| 1034 |
|
| 1035 |
counter += c; |
| 1036 |
} |
| 1037 |
|
| 1038 |
{ |
| 1039 |
const auto c = fe.template n_dofs_per_object<dim>(); |
| 1040 |
|
| 1041 |
result.dofs_per_object_exclusive[dim].emplace_back(c); |
| 1042 |
result.dofs_per_object_inclusive[dim].emplace_back(fe.n_dofs_per_cell()); |
| 1043 |
result.object_index[dim].emplace_back(counter); |
| 1044 |
|
| 1045 |
counter += c; |
| 1046 |
} |
| 1047 |
|
| 1048 |
for (unsigned int d = dim + 1; d <= 3; ++d) |
| 1049 |
{ |
| 1050 |
result.dofs_per_object_exclusive[d].emplace_back(0); |
| 1051 |
result.dofs_per_object_inclusive[d].emplace_back(0); |
| 1052 |
result.object_index[d].emplace_back(counter); |
| 1053 |
} |
| 1054 |
|
| 1055 |
result.first_object_index_on_face.resize(3); |
| 1056 |
for (const unsigned int face_no : reference_cell.face_indices()) |
| 1057 |
{ |
| 1058 |
result.first_object_index_on_face[0].emplace_back(0); |
| 1059 |
|
| 1060 |
result.first_object_index_on_face[1].emplace_back( |
| 1061 |
fe.get_first_face_line_index(face_no)); |
| 1062 |
|
| 1063 |
result.first_object_index_on_face[2].emplace_back( |
| 1064 |
fe.get_first_face_quad_index(face_no)); |
| 1065 |
} |
| 1066 |
|
| 1067 |
return result; |
| 1068 |
} |
| 1069 |
|
| 1070 |
|
| 1071 |
#endif // DOXYGEN |
| 1072 |
|
| 1073 |
|
| 1074 |
DEAL_II_NAMESPACE_CLOSE |
| 1075 |
|
| 1076 |
#endif |