Debian Codegraph @

include/deal.II/fe/fe_dgp_monomial.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2004 - 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_dgp_monomial_h
16 #define dealii_fe_dgp_monomial_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/base/polynomials_p.h>
21
22 #include <deal.II/fe/fe_poly.h>
23
24 DEAL_II_NAMESPACE_OPEN
25
26 /**
27 * @addtogroup fe
28 * @{
29 */
30
31 /**
32 * Discontinuous finite elements based on monomials.
33 *
34 * This finite element implements complete polynomial spaces, that is,
35 * dim-dimensional polynomials of degree p. For example, in 2d the element
36 * FE_DGP(1) would represent the span of the functions $\{1,\hat x,\hat y\}$,
37 * which is in contrast to the element FE_DGQ(1) that is formed by the span of
38 * $\{1,\hat x,\hat y,\hat x\hat y\}$. Since the DGP space has only three
39 * unknowns for each quadrilateral, it is immediately clear that this element
40 * can not be continuous.
41 *
42 * The basis functions for this element are chosen to be the monomials listed
43 * above. Note that this is the main difference to the FE_DGP class that uses
44 * a set of polynomials of complete degree <code>p</code> that form a Legendre
45 * basis on the unit square. Thus, there, the @ref GlossMassMatrix "mass matrix" is diagonal, if the
46 * grid cells are parallelograms. The basis here does not have this property;
47 * however, it is simpler to compute. On the other hand, this element has the
48 * additional disadvantage that the local cell matrices usually have a worse
49 * condition number than the ones originating from the FE_DGP element.
50 *
51 * This class is not implemented for the codimension one case (<tt>spacedim !=
52 * dim</tt>).
53 *
54 * <h3>Transformation properties</h3>
55 *
56 * It is worth noting that under a (bi-, tri-)linear mapping, the space
57 * described by this element does not contain $P(k)$, even if we use a basis
58 * of polynomials of degree $k$. Consequently, for example, on meshes with
59 * non-affine cells, a linear function can not be exactly represented by
60 * elements of type FE_DGP(1) or FE_DGPMonomial(1).
61 *
62 * This can be understood by the following 2-d example: consider the cell with
63 * vertices at $(0,0),(1,0),(0,1),(s,s)$:
64 * @image html dgp_doesnt_contain_p.png
65 *
66 * For this cell, a bilinear transformation $F$ produces the relations $x=\hat
67 * x+\hat x\hat y$ and $y=\hat y+\hat x\hat y$ that correlate reference
68 * coordinates $\hat x,\hat y$ and coordinates in real space $x,y$. Under this
69 * mapping, the constant function is clearly mapped onto itself, but the two
70 * other shape functions of the $P_1$ space, namely $\phi_1(\hat x,\hat
71 * y)=\hat x$ and $\phi_2(\hat x,\hat y)=\hat y$ are mapped onto
72 * $\phi_1(x,y)=\frac{x-t}{t(s-1)},\phi_2(x,y)=t$ where
73 * $t=\frac{y}{s-x+sx+y-sy}$.
74 *
75 * For the simple case that $s=1$, i.e. if the real cell is the unit square,
76 * the expressions can be simplified to $t=y$ and
77 * $\phi_1(x,y)=x,\phi_2(x,y)=y$. However, for all other cases, the functions
78 * $\phi_1(x,y),\phi_2(x,y)$ are not linear any more, and neither is any
79 * linear combination of them. Consequently, the linear functions are not
80 * within the range of the mapped $P_1$ polynomials.
81 *
82 *
83 * <h3>Visualization of shape functions</h3> In 2d, the shape functions of
84 * this element look as follows.
85 *
86 * <h4>$P_0$ element</h4>
87 *
88 * <table> <tr> <td align="center">
89 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P1/P1_DGPMonomial_shape0000.png
90 * </td>
91 *
92 * <td align="center"> </td> </tr> <tr> <td align="center"> $P_0$ element,
93 * shape function 0 </td>
94 *
95 * <td align="center"></tr> </table>
96 *
97 * <h4>$P_1$ element</h4>
98 *
99 * <table> <tr> <td align="center">
100 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P1/P1_DGPMonomial_shape0000.png
101 * </td>
102 *
103 * <td align="center">
104 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P1/P1_DGPMonomial_shape0001.png
105 * </td> </tr> <tr> <td align="center"> $P_1$ element, shape function 0 </td>
106 *
107 * <td align="center"> $P_1$ element, shape function 1 </td> </tr>
108 *
109 * <tr> <td align="center">
110 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P1/P1_DGPMonomial_shape0002.png
111 * </td>
112 *
113 * <td align="center"> </td> </tr> <tr> <td align="center"> $P_1$ element,
114 * shape function 2 </td>
115 *
116 * <td align="center"></td> </tr> </table>
117 *
118 *
119 * <h4>$P_2$ element</h4>
120 *
121 * <table> <tr> <td align="center">
122 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P2/P2_DGPMonomial_shape0000.png
123 * </td>
124 *
125 * <td align="center">
126 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P2/P2_DGPMonomial_shape0001.png
127 * </td> </tr> <tr> <td align="center"> $P_2$ element, shape function 0 </td>
128 *
129 * <td align="center"> $P_2$ element, shape function 1 </td> </tr>
130 *
131 * <tr> <td align="center">
132 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P2/P2_DGPMonomial_shape0002.png
133 * </td>
134 *
135 * <td align="center">
136 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P2/P2_DGPMonomial_shape0003.png
137 * </td> </tr> <tr> <td align="center"> $P_2$ element, shape function 2 </td>
138 *
139 * <td align="center"> $P_2$ element, shape function 3 </td> </tr>
140 *
141 * <tr> <td align="center">
142 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P2/P2_DGPMonomial_shape0004.png
143 * </td>
144 *
145 * <td align="center">
146 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P2/P2_DGPMonomial_shape0005.png
147 * </td> </tr> <tr> <td align="center"> $P_2$ element, shape function 4 </td>
148 *
149 * <td align="center"> $P_2$ element, shape function 5 </td> </tr> </table>
150 *
151 *
152 * <h4>$P_3$ element</h4>
153 *
154 * <table> <tr> <td align="center">
155 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P3/P3_DGPMonomial_shape0000.png
156 * </td>
157 *
158 * <td align="center">
159 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P3/P3_DGPMonomial_shape0001.png
160 * </td> </tr> <tr> <td align="center"> $P_3$ element, shape function 0 </td>
161 *
162 * <td align="center"> $P_3$ element, shape function 1 </td> </tr>
163 *
164 * <tr> <td align="center">
165 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P3/P3_DGPMonomial_shape0002.png
166 * </td>
167 *
168 * <td align="center">
169 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P3/P3_DGPMonomial_shape0003.png
170 * </td> </tr> <tr> <td align="center"> $P_3$ element, shape function 2 </td>
171 *
172 * <td align="center"> $P_3$ element, shape function 3 </td> </tr>
173 *
174 * <tr> <td align="center">
175 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P3/P3_DGPMonomial_shape0004.png
176 * </td>
177 *
178 * <td align="center">
179 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P3/P3_DGPMonomial_shape0005.png
180 * </td> </tr> <tr> <td align="center"> $P_3$ element, shape function 4 </td>
181 *
182 * <td align="center"> $P_3$ element, shape function 5 </td> </tr>
183 *
184 * <tr> <td align="center">
185 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P3/P3_DGPMonomial_shape0006.png
186 * </td>
187 *
188 * <td align="center">
189 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P3/P3_DGPMonomial_shape0007.png
190 * </td> </tr> <tr> <td align="center"> $P_3$ element, shape function 6 </td>
191 *
192 * <td align="center"> $P_3$ element, shape function 7 </td> </tr>
193 *
194 * <tr> <td align="center">
195 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P3/P3_DGPMonomial_shape0008.png
196 * </td>
197 *
198 * <td align="center">
199 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P3/P3_DGPMonomial_shape0009.png
200 * </td> </tr> <tr> <td align="center"> $P_3$ element, shape function 8 </td>
201 *
202 * <td align="center"> $P_3$ element, shape function 9 </td> </tr> </table>
203 *
204 *
205 * <h4>$P_4$ element</h4> <table> <tr> <td align="center">
206 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0000.png
207 * </td>
208 *
209 * <td align="center">
210 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0001.png
211 * </td> </tr> <tr> <td align="center"> $P_4$ element, shape function 0 </td>
212 *
213 * <td align="center"> $P_4$ element, shape function 1 </td> </tr>
214 *
215 * <tr> <td align="center">
216 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0002.png
217 * </td>
218 *
219 * <td align="center">
220 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0003.png
221 * </td> </tr> <tr> <td align="center"> $P_4$ element, shape function 2 </td>
222 *
223 * <td align="center"> $P_4$ element, shape function 3 </td> </tr>
224 *
225 * <tr> <td align="center">
226 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0004.png
227 * </td>
228 *
229 * <td align="center">
230 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0005.png
231 * </td> </tr> <tr> <td align="center"> $P_4$ element, shape function 4 </td>
232 *
233 * <td align="center"> $P_4$ element, shape function 5 </td> </tr>
234 *
235 * <tr> <td align="center">
236 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0006.png
237 * </td>
238 *
239 * <td align="center">
240 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0007.png
241 * </td> </tr> <tr> <td align="center"> $P_4$ element, shape function 6 </td>
242 *
243 * <td align="center"> $P_4$ element, shape function 7 </td> </tr>
244 *
245 * <tr> <td align="center">
246 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0008.png
247 * </td>
248 *
249 * <td align="center">
250 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0009.png
251 * </td> </tr> <tr> <td align="center"> $P_4$ element, shape function 8 </td>
252 *
253 * <td align="center"> $P_4$ element, shape function 9 </td> </tr>
254 *
255 * <tr> <td align="center">
256 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0010.png
257 * </td>
258 *
259 * <td align="center">
260 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0011.png
261 * </td> </tr> <tr> <td align="center"> $P_4$ element, shape function 10 </td>
262 *
263 * <td align="center"> $P_4$ element, shape function 11 </td> </tr>
264 *
265 * <tr> <td align="center">
266 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0012.png
267 * </td>
268 *
269 * <td align="center">
270 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0013.png
271 * </td> </tr> <tr> <td align="center"> $P_4$ element, shape function 12 </td>
272 *
273 * <td align="center"> $P_4$ element, shape function 13 </td> </tr>
274 *
275 * <tr> <td align="center">
276 * @image html http://www.dealii.org/images/shape-functions/DGPMonomial/P4/P4_DGPMonomial_shape0014.png
277 * </td>
278 *
279 * <td align="center"> </td> </tr> <tr> <td align="center"> $P_4$ element,
280 * shape function 14 </td>
281 *
282 * <td align="center"></td> </tr> </table>
283 */
284 template <int dim>
285 class FE_DGPMonomial : public FE_Poly<dim>
286 {
287 public:
288 /**
289 * Constructor for the polynomial space of degree <tt>p</tt>.
290 */
291 FE_DGPMonomial(const unsigned int p);
292
293 /**
294 * Return a string that uniquely identifies a finite element. This class
295 * returns <tt>FE_DGPMonomial<dim>(degree)</tt>, with <tt>dim</tt> and
296 * <tt>p</tt> replaced by appropriate values.
297 */
298 virtual std::string
299 get_name() const override;
300
301 /**
302 * @name Functions to support hp
303 * @{
304 */
305
306 /**
307 * If, on a vertex, several finite elements are active, the hp-code first
308 * assigns the degrees of freedom of each of these FEs different global
309 * indices. It then calls this function to find out which of them should get
310 * identical values, and consequently can receive the same global DoF index.
311 * This function therefore returns a list of identities between DoFs of the
312 * present finite element object with the DoFs of @p fe_other, which is a
313 * reference to a finite element object representing one of the other finite
314 * elements active on this particular vertex. The function computes which of
315 * the degrees of freedom of the two finite element objects are equivalent,
316 * both numbered between zero and the corresponding value of
317 * n_dofs_per_vertex() of the two finite elements. The first index of each
318 * pair denotes one of the vertex dofs of the present element, whereas the
319 * second is the corresponding index of the other finite element.
320 *
321 * This being a discontinuous element, the set of such constraints is of
322 * course empty.
323 */
324 virtual std::vector<std::pair<unsigned int, unsigned int>>
325 hp_vertex_dof_identities(const FiniteElement<dim> &fe_other) const override;
326
327 /**
328 * Same as hp_vertex_dof_indices(), except that the function treats degrees
329 * of freedom on lines.
330 *
331 * This being a discontinuous element, the set of such constraints is of
332 * course empty.
333 */
334 virtual std::vector<std::pair<unsigned int, unsigned int>>
335 hp_line_dof_identities(const FiniteElement<dim> &fe_other) const override;
336
337 /**
338 * Same as hp_vertex_dof_indices(), except that the function treats degrees
339 * of freedom on quads.
340 *
341 * This being a discontinuous element, the set of such constraints is of
342 * course empty.
343 */
344 virtual std::vector<std::pair<unsigned int, unsigned int>>
345 hp_quad_dof_identities(const FiniteElement<dim> &fe_other,
346 const unsigned int face_no = 0) const override;
347
348 /**
349 * Return whether this element implements its hanging node constraints in
350 * the new way, which has to be used to make elements "hp-compatible".
351 *
352 * For the FE_DGPMonomial class the result is always true (independent of
353 * the degree of the element), as it has no hanging nodes (being a
354 * discontinuous element).
355 */
356 virtual bool
357 hp_constraints_are_implemented() const override;
358
359 /**
360 * @copydoc FiniteElement::compare_for_domination()
361 */
362 virtual FiniteElementDomination::Domination
363 compare_for_domination(const FiniteElement<dim> &fe_other,
364 const unsigned int codim = 0) const override final;
365
366 /**
367 * @}
368 */
369
370 /**
371 * Return the matrix interpolating from the given finite element to the
372 * present one. The size of the matrix is then @p dofs_per_cell times
373 * <tt>source.n_dofs_per_cell()</tt>.
374 *
375 * These matrices are only available if the source element is also a @p FE_Q
376 * element. Otherwise, an exception of type
377 * FiniteElement<dim>::ExcInterpolationNotImplemented is thrown.
378 */
379 virtual void
380 get_interpolation_matrix(const FiniteElement<dim> &source,
381 FullMatrix<double> &matrix) const override;
382
383 /**
384 * Return the matrix interpolating from a face of one element to the face
385 * of the neighboring element. The size of the matrix is then @p
386 * dofs_per_face times <tt>source.dofs_per_face</tt>.
387 *
388 * Derived elements will have to implement this function. They may only
389 * provide interpolation matrices for certain source finite elements, for
390 * example those from the same family. If they don't implement interpolation
391 * from a given element, then they must throw an exception of type
392 * FiniteElement<dim>::ExcInterpolationNotImplemented.
393 */
394 virtual void
395 get_face_interpolation_matrix(const FiniteElement<dim> &source,
396 FullMatrix<double> &matrix,
397 const unsigned int face_no = 0) const override;
398
399 /**
400 * Return the matrix interpolating from a face of one element to the face
401 * of the neighboring element. The size of the matrix is then @p
402 * dofs_per_face times <tt>source.dofs_per_face</tt>.
403 *
404 * Derived elements will have to implement this function. They may only
405 * provide interpolation matrices for certain source finite elements, for
406 * example those from the same family. If they don't implement interpolation
407 * from a given element, then they must throw an exception of type
408 * FiniteElement<dim>::ExcInterpolationNotImplemented.
409 */
410 virtual void
411 get_subface_interpolation_matrix(
412 const FiniteElement<dim> &source,
413 const unsigned int subface,
414 FullMatrix<double> &matrix,
415 const unsigned int face_no = 0) const override;
416
417 /**
418 * This function returns @p true, if the shape function @p shape_index has
419 * non-zero function values somewhere on the face @p face_index.
420 */
421 virtual bool
422 has_support_on_face(const unsigned int shape_index,
423 const unsigned int face_index) const override;
424
425 /**
426 * Determine an estimate for the memory consumption (in bytes) of this
427 * object.
428 *
429 * This function is made virtual, since finite element objects are usually
430 * accessed through pointers to their base class, rather than the class
431 * itself.
432 */
433 virtual std::size_t
434 memory_consumption() const override;
435
436 virtual std::unique_ptr<FiniteElement<dim, dim>>
437 clone() const override;
438
439 private:
440 /**
441 * Only for internal use. Its full name is @p get_dofs_per_object_vector
442 * function and it creates the @p dofs_per_object vector that is needed
443 * within the constructor to be passed to the constructor of @p
444 * FiniteElementData.
445 */
446 static std::vector<unsigned int>
447 get_dpo_vector(const unsigned int degree);
448
449 /**
450 * Initialize the restriction matrices. Called from the constructor.
451 */
452 void
453 initialize_restriction();
454 };
455
456 /** @} */
457
458 DEAL_II_NAMESPACE_CLOSE
459
460 #endif