version GIT relicensing-7278-g091132d5eb 2026-12-02 03:10:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
fe_raviart_thomas_nodal.cc
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2005 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
18
20
21#include <deal.II/fe/fe.h>
24#include <deal.II/fe/fe_tools.h>
25#include <deal.II/fe/mapping.h>
26
27#include <memory>
28#include <sstream>
29
30
32
33
34// ---------------- polynomial class for FE_RaviartThomasNodal ---------------
35
36namespace
37{
38 // Return a vector of "dofs per object" where the components of the returned
39 // vector refer to:
40 // 0 = vertex
41 // 1 = edge
42 // 2 = face (which is a cell in 2d)
43 // 3 = cell
44 std::vector<unsigned int>
45 get_rt_dpo_vector(const unsigned int dim, const unsigned int degree)
46 {
47 std::vector<unsigned int> dpo(dim + 1);
48 dpo[0] = 0;
49 dpo[1] = 0;
50 unsigned int dofs_per_face = 1;
51 for (unsigned int d = 1; d < dim; ++d)
52 dofs_per_face *= (degree + 1);
53
54 dpo[dim - 1] = dofs_per_face;
55 dpo[dim] = dim * degree * dofs_per_face;
56
57 return dpo;
58 }
59} // namespace
60
61
62
63// --------------------- actual implementation of element --------------------
64
65template <int dim, int spacedim>
67 const unsigned int degree)
68 : FE_PolyTensor<dim, spacedim>(
69 PolynomialsVectorAnisotropic<dim>(degree + 1,
70 degree,
71 get_lexicographic_numbering(degree)),
72 FiniteElementData<dim>(get_rt_dpo_vector(dim, degree),
73 spacedim,
74 degree + 1,
75 FiniteElementData<dim>::Hdiv),
76 std::vector<bool>(1, false),
77 std::vector<ComponentMask>(
78 PolynomialsVectorAnisotropic<dim>::n_polynomials(degree + 1, degree),
79 ComponentMask(std::vector<bool>(spacedim, true))))
80{
81 Assert(dim >= 2, ExcImpossibleInDim(dim));
82
84
85 const std::vector<unsigned int> numbering =
87
88 // First, initialize the generalized support points and quadrature weights,
89 // since they are required for interpolation.
94 this->n_dofs_per_cell());
95
96 const unsigned int face_no = 0;
97 if (dim > 1)
98 this->generalized_face_support_points[face_no] =
99 degree == 0 ? QGauss<dim - 1>(1).get_points() :
100 QGaussLobatto<dim - 1>(degree + 1).get_points();
101
102 // The hanging-node interface constraints are computed via
103 // FETools::compute_face_embedding_matrices(), which is currently only
104 // implemented for the case dim == spacedim. For embedded surfaces
105 // (dim < spacedim) we skip this step for now; the resulting element can be
106 // used on (possibly globally refined) surface meshes without hanging nodes.
107 if constexpr (dim == spacedim)
108 {
111 for (unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_face;
112 ++i)
113 face_embeddings[i].reinit(this->n_dofs_per_face(face_no),
114 this->n_dofs_per_face(face_no));
115 FETools::compute_face_embedding_matrices<dim, double>(*this,
116 face_embeddings,
117 0,
118 0);
119 this->interface_constraints.reinit(
121 this->n_dofs_per_face(face_no),
122 this->n_dofs_per_face(face_no));
123 unsigned int target_row = 0;
124 for (unsigned int d = 0; d < GeometryInfo<dim>::max_children_per_face;
125 ++d)
126 for (unsigned int i = 0; i < face_embeddings[d].m(); ++i)
127 {
128 for (unsigned int j = 0; j < face_embeddings[d].n(); ++j)
129 this->interface_constraints(target_row, j) =
130 face_embeddings[d](i, j);
131 ++target_row;
132 }
133 }
134
135 // We need to initialize the dof permutation table and the one for the sign
136 // change.
138}
139
140
141
142template <int dim, int spacedim>
143std::string
145{
146 // note that the FETools::get_fe_by_name function depends on the particular
147 // format of the string this function returns, so they have to be kept in
148 // synch
149
150 // note that this->degree is the maximal polynomial degree and is thus one
151 // higher than the argument given to the constructor
152 return "FE_RaviartThomasNodal<" + Utilities::dim_string(dim, spacedim) +
153 ">(" + std::to_string(this->degree - 1) + ")";
154}
155
156
157template <int dim, int spacedim>
158std::unique_ptr<FiniteElement<dim, spacedim>>
160{
161 return std::make_unique<FE_RaviartThomasNodal<dim, spacedim>>(*this);
162}
163
164
165
166template <int dim, int spacedim>
167std::vector<unsigned int>
169 const unsigned int degree)
170{
171 std::vector<unsigned int> numbering =
173
174 // FE_RaviartThomas numbers the degrees of freedom on faces 2 and 3 in 3d
175 // with the x-coordinate running fastest, so transpose them to let the
176 // z-coordinate run fastest
177 if (dim == 3)
178 {
179 const unsigned int n = degree + 1;
180 for (unsigned int &index : numbering)
181 if (index >= 2 * n * n && index < 4 * n * n)
182 {
183 const unsigned int face = index / (n * n);
184 const unsigned int local = index % (n * n);
185 index = face * n * n + (local / n) + (local % n) * n;
186 }
187 }
188 return numbering;
189}
190
191
192//---------------------------------------------------------------------------
193// Auxiliary and internal functions
194//---------------------------------------------------------------------------
195
196
197
198template <int dim, int spacedim>
199void
202{
203 // for 1d and 2d, do nothing
204 if (dim < 3)
205 return;
206
207 const unsigned int n = this->degree;
208 const unsigned int face_no = 0;
209 Assert(n * n == this->n_dofs_per_quad(face_no), ExcInternalError());
210 for (unsigned int local = 0; local < this->n_dofs_per_quad(face_no); ++local)
211 // face support points are in lexicographic ordering with x running
212 // fastest. invert that (y running fastest)
213 {
214 unsigned int i = local % n, j = local / n;
215
216 // face_orientation=false, face_rotation=false, face_flip=false
217 this->adjust_quad_dof_index_for_face_orientation_table[face_no](
218 local, internal::combined_face_orientation(false, false, false)) =
219 j + i * n - local;
220 // face_orientation=false, face_rotation=true, face_flip=false
221 this->adjust_quad_dof_index_for_face_orientation_table[face_no](
222 local, internal::combined_face_orientation(false, true, false)) =
223 i + (n - 1 - j) * n - local;
224 // face_orientation=false, face_rotation=false, face_flip=true
225 this->adjust_quad_dof_index_for_face_orientation_table[face_no](
226 local, internal::combined_face_orientation(false, false, true)) =
227 (n - 1 - j) + (n - 1 - i) * n - local;
228 // face_orientation=false, face_rotation=true, face_flip=true
229 this->adjust_quad_dof_index_for_face_orientation_table[face_no](
230 local, internal::combined_face_orientation(false, true, true)) =
231 (n - 1 - i) + j * n - local;
232 // face_orientation=true, face_rotation=false, face_flip=false
233 this->adjust_quad_dof_index_for_face_orientation_table[face_no](
234 local, internal::combined_face_orientation(true, false, false)) = 0;
235 // face_orientation=true, face_rotation=true, face_flip=false
236 this->adjust_quad_dof_index_for_face_orientation_table[face_no](
237 local, internal::combined_face_orientation(true, true, false)) =
238 j + (n - 1 - i) * n - local;
239 // face_orientation=true, face_rotation=false, face_flip=true
240 this->adjust_quad_dof_index_for_face_orientation_table[face_no](
241 local, internal::combined_face_orientation(true, false, true)) =
242 (n - 1 - i) + (n - 1 - j) * n - local;
243 // face_orientation=true, face_rotation=true, face_flip=true
244 this->adjust_quad_dof_index_for_face_orientation_table[face_no](
245 local, internal::combined_face_orientation(true, true, true)) =
246 (n - 1 - j) + i * n - local;
247
248 // for face_orientation == false, we need to switch the sign
249 for (const bool rotation : {false, true})
250 for (const bool flip : {false, true})
251 this->adjust_quad_dof_sign_for_face_orientation_table[face_no](
252 local, internal::combined_face_orientation(false, rotation, flip)) =
253 1;
254 }
255}
256
257
258
259template <int dim, int spacedim>
260bool
262 const unsigned int shape_index,
263 const unsigned int face_index) const
264{
265 AssertIndexRange(shape_index, this->n_dofs_per_cell());
267
268 // The first degrees of freedom are on the faces and each face has degree
269 // degrees.
270 const unsigned int support_face = shape_index / this->n_dofs_per_face();
271
272 // The only thing we know for sure is that shape functions with support on
273 // one face are zero on the opposite face.
274 if (support_face < GeometryInfo<dim>::faces_per_cell)
275 return (face_index != GeometryInfo<dim>::opposite_face[support_face]);
276
277 // In all other cases, return true, which is safe
278 return true;
279}
280
281
282
283template <int dim, int spacedim>
284void
287 const std::vector<Vector<double>> &support_point_values,
288 std::vector<double> &nodal_values) const
289{
290 if constexpr (dim != spacedim)
291 {
292 // The computation below assumes that support_point_values are given
293 // in the dim-dimensional reference tangent space, which would require
294 // applying the inverse surface Piola transform first. This is not
295 // implemented for the codimension-one case.
296 (void)support_point_values;
297 (void)nodal_values;
299 }
300
301 Assert(support_point_values.size() == this->generalized_support_points.size(),
302 ExcDimensionMismatch(support_point_values.size(),
303 this->generalized_support_points.size()));
304 Assert(nodal_values.size() == this->n_dofs_per_cell(),
305 ExcDimensionMismatch(nodal_values.size(), this->n_dofs_per_cell()));
306 Assert(support_point_values[0].size() == this->n_components(),
307 ExcDimensionMismatch(support_point_values[0].size(),
308 this->n_components()));
309
310 // First do interpolation on faces. There, the component evaluated depends
311 // on the face direction and orientation.
312 unsigned int fbase = 0;
313 unsigned int f = 0;
314 for (; f < GeometryInfo<dim>::faces_per_cell;
315 ++f, fbase += this->n_dofs_per_face(f))
316 {
317 for (unsigned int i = 0; i < this->n_dofs_per_face(f); ++i)
318 {
319 nodal_values[fbase + i] = support_point_values[fbase + i](
321 }
322 }
323
324 // The remaining points form dim chunks, one for each component
325 const unsigned int istep = (this->n_dofs_per_cell() - fbase) / dim;
326 Assert((this->n_dofs_per_cell() - fbase) % dim == 0, ExcInternalError());
327
328 f = 0;
329 while (fbase < this->n_dofs_per_cell())
330 {
331 for (unsigned int i = 0; i < istep; ++i)
332 {
333 nodal_values[fbase + i] = support_point_values[fbase + i](f);
334 }
335 fbase += istep;
336 ++f;
337 }
338 Assert(fbase == this->n_dofs_per_cell(), ExcInternalError());
339}
340
341
342
343// TODO: There are tests that check that the following few functions don't
344// produce assertion failures, but none that actually check whether they do the
345// right thing. one example for such a test would be to project a function onto
346// an hp-space and make sure that the convergence order is correct with regard
347// to the lowest used polynomial degree
348
349template <int dim, int spacedim>
350bool
355
356
357template <int dim, int spacedim>
358std::vector<std::pair<unsigned int, unsigned int>>
360 const FiniteElement<dim, spacedim> &fe_other) const
361{
362 // we can presently only compute these identities if both FEs are
363 // FE_RaviartThomasNodals or the other is FE_Nothing. In either case, no
364 // dofs are assigned on the vertex, so we shouldn't be getting here at all.
365 if (dynamic_cast<const FE_RaviartThomasNodal<dim, spacedim> *>(&fe_other) !=
366 nullptr)
367 return std::vector<std::pair<unsigned int, unsigned int>>();
368 else if (dynamic_cast<const FE_Nothing<dim, spacedim> *>(&fe_other) !=
369 nullptr)
370 return std::vector<std::pair<unsigned int, unsigned int>>();
371 else
372 {
374 return std::vector<std::pair<unsigned int, unsigned int>>();
375 }
376}
377
378
379
380template <int dim, int spacedim>
381std::vector<std::pair<unsigned int, unsigned int>>
383 const FiniteElement<dim, spacedim> &fe_other) const
384{
385 // we can presently only compute these identities if both FEs are
386 // FE_RaviartThomasNodals or if the other one is FE_Nothing
387 if (const FE_RaviartThomasNodal<dim, spacedim> *fe_q_other =
388 dynamic_cast<const FE_RaviartThomasNodal<dim, spacedim> *>(&fe_other))
389 {
390 // dofs are located on faces; these are only lines in 2d
391 if (dim != 2)
392 return std::vector<std::pair<unsigned int, unsigned int>>();
393
394 // dofs are located along lines, so two dofs are identical only if in
395 // the following two cases (remember that the face support points are
396 // Gauss points):
397 // 1. this->degree = fe_q_other->degree,
398 // in the case, all the dofs on the line are identical
399 // 2. this->degree-1 and fe_q_other->degree-1
400 // are both even, i.e. this->dof_per_line and fe_q_other->dof_per_line
401 // are both odd, there exists only one point (the middle one) such
402 // that dofs are identical on this point
403 //
404 // to understand this, note that this->degree is the *maximal*
405 // polynomial degree, and is thus one higher than the argument given to
406 // the constructor
407 const unsigned int p = this->degree - 1;
408 const unsigned int q = fe_q_other->degree - 1;
409
410 std::vector<std::pair<unsigned int, unsigned int>> identities;
411
412 if (p == q)
413 for (unsigned int i = 0; i < p + 1; ++i)
414 identities.emplace_back(i, i);
415
416 else if (p % 2 == 0 && q % 2 == 0)
417 identities.emplace_back(p / 2, q / 2);
418
419 return identities;
420 }
421 else if (dynamic_cast<const FE_Nothing<dim, spacedim> *>(&fe_other) !=
422 nullptr)
423 {
424 // the FE_Nothing has no degrees of freedom, so there are no
425 // equivalencies to be recorded
426 return std::vector<std::pair<unsigned int, unsigned int>>();
427 }
428 else
429 {
431 return std::vector<std::pair<unsigned int, unsigned int>>();
432 }
433}
434
435
436template <int dim, int spacedim>
437std::vector<std::pair<unsigned int, unsigned int>>
439 const FiniteElement<dim, spacedim> &fe_other,
440 const unsigned int face_no) const
441{
442 // we can presently only compute these identities if both FEs are
443 // FE_RaviartThomasNodals or if the other one is FE_Nothing
444 if (const FE_RaviartThomasNodal<dim, spacedim> *fe_q_other =
445 dynamic_cast<const FE_RaviartThomasNodal<dim, spacedim> *>(&fe_other))
446 {
447 // dofs are located on faces; these are only quads in 3d
448 if (dim != 3)
449 return std::vector<std::pair<unsigned int, unsigned int>>();
450
451 // this works exactly like the line case above
452 const unsigned int p = this->n_dofs_per_quad(face_no);
453
454 AssertDimension(fe_q_other->n_unique_faces(), 1);
455 const unsigned int q = fe_q_other->n_dofs_per_quad(0);
456
457 std::vector<std::pair<unsigned int, unsigned int>> identities;
458
459 if (p == q)
460 for (unsigned int i = 0; i < p; ++i)
461 identities.emplace_back(i, i);
462
463 else if (p % 2 != 0 && q % 2 != 0)
464 identities.emplace_back(p / 2, q / 2);
465
466 return identities;
467 }
468 else if (dynamic_cast<const FE_Nothing<dim, spacedim> *>(&fe_other) !=
469 nullptr)
470 {
471 // the FE_Nothing has no degrees of freedom, so there are no
472 // equivalencies to be recorded
473 return std::vector<std::pair<unsigned int, unsigned int>>();
474 }
475 else
476 {
478 return std::vector<std::pair<unsigned int, unsigned int>>();
479 }
480}
481
482
483template <int dim, int spacedim>
486 const FiniteElement<dim, spacedim> &fe_other,
487 const unsigned int codim) const
488{
489 Assert(codim <= dim, ExcImpossibleInDim(dim));
490 (void)codim;
491
492 // vertex/line/face/cell domination
493 // --------------------------------
494 if (const FE_RaviartThomasNodal<dim, spacedim> *fe_rt_nodal_other =
495 dynamic_cast<const FE_RaviartThomasNodal<dim, spacedim> *>(&fe_other))
496 {
497 if (this->degree < fe_rt_nodal_other->degree)
499 else if (this->degree == fe_rt_nodal_other->degree)
501 else
503 }
504 else if (const FE_Nothing<dim, spacedim> *fe_nothing =
505 dynamic_cast<const FE_Nothing<dim, spacedim> *>(&fe_other))
506 {
507 if (fe_nothing->is_dominating())
509 else
510 // the FE_Nothing has no degrees of freedom and it is typically used
511 // in a context where we don't require any continuity along the
512 // interface
514 }
515
518}
519
520
521
522template <>
523void
525 const FiniteElement<1, 1> & /*x_source_fe*/,
526 FullMatrix<double> & /*interpolation_matrix*/,
527 const unsigned int) const
528{
529 Assert(false, ExcImpossibleInDim(1));
530}
531
532
533template <>
534void
536 const FiniteElement<1, 1> & /*x_source_fe*/,
537 const unsigned int /*subface*/,
538 FullMatrix<double> & /*interpolation_matrix*/,
539 const unsigned int) const
540{
541 Assert(false, ExcImpossibleInDim(1));
542}
543
544
545
546template <int dim, int spacedim>
547void
549 const FiniteElement<dim, spacedim> &x_source_fe,
550 FullMatrix<double> &interpolation_matrix,
551 const unsigned int face_no) const
552{
553 // this is only implemented, if the
554 // source FE is also a
555 // RaviartThomasNodal element
557 (x_source_fe.get_name().find("FE_RaviartThomasNodal<") == 0) ||
558 (dynamic_cast<const FE_RaviartThomasNodal<dim, spacedim> *>(
559 &x_source_fe) != nullptr),
561
562 Assert(interpolation_matrix.n() == this->n_dofs_per_face(face_no),
563 ExcDimensionMismatch(interpolation_matrix.n(),
564 this->n_dofs_per_face(face_no)));
565 Assert(interpolation_matrix.m() == x_source_fe.n_dofs_per_face(face_no),
566 ExcDimensionMismatch(interpolation_matrix.m(),
567 x_source_fe.n_dofs_per_face(face_no)));
568
569 // ok, source is a RaviartThomasNodal element, so we will be able to do the
570 // work
571 const FE_RaviartThomasNodal<dim, spacedim> &source_fe =
572 dynamic_cast<const FE_RaviartThomasNodal<dim, spacedim> &>(x_source_fe);
573
574 // Make sure that the element for which the DoFs should be constrained is
575 // the one with the higher polynomial degree. Actually the procedure will
576 // work also if this assertion is not satisfied. But the matrices produced
577 // in that case might lead to problems in the hp-procedures, which use this
578 // method.
579 Assert(
580 this->n_dofs_per_face(face_no) <= source_fe.n_dofs_per_face(face_no),
582
583 // generate a quadrature with the generalized support points. This is later
584 // based as a basis for the QProjector, which returns the support points on
585 // the face.
586 Quadrature<dim - 1> quad_face_support(
587 source_fe.generalized_face_support_points[face_no]);
588
589 // Rule of thumb for FP accuracy, that can be expected for a given
590 // polynomial degree. This value is used to cut off values close to zero.
591 double eps = 2e-13 * this->degree * (dim - 1);
592
593 // compute the interpolation matrix by simply taking the value at the
594 // support points.
595 const Quadrature<dim> face_projection =
596 QProjector<dim>::project_to_face(this->reference_cell(),
597 quad_face_support,
598 0,
600
601 for (unsigned int i = 0; i < source_fe.n_dofs_per_face(face_no); ++i)
602 {
603 const Point<dim> &p = face_projection.point(i);
604
605 for (unsigned int j = 0; j < this->n_dofs_per_face(face_no); ++j)
606 {
607 double matrix_entry =
608 this->shape_value_component(this->face_to_cell_index(j, 0), p, 0);
609
610 // Correct the interpolated value. I.e. if it is close to 1 or 0,
611 // make it exactly 1 or 0. Unfortunately, this is required to avoid
612 // problems with higher order elements.
613 if (std::fabs(matrix_entry - 1.0) < eps)
614 matrix_entry = 1.0;
615 if (std::fabs(matrix_entry) < eps)
616 matrix_entry = 0.0;
617
618 interpolation_matrix(i, j) = matrix_entry;
619 }
620 }
621
622 if constexpr (running_in_debug_mode())
623 {
624 // make sure that the row sum of each of the matrices is 1 at this
625 // point. this must be so since the shape functions sum up to 1
626 for (unsigned int j = 0; j < source_fe.n_dofs_per_face(face_no); ++j)
627 {
628 double sum = 0.;
629
630 for (unsigned int i = 0; i < this->n_dofs_per_face(face_no); ++i)
631 sum += interpolation_matrix(j, i);
632
633 Assert(std::fabs(sum - 1) < 2e-13 * this->degree * (dim - 1),
635 }
636 }
637}
638
639
640template <int dim, int spacedim>
641void
643 const FiniteElement<dim, spacedim> &x_source_fe,
644 const unsigned int subface,
645 FullMatrix<double> &interpolation_matrix,
646 const unsigned int face_no) const
647{
648 // this is only implemented, if the source FE is also a RaviartThomasNodal
649 // element
651 (x_source_fe.get_name().find("FE_RaviartThomasNodal<") == 0) ||
652 (dynamic_cast<const FE_RaviartThomasNodal<dim, spacedim> *>(
653 &x_source_fe) != nullptr),
655
656 Assert(interpolation_matrix.n() == this->n_dofs_per_face(face_no),
657 ExcDimensionMismatch(interpolation_matrix.n(),
658 this->n_dofs_per_face(face_no)));
659 Assert(interpolation_matrix.m() == x_source_fe.n_dofs_per_face(face_no),
660 ExcDimensionMismatch(interpolation_matrix.m(),
661 x_source_fe.n_dofs_per_face(face_no)));
662
663 // ok, source is a RaviartThomasNodal element, so we will be able to do the
664 // work
665 const FE_RaviartThomasNodal<dim, spacedim> &source_fe =
666 dynamic_cast<const FE_RaviartThomasNodal<dim, spacedim> &>(x_source_fe);
667
668 // Make sure that the element for which the DoFs should be constrained is
669 // the one with the higher polynomial degree. Actually the procedure will
670 // work also if this assertion is not satisfied. But the matrices produced
671 // in that case might lead to problems in the hp-procedures, which use this
672 // method.
673 Assert(
674 this->n_dofs_per_face(face_no) <= source_fe.n_dofs_per_face(face_no),
676
677 // generate a quadrature with the generalized support points. This is later
678 // based as a basis for the QProjector, which returns the support points on
679 // the face.
680 Quadrature<dim - 1> quad_face_support(
681 source_fe.generalized_face_support_points[face_no]);
682
683 // Rule of thumb for FP accuracy, that can be expected for a given
684 // polynomial degree. This value is used to cut off values close to zero.
685 double eps = 2e-13 * this->degree * (dim - 1);
686
687 // compute the interpolation matrix by simply taking the value at the
688 // support points.
689 const Quadrature<dim> subface_projection =
691 this->reference_cell(),
692 quad_face_support,
693 0,
694 subface,
697
698 for (unsigned int i = 0; i < source_fe.n_dofs_per_face(face_no); ++i)
699 {
700 const Point<dim> &p = subface_projection.point(i);
701
702 for (unsigned int j = 0; j < this->n_dofs_per_face(face_no); ++j)
703 {
704 double matrix_entry =
705 this->shape_value_component(this->face_to_cell_index(j, 0), p, 0);
706
707 // Correct the interpolated value. I.e. if it is close to 1 or 0,
708 // make it exactly 1 or 0. Unfortunately, this is required to avoid
709 // problems with higher order elements.
710 if (std::fabs(matrix_entry - 1.0) < eps)
711 matrix_entry = 1.0;
712 if (std::fabs(matrix_entry) < eps)
713 matrix_entry = 0.0;
714
715 interpolation_matrix(i, j) = matrix_entry;
716 }
717 }
718
719 if constexpr (running_in_debug_mode())
720 {
721 // make sure that the row sum of each of the matrices is 1 at this
722 // point. this must be so since the shape functions sum up to 1
723 for (unsigned int j = 0; j < source_fe.n_dofs_per_face(face_no); ++j)
724 {
725 double sum = 0.;
726
727 for (unsigned int i = 0; i < this->n_dofs_per_face(face_no); ++i)
728 sum += interpolation_matrix(j, i);
729
730 Assert(std::fabs(sum - 1) < 2e-13 * this->degree * (dim - 1),
732 }
733 }
734}
735
736
737
738template <int dim, int spacedim>
739const FullMatrix<double> &
741 const unsigned int child,
742 const RefinementCase<dim> &refinement_case) const
743{
744 AssertIndexRange(refinement_case,
748 "Prolongation matrices are only available for refined cells!"));
749 AssertIndexRange(child, this->reference_cell().n_children(refinement_case));
750
751 // initialization upon first request
752 if (this->prolongation[refinement_case - 1][child].n() == 0)
753 {
754 std::scoped_lock lock(prolongation_matrix_mutex);
755
756 // if matrix got updated while waiting for the lock
757 if (this->prolongation[refinement_case - 1][child].n() ==
758 this->n_dofs_per_cell())
759 return this->prolongation[refinement_case - 1][child];
760
761 // now do the work. need to get a non-const version of data in order to
762 // be able to modify them inside a const function
764 const_cast<FE_RaviartThomasNodal<dim, spacedim> &>(*this);
765 if (refinement_case == RefinementCase<dim>::isotropic_refinement)
766 {
767 std::vector<std::vector<FullMatrix<double>>> isotropic_matrices(
769 isotropic_matrices.back().resize(
770 this->reference_cell().n_children(
771 RefinementCase<dim>(refinement_case)),
772 FullMatrix<double>(this->n_dofs_per_cell(),
773 this->n_dofs_per_cell()));
774 FETools::compute_embedding_matrices(*this, isotropic_matrices, true);
775 this_nonconst.prolongation[refinement_case - 1] =
776 std::move(isotropic_matrices.back());
777 }
778 else
779 {
780 // must compute both restriction and prolongation matrices because
781 // we only check for their size and the reinit call initializes them
782 // all
785 this_nonconst.prolongation);
787 this_nonconst.restriction);
788 }
789 }
790
791 // finally return the matrix
792 return this->prolongation[refinement_case - 1][child];
793}
794
795
796
797template <int dim, int spacedim>
798const FullMatrix<double> &
800 const unsigned int child,
801 const RefinementCase<dim> &refinement_case) const
802{
803 AssertIndexRange(refinement_case,
807 "Restriction matrices are only available for refined cells!"));
808 AssertIndexRange(child, this->reference_cell().n_children(refinement_case));
809
810 // initialization upon first request
811 if (this->restriction[refinement_case - 1][child].n() == 0)
812 {
813 std::scoped_lock lock(restriction_matrix_mutex);
814
815 // if matrix got updated while waiting for the lock...
816 if (this->restriction[refinement_case - 1][child].n() ==
817 this->n_dofs_per_cell())
818 return this->restriction[refinement_case - 1][child];
819
820 // now do the work. need to get a non-const version of data in order to
821 // be able to modify them inside a const function
823 const_cast<FE_RaviartThomasNodal<dim, spacedim> &>(*this);
824 if (refinement_case == RefinementCase<dim>::isotropic_refinement)
825 {
826 std::vector<std::vector<FullMatrix<double>>> isotropic_matrices(
828 isotropic_matrices.back().resize(
829 this->reference_cell().n_children(
830 RefinementCase<dim>(refinement_case)),
831 FullMatrix<double>(this->n_dofs_per_cell(),
832 this->n_dofs_per_cell()));
833 FETools::compute_projection_matrices(*this, isotropic_matrices, true);
834 this_nonconst.restriction[refinement_case - 1] =
835 std::move(isotropic_matrices.back());
836 }
837 else
838 {
839 // must compute both restriction and prolongation matrices because
840 // we only check for their size and the reinit call initializes them
841 // all
844 this_nonconst.prolongation);
846 this_nonconst.restriction);
847 }
848 }
849
850 // finally return the matrix
851 return this->restriction[refinement_case - 1][child];
852}
853
854
855
856// explicit instantiations
857#include "fe/fe_raviart_thomas_nodal.inst"
858
859
std::vector< MappingKind > mapping_kind
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_quad_dof_identities(const FiniteElement< dim, spacedim > &fe_other, const unsigned int face_no=0) const override
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const override
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
virtual bool hp_constraints_are_implemented() const override
void initialize_quad_dof_index_permutation_and_sign_change()
static std::vector< unsigned int > get_lexicographic_numbering(const unsigned int degree)
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
virtual void get_subface_interpolation_matrix(const FiniteElement< dim, spacedim > &source, const unsigned int subface, FullMatrix< double > &matrix, const unsigned int face_no=0) const override
virtual const FullMatrix< double > & get_prolongation_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const override
virtual std::string get_name() const override
FE_RaviartThomasNodal(const unsigned int p)
virtual void convert_generalized_support_point_values_to_dof_values(const std::vector< Vector< double > > &support_point_values, std::vector< double > &nodal_values) const override
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix, const unsigned int face_no=0) const override
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const override
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
static std::vector< unsigned int > get_lexicographic_numbering(const unsigned int degree)
const unsigned int degree
Definition fe_data.h:450
unsigned int n_dofs_per_face(unsigned int face_no=0, unsigned int child=0) const
virtual std::string get_name() const =0
std::vector< std::vector< FullMatrix< double > > > restriction
Definition fe.h:2547
void reinit_restriction_and_prolongation_matrices(const bool isotropic_restriction_only=false, const bool isotropic_prolongation_only=false)
std::vector< std::vector< Point< dim - 1 > > > generalized_face_support_points
Definition fe.h:2604
FullMatrix< double > interface_constraints
Definition fe.h:2573
std::vector< Point< dim > > generalized_support_points
Definition fe.h:2598
std::vector< std::vector< FullMatrix< double > > > prolongation
Definition fe.h:2561
size_type n() const
size_type m() const
Definition point.h:111
std::vector< Point< dim > > get_polynomial_support_points() const
static Quadrature< dim > project_to_face(const ReferenceCell< dim > &reference_cell, const SubQuadrature &quadrature, const unsigned int face_no, const types::geometric_orientation combined_orientation)
static Quadrature< dim > project_to_subface(const ReferenceCell< dim > &reference_cell, const SubQuadrature &quadrature, const unsigned int face_no, const unsigned int subface_no, const types::geometric_orientation combined_orientation, const RefinementCase< dim - 1 > &ref_case)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
constexpr bool running_in_debug_mode()
Definition config.h:76
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_NOT_IMPLEMENTED()
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
@ mapping_raviart_thomas
Definition mapping.h:134
std::size_t size
Definition mpi.cc:733
void compute_embedding_matrices(const FiniteElement< dim, spacedim > &fe, std::vector< std::vector< FullMatrix< number > > > &matrices, const bool isotropic_only=false, const double threshold=1.e-12)
void compute_projection_matrices(const FiniteElement< dim, spacedim > &fe, std::vector< std::vector< FullMatrix< number > > > &matrices, const bool isotropic_only=false)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
std::string dim_string(const int dim, const int spacedim)
Definition utilities.cc:547
types::geometric_orientation combined_face_orientation(const bool face_orientation, const bool face_rotation, const bool face_flip)
constexpr types::geometric_orientation default_geometric_orientation
Definition types.h:342
STL namespace.