Debian Codegraph @

include/deal.II/fe/fe_p1nc.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2016 - 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_p1nc_h
16 #define dealii_fe_p1nc_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/base/qprojector.h>
21 #include <deal.II/base/quadrature.h>
22
23 #include <deal.II/fe/fe.h>
24
25
26 DEAL_II_NAMESPACE_OPEN
27
28
29 /**
30 * @addtogroup fe
31 * @{
32 */
33
34 /**
35 * Implementation of the scalar version of the P1 nonconforming finite
36 * element, a piecewise linear element on quadrilaterals in 2d.
37 * This implementation is only for 2d cells in a 2d space (i.e., codimension 0).
38 *
39 * Unlike the usual continuous, $H^1$ conforming finite elements,
40 * the P1 nonconforming element does not enforce continuity across edges.
41 * However, it requires the continuity in an integral sense:
42 * any function in the space should have the same integral values
43 * on two sides of the common edge shared by two adjacent elements.
44 *
45 * Thus, each function in the nonconforming element space can be
46 * discontinuous, and consequently not included in $H^1_0$, just like
47 * the basis functions in Discontinuous Galerkin (DG) finite element
48 * spaces. On the other hand, basis functions in DG spaces are
49 * completely discontinuous across edges without any relation between
50 * the values from both sides. This is a reason why usual weak
51 * formulations for DG schemes contain additional penalty terms for
52 * jump across edges to control discontinuity. However, nonconforming
53 * elements usually do not need additional terms in their weak
54 * formulations because their integrals along edges are the same from
55 * both sides, i.e., there is <i>some level</i> of continuity.
56 *
57 * <h3>Dice Rule</h3>
58 * Since any function in the P1 nonconforming space is piecewise linear on each
59 * element, the function value at the midpoint of each edge is same as the mean
60 * value on the edge. Thus the continuity of the integral value across each edge
61 * is equivalent to the continuity of the midpoint value of each edge in this
62 * case.
63 *
64 * Thus for the P1 nonconforming element, the function values at midpoints on
65 * edges of a cell are important. The first attempt to define (local) degrees of
66 * freedom (DoFs) on a quadrilateral is by using midpoint values of a function.
67 *
68 * However, these 4 functionals are not linearly independent
69 * because a linear function on 2d is uniquely determined by only 3 independent
70 * values. A simple observation reads that any linear function on a
71 * quadrilateral should satisfy the 'dice rule': the sum of two function values
72 * at the midpoints of the edge pair on opposite sides of a cell is equal to the
73 * sum of those at the midpoints of the other edge pair. This is called the
74 * 'dice rule' because the number of points on opposite sides of a dice always
75 * adds up to the same number as well (in the case of dice, to seven).
76 *
77 * In formulas, the dice rule is written as $\phi(m_0) + \phi(m_1) = \phi(m_2) +
78 * \phi(m_3)$ for all $\phi$ in the function space where $m_j$ is the midpoint
79 * of the edge $e_j$. Here, we assume the standard numbering convention for
80 * edges used in deal.II and described in class GeometryInfo.
81 *
82 * Conversely if 4 values at midpoints satisfying the dice rule are given,
83 * then there always exists the unique linear function which coincides with 4
84 * midpoints values.
85 *
86 * Due to the dice rule, three values at any three midpoints can determine
87 * the last value at the last midpoint.
88 * It means that the number of independent local functionals on a cell is 3,
89 * and this is also the dimension of the linear polynomial space on a cell in
90 * 2d.
91 *
92 * <h3>Shape functions</h3>
93 * Before introducing the degrees of freedom, we present 4 local shape functions
94 * on a cell. Due to the dice rule, we need a special construction for shape
95 * functions. Although the following 4 shape functions are not linearly
96 * independent within a cell, they are helpful to define the global basis
97 * functions which are linearly independent on the whole domain. Again, we
98 * assume the standard numbering for vertices used in deal.II.
99 *
100 * @verbatim
101 * 2---------|---------3
102 * | |
103 * | |
104 * | |
105 * | |
106 * - -
107 * | |
108 * | |
109 * | |
110 * | |
111 * 0---------|---------1
112 * @endverbatim
113 *
114 * For each vertex $v_j$ of given cell, there are two edges of which $v_j$ is
115 * one of end points. Consider a linear function such that it has value 0.5 at
116 * the midpoints of two adjacent edges, and 0.0 at the two midpoints of the
117 * other edges. Note that the set of these values satisfies the dice rule which
118 * is described above. We denote such a function associated with vertex $v_j$ by
119 * $\phi_j$. Then the set of 4 shape functions is a partition of unity on a
120 * cell: $\sum_{j=0}^{3} \phi_j = 1$. (This is easy to see: at each edge
121 * midpoint, the sum of the four function adds up to one because two functions
122 * have value 0.5 and the other value 0.0. Because the function is globally
123 * linear, the only function that can have value 1 at four points must also be
124 * globally equal to one.)
125 *
126 * The following figures represent $\phi_j$ for $j=0,\cdots,3$ with their
127 * midpoint values:
128 *
129 * <ul>
130 * <li> shape function $\phi_0$:
131 * @verbatim
132 * +--------0.0--------+
133 * | |
134 * | |
135 * | |
136 * | |
137 * 0.5 0.0
138 * | |
139 * | |
140 * | |
141 * | |
142 * +--------0.5--------+
143 * @endverbatim
144 *
145 * <li> shape function $\phi_1$:
146 * @verbatim
147 * +--------0.0--------+
148 * | |
149 * | |
150 * | |
151 * | |
152 * 0.0 0.5
153 * | |
154 * | |
155 * | |
156 * | |
157 * +--------0.5--------+
158 * @endverbatim
159 *
160 * <li> shape function $\phi_2$:
161 * @verbatim
162 * +--------0.5--------+
163 * | |
164 * | |
165 * | |
166 * | |
167 * 0.5 0.0
168 * | |
169 * | |
170 * | |
171 * | |
172 * +--------0.0--------+
173 * @endverbatim
174 *
175 * <li> shape function $\phi_3$:
176 * @verbatim
177 * +--------0.5--------+
178 * | |
179 * | |
180 * | |
181 * | |
182 * 0.0 0.5
183 * | |
184 * | |
185 * | |
186 * | |
187 * +--------0.0--------+
188 * @endverbatim
189 *
190 * </ul>
191 *
192 * The local DoFs are defined by the coefficients of the shape functions
193 * associated with vertices, respectively. Although these 4 local DoFs are not
194 * linearly independent within a single cell, this definition is a good start
195 * point for the definition of the global DoFs.
196 *
197 * We want to emphasize that the shape functions are constructed on each cell,
198 * not on the reference cell only. Usual finite elements are defined based on a
199 * 'parametric' concept. It means that a function space for a finite element is
200 * defined on one reference cell, and it is transformed into each cell via a
201 * mapping from the reference cell. However the P1 nonconforming element does
202 * not follow such concept. It defines a function space with linear shape
203 * functions on each cell without any help of a function space on the reference
204 * cell. In other words, the element is defined in real space, not via a mapping
205 * from a reference cell. In this, it is similar to the FE_DGPNonparametric
206 * element.
207 *
208 * Thus this implementation does not have to compute shape values on the
209 * reference cell. Rather, the shape values are computed by construction of the
210 * shape functions on each cell independently.
211 *
212 * <h3>Degrees of freedom</h3>
213 * We next have to consider the <i>global</i> basis functions for the element
214 * because the system of equations which we ultimately have to solve is for a
215 * global system, not local. The global basis functions associated with a node
216 * are defined by a cell-wise composition of local shape functions associated
217 * with the node on each element.
218 *
219 * There is a theoretical result about the linear independence of the global
220 * basis functions depending on the type of the boundary condition we consider.
221 *
222 * When homogeneous Dirichlet boundary conditions are given,
223 * the global basis functions associated with interior nodes are linearly
224 * independent. Then, the number of DoFs is equal to the number of interior
225 * nodes, and consequently the same as the number of DoFs for the standard
226 * bilinear $Q_1$ finite element.
227 *
228 * When Neumann boundary conditions are given,
229 * the global basis functions associated with all nodes (including boundary
230 * nodes) are actually not linearly independent. There exists one redundancy.
231 * Thus in this case, the number of DoFs is equal to the number of all nodes
232 * minus 1. This is, again as for the regular $Q_1$ element.
233 *
234 * <h3>Unit support points</h3>
235 * For a smooth function, we construct a piecewise linear function which belongs
236 * to the element space by using its nodal values as DoF values.
237 *
238 * Note that for the P1 nonconforming element, two nodal values of a smooth
239 * function and its interpolant do not coincide in general, in contrast to
240 * ordinary Lagrange finite elements. Of course, it is meaningless to refer
241 * 'nodal value' because the element space has nonconformity. But it is also
242 * true even though the single global basis function associated with a node is
243 * considered the unique 'nodal value' at the node. For instance, consider the
244 * basis function associated with a node. Consider two lines representing the
245 * level sets for value 0.5 and 0, respectively, by connecting two midpoints.
246 * Then we cut the quad into two sub-triangles by the diagonal which is placed
247 * along those two lines. It gives another level set for value 0.25 which
248 * coincides with the cutting diagonal. Therefore these three level sets are all
249 * parallel in the quad and it gives the value 0.75 at the base node, not
250 * value 1. This is true whether the quadrilateral is a rectangle,
251 * parallelogram, or any other shape.
252 *
253 * <h3>Reference</h3>
254 * The original paper for the P1 nonconforming element by Park and Sheen
255 * is accessible at https://doi.org/10.1137/S0036142902404923 ,
256 * see @cite park2003p .
257 */
258 class FE_P1NC : public FiniteElement<2, 2>
259 {
260 public:
261 /**
262 * Constructor for the P1 nonconforming element.
263 * It is only for 2d and codimension = 0.
264 */
265 FE_P1NC();
266
267 virtual std::string
268 get_name() const override;
269
270 virtual UpdateFlags
271 requires_update_flags(const UpdateFlags flags) const override;
272
273 virtual std::unique_ptr<FiniteElement<2, 2>>
274 clone() const override;
275
276 /**
277 * Destructor.
278 */
279 virtual ~FE_P1NC() override = default;
280
281
282
283 private:
284 /**
285 * Return the vector consists of the numbers of degrees of freedom per
286 * objects.
287 */
288 static std::vector<unsigned int>
289 get_dpo_vector();
290
291 /**
292 * Return the coefficients of 4 local linear shape functions $\phi_j(x,y) = a
293 * x + b y + c$ on given cell. For each local shape function, the array
294 * consists of three coefficients is in order of a,b and c.
295 */
296 static ndarray<double, 4, 3>
297 get_linear_shape_coefficients(const Triangulation<2, 2>::cell_iterator &cell);
298
299 /**
300 * Do the work which is needed before cellwise data computation.
301 * Since the shape functions are constructed independently on each cell,
302 * the data on the reference cell is not necessary.
303 * It returns an empty variable of type @p InternalDataBase and stores
304 * @p update_flags, and computes trivially zero Hessian for each cell if it is
305 * needed.
306 */
307 virtual std::unique_ptr<FiniteElement<2, 2>::InternalDataBase>
308 get_data(
309 const UpdateFlags update_flags,
310 const Mapping<2, 2> &,
311 const Quadrature<2> &quadrature,
312 dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 2>
313 &output_data) const override;
314
315 using FiniteElement<2, 2>::get_face_data;
316
317 virtual std::unique_ptr<FiniteElement<2, 2>::InternalDataBase>
318 get_face_data(
319 const UpdateFlags update_flags,
320 const Mapping<2, 2> &,
321 const hp::QCollection<1> &quadrature,
322 dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 2>
323 &output_data) const override;
324
325 virtual std::unique_ptr<FiniteElement<2, 2>::InternalDataBase>
326 get_subface_data(
327 const UpdateFlags update_flags,
328 const Mapping<2, 2> &,
329 const Quadrature<1> &quadrature,
330 dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 2>
331 &output_data) const override;
332
333 /**
334 * Compute the data on the current cell.
335 */
336 virtual void
337 fill_fe_values(
338 const Triangulation<2, 2>::cell_iterator &cell,
339 const CellSimilarity::Similarity cell_similarity,
340 const Quadrature<2> &quadrature,
341 const Mapping<2, 2> &mapping,
342 const Mapping<2, 2>::InternalDataBase &mapping_internal,
343 const internal::FEValuesImplementation::MappingRelatedData<2, 2>
344 &mapping_data,
345 const FiniteElement<2, 2>::InternalDataBase &fe_internal,
346 internal::FEValuesImplementation::FiniteElementRelatedData<2, 2>
347 &output_data) const override;
348
349 using FiniteElement<2, 2>::fill_fe_face_values;
350
351 /**
352 * Compute the data on the face of the current cell.
353 */
354 virtual void
355 fill_fe_face_values(
356 const Triangulation<2, 2>::cell_iterator &cell,
357 const unsigned int face_no,
358 const hp::QCollection<1> &quadrature,
359 const Mapping<2, 2> &mapping,
360 const Mapping<2, 2>::InternalDataBase &mapping_internal,
361 const internal::FEValuesImplementation::MappingRelatedData<2, 2>
362 &mapping_data,
363 const InternalDataBase &fe_internal,
364 dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 2>
365 &output_data) const override;
366
367 /**
368 * Compute the data on the subface of the current cell.
369 */
370 virtual void
371 fill_fe_subface_values(
372 const Triangulation<2, 2>::cell_iterator &cell,
373 const unsigned int face_no,
374 const unsigned int sub_no,
375 const Quadrature<1> &quadrature,
376 const Mapping<2, 2> &mapping,
377 const Mapping<2, 2>::InternalDataBase &mapping_internal,
378 const internal::FEValuesImplementation::MappingRelatedData<2, 2>
379 &mapping_data,
380 const InternalDataBase &fe_internal,
381 dealii::internal::FEValuesImplementation::FiniteElementRelatedData<2, 2>
382 &output_data) const override;
383
384 /**
385 * Create the constraints matrix for hanging edges.
386 */
387 void
388 initialize_constraints();
389 };
390
391
392
393 /** @} */
394
395
396 DEAL_II_NAMESPACE_CLOSE
397
398 #endif