Loading [MathJax]/extensions/TeX/newcommand.js
 deal.II version GIT relicensing-3087-ga35b476a78 2025-04-19 20:30: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\}}
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
fe_face.cc
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2009 - 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
17
18#include <deal.II/fe/fe_face.h>
20#include <deal.II/fe/fe_poly_face.templates.h>
21#include <deal.II/fe/fe_tools.h>
22
24
25#include <memory>
26#include <sstream>
27
29
30
31namespace internal
32{
33 namespace FE_FaceQImplementation
34 {
35 namespace
36 {
37 std::vector<Point<1>>
38 get_QGaussLobatto_points(const unsigned int degree)
39 {
40 if (degree > 0)
41 return QGaussLobatto<1>(degree + 1).get_points();
42 else
43 return std::vector<Point<1>>(1, Point<1>(0.5));
44 }
45 } // namespace
46 } // namespace FE_FaceQImplementation
47} // namespace internal
48
49template <int dim, int spacedim>
50FE_FaceQ<dim, spacedim>::FE_FaceQ(const unsigned int degree)
51 : FE_PolyFace<TensorProductPolynomials<dim - 1>, dim, spacedim>(
53 Polynomials::generate_complete_Lagrange_basis(
54 internal::FE_FaceQImplementation::get_QGaussLobatto_points(degree))),
55 FiniteElementData<dim>(get_dpo_vector(degree),
56 1,
57 degree,
58 FiniteElementData<dim>::L2),
59 std::vector<bool>(1, true))
60{
61 // initialize unit face support points
62 const unsigned int codim = dim - 1;
63 this->unit_face_support_points[0].resize(
64 Utilities::fixed_power<codim>(this->degree + 1));
65
66 if (this->degree == 0)
67 for (unsigned int d = 0; d < codim; ++d)
68 this->unit_face_support_points[0][0][d] = 0.5;
69 else
70 {
71 std::vector<Point<1>> points =
72 internal::FE_FaceQImplementation::get_QGaussLobatto_points(degree);
73
74 unsigned int k = 0;
75 for (unsigned int iz = 0; iz <= ((codim > 2) ? this->degree : 0); ++iz)
76 for (unsigned int iy = 0; iy <= ((codim > 1) ? this->degree : 0); ++iy)
77 for (unsigned int ix = 0; ix <= this->degree; ++ix)
78 {
80
81 p[0] = points[ix][0];
82 if (codim > 1)
83 p[1] = points[iy][0];
84 if (codim > 2)
85 p[2] = points[iz][0];
86
87 this->unit_face_support_points[0][k++] = p;
88 }
90 }
91
92 // initialize unit support points (this makes it possible to assign initial
93 // values to FE_FaceQ)
96 const unsigned int n_face_dofs = this->unit_face_support_points[0].size();
97 for (unsigned int i = 0; i < n_face_dofs; ++i)
98 for (unsigned int d = 0; d < dim; ++d)
99 {
100 for (unsigned int e = 0, c = 0; e < dim; ++e)
101 if (d != e)
102 {
103 // faces in y-direction are oriented differently
104 unsigned int renumber = i;
105 if (dim == 3 && d == 1)
106 renumber = i / (degree + 1) + (degree + 1) * (i % (degree + 1));
107 this->unit_support_points[n_face_dofs * 2 * d + i][e] =
108 this->unit_face_support_points[0][renumber][c];
109 this->unit_support_points[n_face_dofs * (2 * d + 1) + i][e] =
110 this->unit_face_support_points[0][renumber][c];
111 this->unit_support_points[n_face_dofs * (2 * d + 1) + i][d] = 1;
112 ++c;
113 }
114 }
115}
116
117
118
119template <int dim, int spacedim>
120std::unique_ptr<FiniteElement<dim, spacedim>>
122{
123 return std::make_unique<FE_FaceQ<dim, spacedim>>(this->degree);
124}
125
126
127
128template <int dim, int spacedim>
129std::string
131{
132 // note that the FETools::get_fe_by_name function depends on the
133 // particular format of the string this function returns, so they have to be
134 // kept in synch
135 std::ostringstream namebuf;
136 namebuf << "FE_FaceQ<" << Utilities::dim_string(dim, spacedim) << ">("
137 << this->degree << ")";
138
139 return namebuf.str();
140}
141
142
143
144template <int dim, int spacedim>
145void
147 const FiniteElement<dim, spacedim> &source_fe,
148 FullMatrix<double> &interpolation_matrix,
149 const unsigned int face_no) const
150{
151 get_subface_interpolation_matrix(source_fe,
153 interpolation_matrix,
154 face_no);
155}
156
157
158
159template <int dim, int spacedim>
160void
162 const FiniteElement<dim, spacedim> &x_source_fe,
163 const unsigned int subface,
164 FullMatrix<double> &interpolation_matrix,
165 const unsigned int face_no) const
166{
167 // this function is similar to the respective method in FE_Q
168
169 Assert(interpolation_matrix.n() == this->n_dofs_per_face(face_no),
170 ExcDimensionMismatch(interpolation_matrix.n(),
171 this->n_dofs_per_face(face_no)));
172 Assert(interpolation_matrix.m() == x_source_fe.n_dofs_per_face(face_no),
173 ExcDimensionMismatch(interpolation_matrix.m(),
174 x_source_fe.n_dofs_per_face(face_no)));
175
176 // see if source is a FaceQ element
177 if (const FE_FaceQ<dim, spacedim> *source_fe =
178 dynamic_cast<const FE_FaceQ<dim, spacedim> *>(&x_source_fe))
179 {
180 // Make sure that the element for which the DoFs should be constrained
181 // is the one with the higher polynomial degree. Actually the procedure
182 // will work also if this assertion is not satisfied. But the matrices
183 // produced in that case might lead to problems in the hp-procedures,
184 // which use this method.
185 Assert(
186 this->n_dofs_per_face(face_no) <= source_fe->n_dofs_per_face(face_no),
187 (typename FiniteElement<dim,
188 spacedim>::ExcInterpolationNotImplemented()));
189
190 // generate a quadrature with the unit face support points.
191 const Quadrature<dim - 1> face_quadrature(
192 source_fe->get_unit_face_support_points(face_no));
193
194 // Rule of thumb for FP accuracy, that can be expected for a given
195 // polynomial degree. This value is used to cut off values close to
196 // zero.
197 const double eps = 2e-13 * (this->degree + 1) * (dim - 1);
198
199 // compute the interpolation matrix by simply taking the value at the
200 // support points.
201 for (unsigned int i = 0; i < source_fe->n_dofs_per_face(face_no); ++i)
202 {
203 const Point<dim - 1> p =
205 face_quadrature.point(i) :
207 face_quadrature.point(i), subface);
208
209 for (unsigned int j = 0; j < this->n_dofs_per_face(face_no); ++j)
210 {
211 double matrix_entry = this->poly_space.compute_value(j, p);
212
213 // Correct the interpolated value. I.e. if it is close to 1 or 0,
214 // make it exactly 1 or 0. Unfortunately, this is required to
215 // avoid problems with higher order elements.
216 if (std::fabs(matrix_entry - 1.0) < eps)
217 matrix_entry = 1.0;
218 if (std::fabs(matrix_entry) < eps)
219 matrix_entry = 0.0;
220
221 interpolation_matrix(i, j) = matrix_entry;
222 }
223 }
224
225 if constexpr (running_in_debug_mode())
226 {
227 // make sure that the row sum of each of the matrices is 1 at this
228 // point. this must be so since the shape functions sum up to 1
229 for (unsigned int j = 0; j < source_fe->n_dofs_per_face(face_no); ++j)
230 {
231 double sum = 0.;
232
233 for (unsigned int i = 0; i < this->n_dofs_per_face(face_no); ++i)
234 sum += interpolation_matrix(j, i);
235
236 Assert(std::fabs(sum - 1) < eps, ExcInternalError());
237 }
238 }
239 }
240 else if (dynamic_cast<const FE_Nothing<dim> *>(&x_source_fe) != nullptr)
241 {
242 // nothing to do here, the FE_Nothing has no degrees of freedom anyway
243 }
244 else
246 false,
247 (typename FiniteElement<dim,
248 spacedim>::ExcInterpolationNotImplemented()));
249}
250
251
252
253template <int dim, int spacedim>
254bool
256 const unsigned int shape_index,
257 const unsigned int face_index) const
258{
259 return (face_index == (shape_index / this->n_dofs_per_face(face_index)));
260}
261
262
263
264template <int dim, int spacedim>
265std::vector<unsigned int>
267{
268 std::vector<unsigned int> dpo(dim + 1, 0U);
269 dpo[dim - 1] = deg + 1;
270 for (unsigned int i = 1; i < dim - 1; ++i)
271 dpo[dim - 1] *= deg + 1;
272 return dpo;
273}
274
275
276
277template <int dim, int spacedim>
278bool
283
284
285
286template <int dim, int spacedim>
287std::vector<std::pair<unsigned int, unsigned int>>
289 const FiniteElement<dim, spacedim> & /*fe_other*/) const
290{
291 // this element is always discontinuous at vertices
292 return std::vector<std::pair<unsigned int, unsigned int>>();
293}
294
295
296
297template <int dim, int spacedim>
298std::vector<std::pair<unsigned int, unsigned int>>
300 const FiniteElement<dim, spacedim> &fe_other) const
301{
302 Assert(dim >= 2, ExcInternalError());
303
304 // this element is continuous only for the highest dimensional bounding object
305 if (dim > 2)
306 return std::vector<std::pair<unsigned int, unsigned int>>();
307 else
308 {
309 // this is similar to the FE_Q_Base class
310 if (const FE_FaceQ<dim, spacedim> *fe_q_other =
311 dynamic_cast<const FE_FaceQ<dim, spacedim> *>(&fe_other))
312 {
313 // dofs are located along lines, so two dofs are identical if they are
314 // located at identical positions.
315 // Therefore, read the points in unit_support_points for the
316 // first coordinate direction. We take the lexicographic ordering of
317 // the points in the second direction (i.e., y-direction) since we
318 // know that the first p+1 dofs are located at the left (x=0) face.
319 const unsigned int p = this->degree;
320 const unsigned int q = fe_q_other->degree;
321
322 std::vector<std::pair<unsigned int, unsigned int>> identities;
323
324 const std::vector<unsigned int> &index_map_inverse =
325 this->poly_space.get_numbering_inverse();
326 const std::vector<unsigned int> &index_map_inverse_other =
327 fe_q_other->poly_space.get_numbering_inverse();
328
329 for (unsigned int i = 0; i < p + 1; ++i)
330 for (unsigned int j = 0; j < q + 1; ++j)
331 if (std::fabs(
332 this->unit_support_points[index_map_inverse[i]][dim - 1] -
333 fe_q_other->unit_support_points[index_map_inverse_other[j]]
334 [dim - 1]) < 1e-14)
335 identities.emplace_back(i, j);
336
337 return identities;
338 }
339 else if (dynamic_cast<const FE_Nothing<dim> *>(&fe_other) != nullptr)
340 {
341 // the FE_Nothing has no degrees of freedom, so there are no
342 // equivalencies to be recorded
343 return std::vector<std::pair<unsigned int, unsigned int>>();
344 }
345 else if (fe_other.n_unique_faces() == 1 &&
346 fe_other.n_dofs_per_face(0) == 0)
347 {
348 // if the other element has no elements on faces at all,
349 // then it would be impossible to enforce any kind of
350 // continuity even if we knew exactly what kind of element
351 // we have -- simply because the other element declares
352 // that it is discontinuous because it has no DoFs on
353 // its faces. in that case, just state that we have no
354 // constraints to declare
355 return std::vector<std::pair<unsigned int, unsigned int>>();
356 }
357 else
358 {
360 return std::vector<std::pair<unsigned int, unsigned int>>();
361 }
362 }
363}
364
365
366
367template <int dim, int spacedim>
368std::vector<std::pair<unsigned int, unsigned int>>
370 const FiniteElement<dim, spacedim> &fe_other,
371 const unsigned int) const
372{
373 Assert(dim >= 3, ExcInternalError());
374
375 // this element is continuous only for the highest dimensional bounding object
376 if (dim > 3)
377 return std::vector<std::pair<unsigned int, unsigned int>>();
378 else
379 {
380 // this is similar to the FE_Q_Base class
381 if (const FE_FaceQ<dim, spacedim> *fe_q_other =
382 dynamic_cast<const FE_FaceQ<dim, spacedim> *>(&fe_other))
383 {
384 // this works exactly like the line case above, except that now we
385 // have to have two indices i1, i2 and j1, j2 to characterize the dofs
386 // on the face of each of the finite elements. since they are ordered
387 // lexicographically along the first line and we have a tensor
388 // product, the rest is rather straightforward
389 const unsigned int p = this->degree;
390 const unsigned int q = fe_q_other->degree;
391
392 std::vector<std::pair<unsigned int, unsigned int>> identities;
393
394 const std::vector<unsigned int> &index_map_inverse =
395 this->poly_space.get_numbering_inverse();
396 const std::vector<unsigned int> &index_map_inverse_other =
397 fe_q_other->poly_space.get_numbering_inverse();
398
399 std::vector<std::pair<unsigned int, unsigned int>> identities_1d;
400
401 for (unsigned int i = 0; i < p + 1; ++i)
402 for (unsigned int j = 0; j < q + 1; ++j)
403 if (std::fabs(
404 this->unit_support_points[index_map_inverse[i]][dim - 2] -
405 fe_q_other->unit_support_points[index_map_inverse_other[j]]
406 [dim - 2]) < 1e-14)
407 identities_1d.emplace_back(i, j);
408
409 for (unsigned int n1 = 0; n1 < identities_1d.size(); ++n1)
410 for (unsigned int n2 = 0; n2 < identities_1d.size(); ++n2)
411 identities.emplace_back(identities_1d[n1].first * (p + 1) +
412 identities_1d[n2].first,
413 identities_1d[n1].second * (q + 1) +
414 identities_1d[n2].second);
415
416 return identities;
417 }
418 else if (dynamic_cast<const FE_Nothing<dim> *>(&fe_other) != nullptr)
419 {
420 // the FE_Nothing has no degrees of freedom, so there are no
421 // equivalencies to be recorded
422 return std::vector<std::pair<unsigned int, unsigned int>>();
423 }
424 else if (fe_other.n_unique_faces() == 1 &&
425 fe_other.n_dofs_per_face(0) == 0)
426 {
427 // if the other element has no elements on faces at all,
428 // then it would be impossible to enforce any kind of
429 // continuity even if we knew exactly what kind of element
430 // we have -- simply because the other element declares
431 // that it is discontinuous because it has no DoFs on
432 // its faces. in that case, just state that we have no
433 // constraints to declare
434 return std::vector<std::pair<unsigned int, unsigned int>>();
435 }
436 else
437 {
439 return std::vector<std::pair<unsigned int, unsigned int>>();
440 }
441 }
442}
443
444
445
446template <int dim, int spacedim>
449 const FiniteElement<dim, spacedim> &fe_other,
450 const unsigned int codim) const
451{
452 Assert(codim <= dim, ExcImpossibleInDim(dim));
453
454 // vertex/line/face/cell domination
455 // --------------------------------
456 if (const FE_FaceQ<dim, spacedim> *fe_faceq_other =
457 dynamic_cast<const FE_FaceQ<dim, spacedim> *>(&fe_other))
458 {
459 if (this->degree < fe_faceq_other->degree)
461 else if (this->degree == fe_faceq_other->degree)
463 else
465 }
466 else if (const FE_Nothing<dim> *fe_nothing =
467 dynamic_cast<const FE_Nothing<dim> *>(&fe_other))
468 {
469 if (fe_nothing->is_dominating())
471 else
472 // the FE_Nothing has no degrees of freedom and it is typically used
473 // in a context where we don't require any continuity along the
474 // interface
476 }
477
480}
481
482template <int dim, int spacedim>
483std::pair<Table<2, bool>, std::vector<unsigned int>>
485{
486 Table<2, bool> constant_modes(1, this->n_dofs_per_cell());
487 for (unsigned int i = 0; i < this->n_dofs_per_cell(); ++i)
488 constant_modes(0, i) = true;
489 return std::pair<Table<2, bool>, std::vector<unsigned int>>(
490 constant_modes, std::vector<unsigned int>(1, 0));
491}
492
493template <int dim, int spacedim>
494void
496 const std::vector<Vector<double>> &support_point_values,
497 std::vector<double> &nodal_values) const
498{
499 AssertDimension(support_point_values.size(),
500 this->get_unit_support_points().size());
501 AssertDimension(support_point_values.size(), nodal_values.size());
502 AssertDimension(this->n_dofs_per_cell(), nodal_values.size());
503
504 for (unsigned int i = 0; i < this->n_dofs_per_cell(); ++i)
505 {
506 AssertDimension(support_point_values[i].size(), 1);
507
508 nodal_values[i] = support_point_values[i](0);
509 }
510}
511
512// ----------------------------- FE_FaceQ<1,spacedim> ------------------------
513
514template <int spacedim>
515FE_FaceQ<1, spacedim>::FE_FaceQ(const unsigned int degree)
516 : FiniteElement<1, spacedim>(
517 FiniteElementData<1>(get_dpo_vector(degree),
518 1,
519 degree,
520 FiniteElementData<1>::L2),
521 std::vector<bool>(1, true),
522 std::vector<ComponentMask>(1, ComponentMask(1, true)))
523{
524 this->unit_face_support_points[0].resize(1);
525
526 // initialize unit support points (this makes it possible to assign initial
527 // values to FE_FaceQ)
529 this->unit_support_points[1] = Point<1>(1.);
530}
531
532
533
534template <int spacedim>
535std::unique_ptr<FiniteElement<1, spacedim>>
537{
538 return std::make_unique<FE_FaceQ<1, spacedim>>(this->degree);
539}
540
541
542
543template <int spacedim>
544std::string
546{
547 // note that the FETools::get_fe_by_name function depends on the
548 // particular format of the string this function returns, so they have to be
549 // kept in synch
550 std::ostringstream namebuf;
551 namebuf << "FE_FaceQ<" << Utilities::dim_string(1, spacedim) << ">("
552 << this->degree << ")";
553
554 return namebuf.str();
555}
556
557
558
559template <int spacedim>
560void
562 const FiniteElement<1, spacedim> &source_fe,
563 FullMatrix<double> &interpolation_matrix,
564 const unsigned int face_no) const
565{
566 get_subface_interpolation_matrix(source_fe,
568 interpolation_matrix,
569 face_no);
570}
571
572
573
574template <int spacedim>
575void
577 const FiniteElement<1, spacedim> &x_source_fe,
578 const unsigned int /*subface*/,
579 FullMatrix<double> &interpolation_matrix,
580 const unsigned int face_no) const
581{
582 Assert(interpolation_matrix.n() == this->n_dofs_per_face(face_no),
583 ExcDimensionMismatch(interpolation_matrix.n(),
584 this->n_dofs_per_face(face_no)));
585 Assert(interpolation_matrix.m() == x_source_fe.n_dofs_per_face(face_no),
586 ExcDimensionMismatch(interpolation_matrix.m(),
587 x_source_fe.n_dofs_per_face(face_no)));
588 interpolation_matrix(0, 0) = 1.;
589}
590
591
592
593template <int spacedim>
594bool
595FE_FaceQ<1, spacedim>::has_support_on_face(const unsigned int shape_index,
596 const unsigned int face_index) const
597{
598 AssertIndexRange(shape_index, 2);
599 return (face_index == shape_index);
600}
601
602
603
604template <int spacedim>
605std::vector<unsigned int>
607{
608 std::vector<unsigned int> dpo(2, 0U);
609 dpo[0] = 1;
610 return dpo;
611}
612
613
614
615template <int spacedim>
616bool
621
622template <int spacedim>
623std::vector<std::pair<unsigned int, unsigned int>>
625 const FiniteElement<1, spacedim> & /*fe_other*/) const
626{
627 // this element is always discontinuous at vertices
628 return std::vector<std::pair<unsigned int, unsigned int>>(1,
629 std::make_pair(0U,
630 0U));
631}
632
633
634
635template <int spacedim>
636std::vector<std::pair<unsigned int, unsigned int>>
638 const FiniteElement<1, spacedim> &) const
639{
640 // this element is continuous only for the highest dimensional bounding object
641 return std::vector<std::pair<unsigned int, unsigned int>>();
642}
643
644
645
646template <int spacedim>
647std::vector<std::pair<unsigned int, unsigned int>>
650 const unsigned int) const
651{
652 // this element is continuous only for the highest dimensional bounding object
653 return std::vector<std::pair<unsigned int, unsigned int>>();
654}
655
656
657
658template <int spacedim>
659std::pair<Table<2, bool>, std::vector<unsigned int>>
661{
662 Table<2, bool> constant_modes(1, this->n_dofs_per_cell());
663 for (unsigned int i = 0; i < this->n_dofs_per_cell(); ++i)
664 constant_modes(0, i) = true;
665 return std::pair<Table<2, bool>, std::vector<unsigned int>>(
666 constant_modes, std::vector<unsigned int>(1, 0));
667}
668
669
670
671template <int spacedim>
685
686
687template <int spacedim>
688void
692 const Quadrature<1> &,
693 const Mapping<1, spacedim> &,
698 spacedim>
699 &) const
700{
701 // Do nothing, since we do not have values in the interior
702}
703
704
705
706template <int spacedim>
707void
710 const unsigned int face,
711 const hp::QCollection<0> &,
712 const Mapping<1, spacedim> &,
715 const typename FiniteElement<1, spacedim>::InternalDataBase &fe_internal,
717 spacedim>
718 &output_data) const
719{
720 const unsigned int foffset = face;
721 if (fe_internal.update_each & update_values)
722 {
723 for (unsigned int k = 0; k < this->n_dofs_per_cell(); ++k)
724 output_data.shape_values(k, 0) = 0.;
725 output_data.shape_values(foffset, 0) = 1;
726 }
727}
728
729
730template <int spacedim>
731void
734 const unsigned int,
735 const unsigned int,
736 const Quadrature<0> &,
737 const Mapping<1, spacedim> &,
742 spacedim>
743 &) const
744{
745 Assert(false, ExcMessage("There are no sub-face values to fill in 1d!"));
746}
747
748
749
750// --------------------------------------- FE_FaceP --------------------------
751
752template <int dim, int spacedim>
753FE_FaceP<dim, spacedim>::FE_FaceP(const unsigned int degree)
754 : FE_PolyFace<PolynomialSpace<dim - 1>, dim, spacedim>(
755 PolynomialSpace<dim - 1>(
756 Polynomials::Legendre::generate_complete_basis(degree)),
757 FiniteElementData<dim>(get_dpo_vector(degree),
758 1,
759 degree,
760 FiniteElementData<dim>::L2),
761 std::vector<bool>(1, true))
762{}
763
764
765
766template <int dim, int spacedim>
767std::unique_ptr<FiniteElement<dim, spacedim>>
769{
770 return std::make_unique<FE_FaceP<dim, spacedim>>(this->degree);
771}
772
773
774
775template <int dim, int spacedim>
776std::string
778{
779 // note that the FETools::get_fe_by_name function depends on the
780 // particular format of the string this function returns, so they have to be
781 // kept in synch
782 std::ostringstream namebuf;
783 namebuf << "FE_FaceP<" << Utilities::dim_string(dim, spacedim) << ">("
784 << this->degree << ")";
785
786 return namebuf.str();
787}
788
789
790
791template <int dim, int spacedim>
792bool
794 const unsigned int shape_index,
795 const unsigned int face_index) const
796{
797 return (face_index == (shape_index / this->n_dofs_per_face(face_index)));
798}
799
800
801
802template <int dim, int spacedim>
803std::vector<unsigned int>
805{
806 std::vector<unsigned int> dpo(dim + 1, 0U);
807 dpo[dim - 1] = deg + 1;
808 for (unsigned int i = 1; i < dim - 1; ++i)
809 {
810 dpo[dim - 1] *= deg + 1 + i;
811 dpo[dim - 1] /= i + 1;
812 }
813 return dpo;
814}
815
816
817
818template <int dim, int spacedim>
819bool
824
825
826
827template <int dim, int spacedim>
830 const FiniteElement<dim, spacedim> &fe_other,
831 const unsigned int codim) const
832{
833 Assert(codim <= dim, ExcImpossibleInDim(dim));
834
835 // vertex/line/face/cell domination
836 // --------------------------------
837 if (const FE_FaceP<dim, spacedim> *fe_facep_other =
838 dynamic_cast<const FE_FaceP<dim, spacedim> *>(&fe_other))
839 {
840 if (this->degree < fe_facep_other->degree)
842 else if (this->degree == fe_facep_other->degree)
844 else
846 }
847 else if (const FE_Nothing<dim> *fe_nothing =
848 dynamic_cast<const FE_Nothing<dim> *>(&fe_other))
849 {
850 if (fe_nothing->is_dominating())
852 else
853 // the FE_Nothing has no degrees of freedom and it is typically used
854 // in a context where we don't require any continuity along the
855 // interface
857 }
858
861}
862
863
864
865template <int dim, int spacedim>
866void
868 const FiniteElement<dim, spacedim> &source_fe,
869 FullMatrix<double> &interpolation_matrix,
870 const unsigned int face_no) const
871{
872 get_subface_interpolation_matrix(source_fe,
874 interpolation_matrix,
875 face_no);
876}
877
878
879
880template <int dim, int spacedim>
881void
883 const FiniteElement<dim, spacedim> &x_source_fe,
884 const unsigned int subface,
885 FullMatrix<double> &interpolation_matrix,
886 const unsigned int face_no) const
887{
888 // this function is similar to the respective method in FE_Q
889
890 Assert(interpolation_matrix.n() == this->n_dofs_per_face(face_no),
891 ExcDimensionMismatch(interpolation_matrix.n(),
892 this->n_dofs_per_face(face_no)));
893 Assert(interpolation_matrix.m() == x_source_fe.n_dofs_per_face(face_no),
894 ExcDimensionMismatch(interpolation_matrix.m(),
895 x_source_fe.n_dofs_per_face(face_no)));
896
897 // see if source is a FaceP element
898 if (const FE_FaceP<dim, spacedim> *source_fe =
899 dynamic_cast<const FE_FaceP<dim, spacedim> *>(&x_source_fe))
900 {
901 // Make sure that the element for which the DoFs should be constrained
902 // is the one with the higher polynomial degree. Actually the procedure
903 // will work also if this assertion is not satisfied. But the matrices
904 // produced in that case might lead to problems in the hp-procedures,
905 // which use this method.
906 Assert(
907 this->n_dofs_per_face(face_no) <= source_fe->n_dofs_per_face(face_no),
908 (typename FiniteElement<dim,
909 spacedim>::ExcInterpolationNotImplemented()));
910
911 // do this as in FETools by solving a least squares problem where we
912 // force the source FE polynomial to be equal the given FE on all
913 // quadrature points
914 const QGauss<dim - 1> face_quadrature(source_fe->degree + 1);
915
916 // Rule of thumb for FP accuracy, that can be expected for a given
917 // polynomial degree. This value is used to cut off values close to
918 // zero.
919 const double eps = 2e-13 * (this->degree + 1) * (dim - 1);
920
921 FullMatrix<double> mass(face_quadrature.size(),
922 source_fe->n_dofs_per_face(face_no));
923
924 for (unsigned int k = 0; k < face_quadrature.size(); ++k)
925 {
926 const Point<dim - 1> p =
928 face_quadrature.point(k) :
930 face_quadrature.point(k), subface);
931
932 for (unsigned int j = 0; j < source_fe->n_dofs_per_face(face_no); ++j)
933 mass(k, j) = source_fe->poly_space.compute_value(j, p);
934 }
935
936 Householder<double> H(mass);
937 Vector<double> v_in(face_quadrature.size());
938 Vector<double> v_out(source_fe->n_dofs_per_face(face_no));
939
940
941 // compute the interpolation matrix by evaluating on the fine side and
942 // then solving the least squares problem
943 for (unsigned int i = 0; i < this->n_dofs_per_face(face_no); ++i)
944 {
945 for (unsigned int k = 0; k < face_quadrature.size(); ++k)
946 {
947 const Point<dim - 1> p =
949 face_quadrature.point(k) :
951 face_quadrature.point(k), subface);
952 v_in(k) = this->poly_space.compute_value(i, p);
953 }
954 [[maybe_unused]] const double result = H.least_squares(v_out, v_in);
955 Assert(result < 1e-12, FETools::ExcLeastSquaresError(result));
956
957 for (unsigned int j = 0; j < source_fe->n_dofs_per_face(face_no); ++j)
958 {
959 double matrix_entry = v_out(j);
960
961 // Correct the interpolated value. I.e. if it is close to 1 or 0,
962 // make it exactly 1 or 0. Unfortunately, this is required to
963 // avoid problems with higher order elements.
964 if (std::fabs(matrix_entry - 1.0) < eps)
965 matrix_entry = 1.0;
966 if (std::fabs(matrix_entry) < eps)
967 matrix_entry = 0.0;
968
969 interpolation_matrix(j, i) = matrix_entry;
970 }
971 }
972 }
973 else if (dynamic_cast<const FE_Nothing<dim> *>(&x_source_fe) != nullptr)
974 {
975 // nothing to do here, the FE_Nothing has no degrees of freedom anyway
976 }
977 else
979 false,
980 (typename FiniteElement<dim,
981 spacedim>::ExcInterpolationNotImplemented()));
982}
983
984
985
986template <int dim, int spacedim>
987std::pair<Table<2, bool>, std::vector<unsigned int>>
989{
990 Table<2, bool> constant_modes(1, this->n_dofs_per_cell());
991 for (const unsigned int face : GeometryInfo<dim>::face_indices())
992 constant_modes(0, face * this->n_dofs_per_face(face)) = true;
993 return std::pair<Table<2, bool>, std::vector<unsigned int>>(
994 constant_modes, std::vector<unsigned int>(1, 0));
995}
996
997
998
999template <int spacedim>
1000FE_FaceP<1, spacedim>::FE_FaceP(const unsigned int degree)
1001 : FE_FaceQ<1, spacedim>(degree)
1002{}
1003
1004
1005
1006template <int spacedim>
1007std::string
1009{
1010 // note that the FETools::get_fe_by_name function depends on the
1011 // particular format of the string this function returns, so they have to be
1012 // kept in synch
1013 std::ostringstream namebuf;
1014 namebuf << "FE_FaceP<" << Utilities::dim_string(1, spacedim) << ">("
1015 << this->degree << ")";
1016
1017 return namebuf.str();
1018}
1019
1020
1021
1022// explicit instantiations
1023#include "fe/fe_face.inst"
1024
1025
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const override
Definition fe_face.cc:988
virtual bool hp_constraints_are_implemented() const override
Definition fe_face.cc:820
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const override
Definition fe_face.cc:793
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
Definition fe_face.cc:829
virtual std::string get_name() const override
Definition fe_face.cc:777
static std::vector< unsigned int > get_dpo_vector(const unsigned int deg)
Definition fe_face.cc:804
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
Definition fe_face.cc:882
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition fe_face.cc:768
FE_FaceP(unsigned int p)
Definition fe_face.cc:753
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix, const unsigned int face_no=0) const override
Definition fe_face.cc:867
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const override final
Definition fe_face.cc:448
virtual std::string get_name() const override
Definition fe_face.cc:130
static std::vector< unsigned int > get_dpo_vector(const unsigned int deg)
Definition fe_face.cc:266
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
Definition fe_face.cc:495
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const override
Definition fe_face.cc:484
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix, const unsigned int face_no=0) const override
Definition fe_face.cc:146
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Definition fe_face.cc:299
FE_FaceQ(const unsigned int p)
Definition fe_face.cc:50
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
Definition fe_face.cc:121
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
Definition fe_face.cc:161
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const override
Definition fe_face.cc:255
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Definition fe_face.cc:288
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
Definition fe_face.cc:369
virtual bool hp_constraints_are_implemented() const override
Definition fe_face.cc:279
const unsigned int degree
Definition fe_data.h:452
unsigned int n_dofs_per_face(unsigned int face_no=0, unsigned int child=0) const
unsigned int n_unique_faces() const
virtual void fill_fe_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellSimilarity::Similarity cell_similarity, const Quadrature< dim > &quadrature, const Mapping< dim, spacedim > &mapping, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_internal, const internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &mapping_data, const InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const =0
std::vector< std::vector< Point< dim - 1 > > > unit_face_support_points
Definition fe.h:2568
virtual void fill_fe_face_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const hp::QCollection< dim - 1 > &quadrature, const Mapping< dim, spacedim > &mapping, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_internal, const internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &mapping_data, const InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const
virtual void fill_fe_subface_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const unsigned int sub_no, const Quadrature< dim - 1 > &quadrature, const Mapping< dim, spacedim > &mapping, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_internal, const internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &mapping_data, const InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const =0
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const =0
std::vector< Point< dim > > unit_support_points
Definition fe.h:2561
size_type n() const
size_type m() const
double least_squares(Vector< number2 > &dst, const Vector< number2 > &src) const
Abstract base class for mapping classes.
Definition mapping.h:320
Definition point.h:113
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:35
constexpr bool running_in_debug_mode()
Definition config.h:73
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:36
#define DEAL_II_NOT_IMPLEMENTED()
Point< 2 > second
Definition grid_out.cc:4633
#define Assert(cond, exc)
static ::ExceptionBase & ExcLeastSquaresError(double arg1)
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)
UpdateFlags
@ update_hessians
Second derivatives of shape functions.
@ update_values
Shape function values.
@ update_normal_vectors
Normal vectors.
@ update_JxW_values
Transformed quadrature weights.
@ update_covariant_transformation
Covariant transformation.
@ update_gradients
Shape function gradients.
std::size_t size
Definition mpi.cc:745
std::string dim_string(const int dim, const int spacedim)
Definition utilities.cc:551
constexpr unsigned int invalid_unsigned_int
Definition types.h:238
STL namespace.
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()
static Point< dim > child_to_cell_coordinates(const Point< dim > &p, const unsigned int child_index, const RefinementCase< dim > refine_case=RefinementCase< dim >::isotropic_refinement)