Debian Codegraph @

include/deal.II/fe/mapping_q1.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2001 - 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_mapping_q1_h
16 #define dealii_mapping_q1_h
17
18
19 #include <deal.II/base/config.h>
20
21 #include <deal.II/fe/mapping_q.h>
22
23 #include <cmath>
24
25 DEAL_II_NAMESPACE_OPEN
26
27 /**
28 * @addtogroup mapping
29 * @{
30 */
31
32 /**
33 * Implementation of a $d$-linear mapping from the reference cell to a general
34 * quadrilateral/hexahedron.
35 *
36 * The mapping implemented by this class maps the reference (unit) cell to a
37 * general grid cell with straight lines in $d$ dimensions. (Note, however,
38 * that in 3d the <i>faces</i> of a general, trilinearly mapped cell may be
39 * curved, even if the edges are not). This is the standard mapping used for
40 * polyhedral domains. It is also the mapping used throughout deal.II for many
41 * functions that come in two variants, one that allows to pass a mapping
42 * argument explicitly and one that simply falls back to the MappingQ1 class
43 * declared here. (Or, in fact, to an object of kind MappingQ(1), which
44 * implements exactly the functionality of this class.)
45 *
46 * The shape functions for this mapping are the same as for the finite element
47 * FE_Q of polynomial degree 1. Therefore, coupling these two yields an
48 * isoparametric element.
49 *
50 * @note This class is, in all reality, nothing more than a different name for
51 * calling MappingQ with a polynomial degree of one as argument.
52 */
53 template <int dim, int spacedim = dim>
54 class MappingQ1 : public MappingQ<dim, spacedim>
55 {
56 public:
57 /**
58 * Default constructor.
59 */
60 MappingQ1();
61
62 // for documentation, see the Mapping base class
63 virtual std::unique_ptr<Mapping<dim, spacedim>>
64 clone() const override;
65 };
66
67
68
69 /**
70 * Many places in the library by default use (bi-,tri-)linear mappings unless
71 * users explicitly provide a different mapping to use. In these cases, the
72 * called function has to create a $Q_1$ mapping object, i.e., an object of
73 * kind MappingQ(1). This is costly. It would also be costly to create
74 * such objects as static objects in the affected functions, because static
75 * objects are never destroyed throughout the lifetime of a program, even
76 * though they only have to be created once the first time code runs through a
77 * particular function.
78 *
79 * In order to avoid creation of (static or dynamic) $Q_1$ mapping objects in
80 * these contexts throughout the library, this class defines a static $Q_1$
81 * mapping object. This object can then be used in all of those places where
82 * such an object is needed.
83 *
84 * @note The use of this object should be avoided since it is only applicable
85 * in cases where a mesh consists exclusively of quadrilaterals or hexahedra.
86 * Use
87 * `ReferenceCells::get_hypercube<dim>().get_default_linear_mapping()`
88 * instead.
89 */
90 template <int dim, int spacedim = dim>
91 struct StaticMappingQ1
92 {
93 /**
94 * The static $Q_1$ mapping object discussed in the documentation of this
95 * class.
96 */
97 static MappingQ<dim, spacedim> mapping;
98 };
99
100
101 /** @} */
102
103 template <int dim, int spacedim>
104 MappingQ<dim, spacedim> StaticMappingQ1<dim, spacedim>::mapping =
105 MappingQ1<dim, spacedim>{};
106
107 DEAL_II_NAMESPACE_CLOSE
108
109 #endif