deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20: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.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) 1998 - 2025 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
16
18
19#include <deal.II/fe/fe.h>
21#include <deal.II/fe/mapping.h>
22
23#include <deal.II/grid/tria.h>
26
27#include <algorithm>
28#include <functional>
29#include <numeric>
30#include <typeinfo>
31
33
34
35/*------------------------------- FiniteElement ----------------------*/
36#ifndef DOXYGEN
37
38template <int dim, int spacedim>
40 : update_each(update_default)
41{}
42
43
44
45template <int dim, int spacedim>
46std::size_t
48{
49 return sizeof(*this);
50}
51
52
53
54template <int dim, int spacedim>
56 const FiniteElementData<dim> &fe_data,
57 const std::vector<bool> &r_i_a_f,
58 const std::vector<ComponentMask> &nonzero_c)
59 : FiniteElementData<dim>(fe_data)
63 std::make_pair(std::make_pair(0U, 0U), 0U))
64 ,
65
66 // Special handling of vectors of length one: in this case, we
67 // assume that all entries were supposed to be equal
69 r_i_a_f.size() == 1 ?
70 std::vector<bool>(fe_data.n_dofs_per_cell(), r_i_a_f[0]) :
71 r_i_a_f)
73 nonzero_c.size() == 1 ?
74 std::vector<ComponentMask>(fe_data.n_dofs_per_cell(), nonzero_c[0]) :
75 nonzero_c)
79 [](const unsigned int n_components) {
80 return n_components != 1U;
81 }) == n_nonzero_components_table.end())
82{
83 Assert(restriction_is_additive_flags.size() == this->n_dofs_per_cell(),
84 ExcDimensionMismatch(restriction_is_additive_flags.size(),
85 this->n_dofs_per_cell()));
86 AssertDimension(nonzero_components.size(), this->n_dofs_per_cell());
87 for (unsigned int i = 0; i < nonzero_components.size(); ++i)
88 {
89 Assert(nonzero_components[i].size() == this->n_components(),
91 Assert(nonzero_components[i].n_selected_components() >= 1,
93 Assert(n_nonzero_components_table[i] >= 1, ExcInternalError());
94 Assert(n_nonzero_components_table[i] <= this->n_components(),
96 }
97
98 // initialize some tables in the default way, i.e. if there is only one
99 // (vector-)component; if the element is not primitive, leave these tables
100 // empty.
101 if (this->is_primitive())
102 {
103 system_to_component_table.resize(this->n_dofs_per_cell());
104 for (unsigned int j = 0; j < this->n_dofs_per_cell(); ++j)
105 system_to_component_table[j] = std::pair<unsigned, unsigned>(0, j);
106
107 face_system_to_component_table.resize(this->n_unique_faces());
108 for (unsigned int f = 0; f < this->n_unique_faces(); ++f)
109 {
110 face_system_to_component_table[f].resize(this->n_dofs_per_face(f));
111 for (unsigned int j = 0; j < this->n_dofs_per_face(f); ++j)
112 face_system_to_component_table[f][j] =
113 std::pair<unsigned, unsigned>(0, j);
114 }
115 }
116
117 for (unsigned int j = 0; j < this->n_dofs_per_cell(); ++j)
118 system_to_base_table[j] = std::make_pair(std::make_pair(0U, 0U), j);
119
120 face_system_to_base_table.resize(this->n_unique_faces());
121 for (unsigned int f = 0; f < this->n_unique_faces(); ++f)
122 {
123 face_system_to_base_table[f].resize(this->n_dofs_per_face(f));
124 for (unsigned int j = 0; j < this->n_dofs_per_face(f); ++j)
125 face_system_to_base_table[f][j] =
126 std::make_pair(std::make_pair(0U, 0U), j);
127 }
128
129 // Fill with default value; may be changed by constructor of derived class.
130 base_to_block_indices.reinit(1, 1);
131
132 // initialize the restriction and prolongation matrices. the default
133 // constructor of FullMatrix<dim> initializes them with size zero
136 for (const unsigned int ref_case :
137 RefinementCase<dim>::all_refinement_cases())
138 if (ref_case != RefinementCase<dim>::no_refinement)
139 {
140 prolongation[ref_case - 1].resize(this->reference_cell().n_children(
141 RefinementCase<dim>(ref_case)),
143 restriction[ref_case - 1].resize(this->reference_cell().n_children(
144 RefinementCase<dim>(ref_case)),
146 }
147
148
149 if (dim == 3)
150 {
151 adjust_quad_dof_index_for_face_orientation_table.resize(
152 this->n_unique_2d_subobjects());
153
154 for (unsigned int f = 0; f < this->n_unique_2d_subobjects(); ++f)
155 {
156 adjust_quad_dof_index_for_face_orientation_table[f] =
157 Table<2, int>(this->n_dofs_per_quad(f),
158 this->reference_cell().n_face_orientations(f));
159 adjust_quad_dof_index_for_face_orientation_table[f].fill(0);
160 }
161 }
162
163 unit_face_support_points.resize(this->n_unique_faces());
164 generalized_face_support_points.resize(this->n_unique_faces());
165}
166
167
168
169template <int dim, int spacedim>
170std::pair<std::unique_ptr<FiniteElement<dim, spacedim>>, unsigned int>
171FiniteElement<dim, spacedim>::operator^(const unsigned int multiplicity) const
172{
173 return {this->clone(), multiplicity};
174}
175
176
177
178template <int dim, int spacedim>
179double
181 const Point<dim> &) const
182{
183 AssertThrow(false, ExcUnitShapeValuesDoNotExist());
184 return 0.;
185}
186
187
188
189template <int dim, int spacedim>
190double
192 const Point<dim> &,
193 const unsigned int) const
194{
195 AssertThrow(false, ExcUnitShapeValuesDoNotExist());
196 return 0.;
197}
198
199
200
201template <int dim, int spacedim>
204 const Point<dim> &) const
205{
206 AssertThrow(false, ExcUnitShapeValuesDoNotExist());
207 return Tensor<1, dim>();
208}
209
210
211
212template <int dim, int spacedim>
215 const Point<dim> &,
216 const unsigned int) const
217{
218 AssertThrow(false, ExcUnitShapeValuesDoNotExist());
219 return Tensor<1, dim>();
220}
221
222
223
224template <int dim, int spacedim>
227 const Point<dim> &) const
228{
229 AssertThrow(false, ExcUnitShapeValuesDoNotExist());
230 return Tensor<2, dim>();
231}
232
233
234
235template <int dim, int spacedim>
238 const unsigned int,
239 const Point<dim> &,
240 const unsigned int) const
241{
242 AssertThrow(false, ExcUnitShapeValuesDoNotExist());
243 return Tensor<2, dim>();
244}
245
246
247
248template <int dim, int spacedim>
251 const Point<dim> &) const
252{
253 AssertThrow(false, ExcUnitShapeValuesDoNotExist());
254 return Tensor<3, dim>();
255}
256
257
258
259template <int dim, int spacedim>
262 const unsigned int,
263 const Point<dim> &,
264 const unsigned int) const
265{
266 AssertThrow(false, ExcUnitShapeValuesDoNotExist());
267 return Tensor<3, dim>();
268}
269
270
271
272template <int dim, int spacedim>
275 const Point<dim> &) const
276{
277 AssertThrow(false, ExcUnitShapeValuesDoNotExist());
278 return Tensor<4, dim>();
279}
280
281
282
283template <int dim, int spacedim>
286 const unsigned int,
287 const Point<dim> &,
288 const unsigned int) const
289{
290 AssertThrow(false, ExcUnitShapeValuesDoNotExist());
291 return Tensor<4, dim>();
292}
293
294
295template <int dim, int spacedim>
296void
298 const bool isotropic_restriction_only,
299 const bool isotropic_prolongation_only)
300{
301 for (const unsigned int ref_case :
302 RefinementCase<dim>::all_refinement_cases())
303 if (ref_case != RefinementCase<dim>::no_refinement)
304 {
305 const unsigned int nc =
306 this->reference_cell().n_children(RefinementCase<dim>(ref_case));
307
308 for (unsigned int i = 0; i < nc; ++i)
309 {
310 if (this->restriction[ref_case - 1][i].m() !=
311 this->n_dofs_per_cell() &&
312 (!isotropic_restriction_only ||
314 this->restriction[ref_case - 1][i].reinit(
315 this->n_dofs_per_cell(), this->n_dofs_per_cell());
316 if (this->prolongation[ref_case - 1][i].m() !=
317 this->n_dofs_per_cell() &&
318 (!isotropic_prolongation_only ||
320 this->prolongation[ref_case - 1][i].reinit(
321 this->n_dofs_per_cell(), this->n_dofs_per_cell());
322 }
323 }
324}
325
326
327template <int dim, int spacedim>
328const FullMatrix<double> &
330 const unsigned int child,
331 const RefinementCase<dim> &refinement_case) const
332{
333 AssertIndexRange(refinement_case,
337 "Restriction matrices are only available for refined cells!"));
338 AssertIndexRange(child,
339 this->reference_cell().n_children(
340 RefinementCase<dim>(refinement_case)));
341 // we use refinement_case-1 here. the -1 takes care of the origin of the
342 // vector, as for RefinementCase<dim>::no_refinement (=0) there is no data
343 // available and so the vector indices are shifted
344 Assert(restriction[refinement_case - 1][child].n() == this->n_dofs_per_cell(),
345 ExcProjectionVoid());
346 return restriction[refinement_case - 1][child];
347}
348
349
350
351template <int dim, int spacedim>
352const FullMatrix<double> &
354 const unsigned int child,
355 const RefinementCase<dim> &refinement_case) const
356{
357 AssertIndexRange(refinement_case,
361 "Prolongation matrices are only available for refined cells!"));
362 AssertIndexRange(child,
363 this->reference_cell().n_children(
364 RefinementCase<dim>(refinement_case)));
365 // we use refinement_case-1 here. the -1 takes care
366 // of the origin of the vector, as for
367 // RefinementCase::no_refinement (=0) there is no
368 // data available and so the vector indices
369 // are shifted
370 Assert(prolongation[refinement_case - 1][child].n() ==
371 this->n_dofs_per_cell(),
372 ExcEmbeddingVoid());
373 return prolongation[refinement_case - 1][child];
374}
375
376
377// TODO:[GK] This is probably not the most efficient way of doing this.
378template <int dim, int spacedim>
379unsigned int
381 const unsigned int index) const
382{
383 AssertIndexRange(index, this->n_components());
384
385 return first_block_of_base(component_to_base_table[index].first.first) +
386 component_to_base_table[index].second;
387}
388
389
390template <int dim, int spacedim>
393 const FEValuesExtractors::Scalar &scalar) const
394{
395 AssertIndexRange(scalar.component, this->n_components());
396
397 // TODO: it would be nice to verify that it is indeed possible
398 // to select this scalar component, i.e., that it is not part
399 // of a non-primitive element. unfortunately, there is no simple
400 // way to write such a condition...
401
402 std::vector<bool> mask(this->n_components(), false);
403 mask[scalar.component] = true;
404 return ComponentMask(mask);
405}
406
407
408template <int dim, int spacedim>
411 const FEValuesExtractors::Vector &vector) const
412{
414 this->n_components());
415
416 // TODO: it would be nice to verify that it is indeed possible
417 // to select these vector components, i.e., that they don't span
418 // beyond the beginning or end of anon-primitive element.
419 // unfortunately, there is no simple way to write such a condition...
420
421 std::vector<bool> mask(this->n_components(), false);
422 for (unsigned int c = vector.first_vector_component;
423 c < vector.first_vector_component + dim;
424 ++c)
425 mask[c] = true;
426 return ComponentMask(mask);
427}
428
429
430template <int dim, int spacedim>
433 const FEValuesExtractors::SymmetricTensor<2> &sym_tensor) const
434{
437 this->n_components());
438
439 // TODO: it would be nice to verify that it is indeed possible
440 // to select these vector components, i.e., that they don't span
441 // beyond the beginning or end of anon-primitive element.
442 // unfortunately, there is no simple way to write such a condition...
443
444 std::vector<bool> mask(this->n_components(), false);
445 for (unsigned int c = sym_tensor.first_tensor_component;
446 c < sym_tensor.first_tensor_component +
448 ++c)
449 mask[c] = true;
450 return ComponentMask(mask);
451}
452
453
454
455template <int dim, int spacedim>
458{
459 // if we get a block mask that represents all blocks, then
460 // do the same for the returned component mask
461 if (block_mask.represents_the_all_selected_mask())
462 return {};
463
464 AssertDimension(block_mask.size(), this->n_blocks());
465
466 std::vector<bool> component_mask(this->n_components(), false);
467 for (unsigned int c = 0; c < this->n_components(); ++c)
468 if (block_mask[component_to_block_index(c)] == true)
469 component_mask[c] = true;
470
471 return ComponentMask(component_mask);
472}
473
474
475
476template <int dim, int spacedim>
479 const FEValuesExtractors::Scalar &scalar) const
480{
481 // simply create the corresponding component mask (a simpler
482 // process) and then convert it to a block mask
483 return block_mask(component_mask(scalar));
484}
485
486
487template <int dim, int spacedim>
490 const FEValuesExtractors::Vector &vector) const
491{
492 // simply create the corresponding component mask (a simpler
493 // process) and then convert it to a block mask
494 return block_mask(component_mask(vector));
495}
496
497
498template <int dim, int spacedim>
501 const FEValuesExtractors::SymmetricTensor<2> &sym_tensor) const
502{
503 // simply create the corresponding component mask (a simpler
504 // process) and then convert it to a block mask
505 return block_mask(component_mask(sym_tensor));
506}
507
508
509
510template <int dim, int spacedim>
513 const ComponentMask &component_mask) const
514{
515 // if we get a component mask that represents all component, then
516 // do the same for the returned block mask
517 if (component_mask.represents_the_all_selected_mask())
518 return {};
519
520 AssertDimension(component_mask.size(), this->n_components());
521
522 // walk over all of the components
523 // of this finite element and see
524 // if we need to set the
525 // corresponding block. inside the
526 // block, walk over all the
527 // components that correspond to
528 // this block and make sure the
529 // component mask is set for all of
530 // them
531 std::vector<bool> block_mask(this->n_blocks(), false);
532 for (unsigned int c = 0; c < this->n_components();)
533 {
534 const unsigned int block = component_to_block_index(c);
535 if (component_mask[c] == true)
536 block_mask[block] = true;
537
538 // now check all of the other
539 // components that correspond
540 // to this block
541 ++c;
542 while ((c < this->n_components()) &&
543 (component_to_block_index(c) == block))
544 {
545 Assert(component_mask[c] == block_mask[block],
547 "The component mask argument given to this function "
548 "is not a mask where the individual components belonging "
549 "to one block of the finite element are either all "
550 "selected or not selected. You can't call this function "
551 "with a component mask that splits blocks."));
552 ++c;
553 }
554 }
555
556
557 return BlockMask(block_mask);
558}
559
560
561
562template <int dim, int spacedim>
563unsigned int
565 const unsigned int face_index,
566 const unsigned int face,
567 const types::geometric_orientation combined_orientation) const
568{
569 AssertIndexRange(face_index, this->n_dofs_per_face(face));
570 AssertIndexRange(face, this->reference_cell().n_faces());
571
572 // see the function's documentation for an explanation of this
573 // assertion -- in essence, derived classes have to implement
574 // an overloaded version of this function if we are to use any
575 // other than default (standard) orientation
576 if (combined_orientation != numbers::default_geometric_orientation)
577 Assert((this->n_dofs_per_line() <= 1) && (this->n_dofs_per_quad(face) <= 1),
579 "The function in this base class can not handle this case. "
580 "Rather, the derived class you are using must provide "
581 "an overloaded version but apparently hasn't done so. See "
582 "the documentation of this function for more information."));
583
584 // we need to distinguish between DoFs on vertices, lines and (in 3d) quads.
585 // do so in a sequence of if-else statements
586 if (face_index < this->get_first_face_line_index(face))
587 // DoF is on a vertex
588 {
589 // get the number of the vertex on the face that corresponds to this DoF,
590 // along with the number of the DoF on this vertex
591 const unsigned int face_vertex = face_index / this->n_dofs_per_vertex();
592 const unsigned int dof_index_on_vertex =
593 face_index % this->n_dofs_per_vertex();
594
595 // then get the number of this vertex on the cell and translate
596 // this to a DoF number on the cell
597 return (this->reference_cell().face_to_cell_vertices(
598 face, face_vertex, combined_orientation) *
599 this->n_dofs_per_vertex() +
600 dof_index_on_vertex);
601 }
602 else if (face_index < this->get_first_face_quad_index(face))
603 // DoF is on a face
604 {
605 // do the same kind of translation as before. we need to only consider
606 // DoFs on the lines, i.e., ignoring those on the vertices
607 const unsigned int index =
608 face_index - this->get_first_face_line_index(face);
609
610 const unsigned int face_line = index / this->n_dofs_per_line();
611 const unsigned int dof_index_on_line = index % this->n_dofs_per_line();
612
613 return (this->get_first_line_index() +
614 this->reference_cell().face_to_cell_lines(face,
615 face_line,
616 combined_orientation) *
617 this->n_dofs_per_line() +
618 dof_index_on_line);
619 }
620 else
621 // DoF is on a quad
622 {
623 Assert(dim >= 3, ExcInternalError());
624
625 // ignore vertex and line dofs
626 const unsigned int index =
627 face_index - this->get_first_face_quad_index(face);
628
629 return (this->get_first_quad_index(face) + index);
630 }
631}
632
633
634
635template <int dim, int spacedim>
636bool
638{
639 for (const unsigned int ref_case :
640 RefinementCase<dim>::all_refinement_cases())
641 if (ref_case != RefinementCase<dim>::no_refinement)
642 for (unsigned int c = 0;
643 c < this->reference_cell().n_children(RefinementCase<dim>(ref_case));
644 ++c)
645 {
646 // make sure also the lazily initialized matrices are created
647 get_prolongation_matrix(c, RefinementCase<dim>(ref_case));
648 Assert((prolongation[ref_case - 1][c].m() ==
649 this->n_dofs_per_cell()) ||
650 (prolongation[ref_case - 1][c].m() == 0),
652 Assert((prolongation[ref_case - 1][c].n() ==
653 this->n_dofs_per_cell()) ||
654 (prolongation[ref_case - 1][c].n() == 0),
656 if ((prolongation[ref_case - 1][c].m() == 0) ||
657 (prolongation[ref_case - 1][c].n() == 0))
658 return false;
659 }
660 return true;
661}
662
663
664
665template <int dim, int spacedim>
666bool
668{
669 for (const unsigned int ref_case :
670 RefinementCase<dim>::all_refinement_cases())
671 if (ref_case != RefinementCase<dim>::no_refinement)
672 for (unsigned int c = 0;
673 c < this->reference_cell().n_children(RefinementCase<dim>(ref_case));
674 ++c)
675 {
676 // make sure also the lazily initialized matrices are created
677 get_restriction_matrix(c, RefinementCase<dim>(ref_case));
678 Assert((restriction[ref_case - 1][c].m() ==
679 this->n_dofs_per_cell()) ||
680 (restriction[ref_case - 1][c].m() == 0),
682 Assert((restriction[ref_case - 1][c].n() ==
683 this->n_dofs_per_cell()) ||
684 (restriction[ref_case - 1][c].n() == 0),
686 if ((restriction[ref_case - 1][c].m() == 0) ||
687 (restriction[ref_case - 1][c].n() == 0))
688 return false;
689 }
690 return true;
691}
692
693
694
695template <int dim, int spacedim>
696bool
698{
699 const RefinementCase<dim> ref_case =
701
702 for (unsigned int c = 0;
703 c < this->reference_cell().n_children(RefinementCase<dim>(ref_case));
704 ++c)
705 {
706 // make sure also the lazily initialized matrices are created
707 get_prolongation_matrix(c, RefinementCase<dim>(ref_case));
708 Assert((prolongation[ref_case - 1][c].m() == this->n_dofs_per_cell()) ||
709 (prolongation[ref_case - 1][c].m() == 0),
711 Assert((prolongation[ref_case - 1][c].n() == this->n_dofs_per_cell()) ||
712 (prolongation[ref_case - 1][c].n() == 0),
714 if ((prolongation[ref_case - 1][c].m() == 0) ||
715 (prolongation[ref_case - 1][c].n() == 0))
716 return false;
717 }
718 return true;
719}
720
721
722
723template <int dim, int spacedim>
724bool
726{
727 const RefinementCase<dim> ref_case =
729
730 for (unsigned int c = 0;
731 c < this->reference_cell().n_children(RefinementCase<dim>(ref_case));
732 ++c)
733 {
734 // make sure also the lazily initialized matrices are created
735 get_restriction_matrix(c, RefinementCase<dim>(ref_case));
736 Assert((restriction[ref_case - 1][c].m() == this->n_dofs_per_cell()) ||
737 (restriction[ref_case - 1][c].m() == 0),
739 Assert((restriction[ref_case - 1][c].n() == this->n_dofs_per_cell()) ||
740 (restriction[ref_case - 1][c].n() == 0),
742 if ((restriction[ref_case - 1][c].m() == 0) ||
743 (restriction[ref_case - 1][c].n() == 0))
744 return false;
745 }
746 return true;
747}
748
749
750
751template <int dim, int spacedim>
752bool
754 const internal::SubfaceCase<dim> &subface_case) const
755{
757 {
758 unsigned int n_dofs_on_faces = 0;
759
760 for (const auto face_no : this->reference_cell().face_indices())
761 n_dofs_on_faces += this->n_dofs_per_face(face_no);
762
763 return (n_dofs_on_faces == 0) || (interface_constraints.m() != 0);
764 }
765 else
766 return false;
767}
768
769
770
771template <int dim, int spacedim>
772bool
774{
775 return false;
776}
777
778
779
780template <int dim, int spacedim>
781const FullMatrix<double> &
783 const internal::SubfaceCase<dim> &subface_case) const
784{
785 // TODO: the implementation makes the assumption that all faces have the
786 // same number of dofs
787 AssertDimension(this->n_unique_faces(), 1);
788 const unsigned int face_no = 0;
789
791 ExcMessage("Constraints for this element are only implemented "
792 "for the case that faces are refined isotropically "
793 "(which is always the case in 2d, and in 3d requires "
794 "that the neighboring cell of a coarse cell presents "
795 "exactly four children on the common face)."));
796 Assert((this->n_dofs_per_face(face_no) == 0) ||
797 (interface_constraints.m() != 0),
798 ExcMessage("The finite element for which you try to obtain "
799 "hanging node constraints does not appear to "
800 "implement them."));
801
802 if (dim == 1)
803 Assert((interface_constraints.m() == 0) && (interface_constraints.n() == 0),
804 ExcWrongInterfaceMatrixSize(interface_constraints.m(),
805 interface_constraints.n()));
806
807 return interface_constraints;
808}
809
810
811
812template <int dim, int spacedim>
815{
816 // TODO: the implementation makes the assumption that all faces have the
817 // same number of dofs
818 AssertDimension(this->n_unique_faces(), 1);
819 const unsigned int face_no = 0;
820
821 switch (dim)
822 {
823 case 1:
824 return {0U, 0U};
825
826 case 2:
827 // We have to interpolate from the DoFs in the interior of the
828 // the two child faces (=lines) and the one central vertex
829 // to the DoFs of the parent face:
830 return {this->n_dofs_per_vertex() + 2 * this->n_dofs_per_line(),
831 this->n_dofs_per_face(face_no)};
832
833 case 3:
834 // We have to interpolate from the DoFs in the interior of the
835 // the child faces (=quads or tris) and the vertices that are
836 // not part of the parent face, to the DoFs of the parent face:
837 if (this->reference_cell().face_reference_cell(face_no) ==
839 return {
840 5 * this->n_dofs_per_vertex() + // 4 vertices at mid-edge points
841 // + 1 at cell center
842 12 * this->n_dofs_per_line() + // 4*2 children of the old edges
843 // + 2*2 edges in the cell interior
844 4 * this->n_dofs_per_quad(face_no), // 4 child faces
845 this->n_dofs_per_face(face_no)};
846 else if (this->reference_cell().face_reference_cell(face_no) ==
848 return {
849 3 * this->n_dofs_per_vertex() + // 3 vertices at mid-edge points
850 9 * this->n_dofs_per_line() + // 3*2 children of the old edges
851 // + 3 edges in the cell interior
852 4 * this->n_dofs_per_quad(face_no), // 4 child faces
853 this->n_dofs_per_face(face_no)};
854 else
856
857 default:
859 }
861}
862
863
864
865template <int dim, int spacedim>
866void
869 FullMatrix<double> &) const
870{
871 // by default, no interpolation
872 // implemented. so throw exception,
873 // as documentation says
875 false,
877}
878
879
880
881template <int dim, int spacedim>
882void
886 const unsigned int) const
887{
888 // by default, no interpolation
889 // implemented. so throw exception,
890 // as documentation says
892 false,
894}
895
896
897
898template <int dim, int spacedim>
899void
902 const unsigned int,
904 const unsigned int) const
905{
906 // by default, no interpolation
907 // implemented. so throw exception,
908 // as documentation says
910 false,
912}
913
914
915
916template <int dim, int spacedim>
917std::vector<std::pair<unsigned int, unsigned int>>
919 const FiniteElement<dim, spacedim> &) const
920{
922 return std::vector<std::pair<unsigned int, unsigned int>>();
923}
924
925
926
927template <int dim, int spacedim>
928std::vector<std::pair<unsigned int, unsigned int>>
930 const FiniteElement<dim, spacedim> &) const
931{
933 return std::vector<std::pair<unsigned int, unsigned int>>();
934}
935
936
937
938template <int dim, int spacedim>
939std::vector<std::pair<unsigned int, unsigned int>>
942 const unsigned int) const
943{
945 return std::vector<std::pair<unsigned int, unsigned int>>();
946}
947
948
949
950template <int dim, int spacedim>
954 const unsigned int) const
955{
958}
959
960
961
962template <int dim, int spacedim>
963bool
965 const FiniteElement<dim, spacedim> &f) const
966{
967 // Compare fields in roughly increasing order of how expensive the
968 // comparison is
969 return ((typeid(*this) == typeid(f)) && (this->get_name() == f.get_name()) &&
970 (static_cast<const FiniteElementData<dim> &>(*this) ==
971 static_cast<const FiniteElementData<dim> &>(f)) &&
972 (interface_constraints == f.interface_constraints));
973}
974
975
976
977template <int dim, int spacedim>
978bool
980 const FiniteElement<dim, spacedim> &f) const
981{
982 return !(*this == f);
983}
984
985
986
987template <int dim, int spacedim>
988const std::vector<Point<dim>> &
990{
991 // a finite element may define
992 // support points, but only if
993 // there are as many as there are
994 // degrees of freedom
995 Assert((unit_support_points.empty()) ||
996 (unit_support_points.size() == this->n_dofs_per_cell()),
998 return unit_support_points;
999}
1000
1001
1002
1003template <int dim, int spacedim>
1004bool
1006{
1007 if (this->dofs_per_cell > 0)
1008 return (unit_support_points.size() != 0);
1009 else
1010 {
1011 // If the FE has no DoFs, we shouldn't expect the array
1012 // size to be anything other than zero:
1014
1015 // A finite element without DoFs *has* support points
1016 // (which is then an empty array)
1017 return true;
1018 }
1019}
1020
1021
1022
1023template <int dim, int spacedim>
1024const std::vector<Point<dim>> &
1026{
1027 // If the finite element implements generalized support points, return
1028 // those. Otherwise fall back to unit support points.
1029 return ((generalized_support_points.empty()) ? unit_support_points :
1030 generalized_support_points);
1031}
1032
1033
1034
1035template <int dim, int spacedim>
1036bool
1038{
1039 if (this->dofs_per_cell > 0)
1040 return (get_generalized_support_points().size() != 0);
1041 else
1042 {
1043 // If the FE has no DoFs, the array size should be zero:
1044 AssertDimension(get_generalized_support_points().size(), 0);
1045
1046 // A finite element without DoFs *has* generalized support points
1047 // (which is then an empty array)
1048 return true;
1049 }
1050}
1051
1052
1053
1054template <int dim, int spacedim>
1056FiniteElement<dim, spacedim>::unit_support_point(const unsigned int index) const
1057{
1058 AssertIndexRange(index, this->n_dofs_per_cell());
1059 Assert(unit_support_points.size() == this->n_dofs_per_cell(),
1060 ExcFEHasNoSupportPoints());
1061 return unit_support_points[index];
1062}
1063
1064
1065
1066template <int dim, int spacedim>
1067const std::vector<Point<dim - 1>> &
1069 const unsigned int face_no) const
1070{
1071 // a finite element may define
1072 // support points, but only if
1073 // there are as many as there are
1074 // degrees of freedom on a face
1075 Assert((unit_face_support_points[this->n_unique_faces() == 1 ? 0 : face_no]
1076 .empty()) ||
1077 (unit_face_support_points[this->n_unique_faces() == 1 ? 0 : face_no]
1078 .size() == this->n_dofs_per_face(face_no)),
1080 return unit_face_support_points[this->n_unique_faces() == 1 ? 0 : face_no];
1081}
1082
1083
1084
1085template <int dim, int spacedim>
1086bool
1088 const unsigned int face_no) const
1089{
1090 const unsigned int face_index = this->n_unique_faces() == 1 ? 0 : face_no;
1091 if (this->n_dofs_per_face(face_index) > 0)
1092 return (unit_face_support_points[face_index].size() != 0);
1093 else
1094 {
1095 // If the FE has no DoFs on face, the array size should be zero
1096 AssertDimension(unit_face_support_points[face_index].size(), 0);
1097
1098 // A finite element without DoFs *has* face support points
1099 // (which is then an empty array)
1100 return true;
1101 }
1102}
1103
1104
1105
1106template <int dim, int spacedim>
1107Point<dim - 1>
1109 const unsigned int index,
1110 const unsigned int face_no) const
1111{
1112 AssertIndexRange(index, this->n_dofs_per_face(face_no));
1113 Assert(unit_face_support_points[this->n_unique_faces() == 1 ? 0 : face_no]
1114 .size() == this->n_dofs_per_face(face_no),
1115 ExcFEHasNoSupportPoints());
1116 return unit_face_support_points[this->n_unique_faces() == 1 ? 0 : face_no]
1117 [index];
1118}
1119
1120
1121
1122template <int dim, int spacedim>
1123bool
1125 const unsigned int) const
1126{
1127 return true;
1128}
1129
1130
1131
1132template <int dim, int spacedim>
1135{
1136 // Translate the ComponentMask into first_selected and n_components after
1137 // some error checking:
1138 const unsigned int n_total_components = this->n_components();
1139 Assert((n_total_components == mask.size()) || (mask.size() == 0),
1140 ExcMessage("The given ComponentMask has the wrong size."));
1141
1142 const unsigned int n_selected =
1143 mask.n_selected_components(n_total_components);
1144 Assert(n_selected > 0,
1145 ExcMessage("You need at least one selected component."));
1146
1147 const unsigned int first_selected =
1148 mask.first_selected_component(n_total_components);
1149
1150 if constexpr (running_in_debug_mode())
1151 {
1152 // check that it is contiguous:
1153 for (unsigned int c = 0; c < n_total_components; ++c)
1154 Assert((c < first_selected && (!mask[c])) ||
1155 (c >= first_selected && c < first_selected + n_selected &&
1156 mask[c]) ||
1157 (c >= first_selected + n_selected && !mask[c]),
1158 ExcMessage(
1159 "The given ComponentMask is not contiguous, but "
1160 "any sub-element of the current element must "
1161 "necessarily occupy a contiguous set of components."));
1162 }
1163
1164 return get_sub_fe(first_selected, n_selected);
1165}
1166
1167
1168
1169template <int dim, int spacedim>
1172 const unsigned int first_component,
1173 const unsigned int n_selected_components) const
1174{
1175 // No complicated logic is needed here, because it is overridden in
1176 // FESystem<dim,spacedim>. Just make sure that what the user chose is valid:
1177 Assert(first_component == 0 && n_selected_components == this->n_components(),
1178 ExcMessage(
1179 "You can only select a whole FiniteElement, not a part of one."));
1180
1181 return *this;
1182}
1183
1184
1185
1186template <int dim, int spacedim>
1187std::pair<Table<2, bool>, std::vector<unsigned int>>
1189{
1191 return std::pair<Table<2, bool>, std::vector<unsigned int>>(
1192 Table<2, bool>(this->n_components(), this->n_dofs_per_cell()),
1193 std::vector<unsigned int>(this->n_components()));
1194}
1195
1196
1197
1198template <int dim, int spacedim>
1199void
1202 const std::vector<Vector<double>> &,
1203 std::vector<double> &) const
1204{
1205 Assert(has_generalized_support_points(),
1206 ExcMessage("The element for which you are calling the current "
1207 "function does not have generalized support points (see "
1208 "the glossary for a definition of generalized support "
1209 "points). Consequently, the current function can not "
1210 "be defined and is not implemented by the element."));
1212}
1213
1214
1215
1216template <int dim, int spacedim>
1217std::size_t
1219{
1220 return (
1221 sizeof(FiniteElementData<dim>) +
1224 MemoryConsumption::memory_consumption(interface_constraints) +
1225 MemoryConsumption::memory_consumption(system_to_component_table) +
1226 MemoryConsumption::memory_consumption(face_system_to_component_table) +
1227 MemoryConsumption::memory_consumption(system_to_base_table) +
1228 MemoryConsumption::memory_consumption(face_system_to_base_table) +
1229 MemoryConsumption::memory_consumption(component_to_base_table) +
1230 MemoryConsumption::memory_consumption(restriction_is_additive_flags) +
1231 MemoryConsumption::memory_consumption(nonzero_components) +
1232 MemoryConsumption::memory_consumption(n_nonzero_components_table));
1233}
1234
1235
1236
1237template <int dim, int spacedim>
1238std::vector<unsigned int>
1240 const std::vector<ComponentMask> &nonzero_components)
1241{
1242 std::vector<unsigned int> retval(nonzero_components.size());
1243 for (unsigned int i = 0; i < nonzero_components.size(); ++i)
1244 retval[i] = nonzero_components[i].n_selected_components();
1245 return retval;
1246}
1247
1248
1249
1250/*------------------------------- FiniteElement ----------------------*/
1251
1252# ifndef DOXYGEN
1253template <int dim, int spacedim>
1254std::unique_ptr<typename FiniteElement<dim, spacedim>::InternalDataBase>
1256 const UpdateFlags flags,
1257 const Mapping<dim, spacedim> &mapping,
1258 const hp::QCollection<dim - 1> &quadrature,
1260 spacedim>
1261 &output_data) const
1262{
1263 return get_data(flags,
1264 mapping,
1266 quadrature),
1267 output_data);
1268}
1269
1270
1271
1272template <int dim, int spacedim>
1273std::unique_ptr<typename FiniteElement<dim, spacedim>::InternalDataBase>
1275 const UpdateFlags flags,
1276 const Mapping<dim, spacedim> &mapping,
1277 const Quadrature<dim - 1> &quadrature,
1279 spacedim>
1280 &output_data) const
1281{
1282 return get_data(flags,
1283 mapping,
1285 quadrature),
1286 output_data);
1287}
1288
1289
1290
1291template <int dim, int spacedim>
1292void
1295 const unsigned int face_no,
1296 const hp::QCollection<dim - 1> &quadrature,
1297 const Mapping<dim, spacedim> &mapping,
1298 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal,
1300 &mapping_data,
1301 const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
1303 spacedim>
1304 &output_data) const
1305{
1306 // base class version, implement overridden function in derived classes
1307 AssertDimension(quadrature.size(), 1);
1308 fill_fe_face_values(cell,
1309 face_no,
1310 quadrature[0],
1311 mapping,
1312 mapping_internal,
1313 mapping_data,
1314 fe_internal,
1315 output_data);
1316}
1317
1318
1319
1320template <int dim, int spacedim>
1321void
1323 const typename Triangulation<dim, spacedim>::cell_iterator & /* cell */,
1324 const unsigned int /* face_no */,
1325 const Quadrature<dim - 1> & /* quadrature */,
1326 const Mapping<dim, spacedim> & /* mapping */,
1328 & /* mapping_internal */,
1330 & /* mapping_data */,
1332 & /* fe_internal */,
1334 spacedim>
1335 & /* output_data */) const
1336{
1337 Assert(false,
1338 ExcMessage("Use of a deprecated interface, please implement "
1339 "fill_fe_face_values taking a hp::QCollection argument"));
1340}
1341# endif
1342
1343
1344
1345template <int dim, int spacedim>
1346std::unique_ptr<typename FiniteElement<dim, spacedim>::InternalDataBase>
1348 const UpdateFlags flags,
1349 const Mapping<dim, spacedim> &mapping,
1350 const Quadrature<dim - 1> &quadrature,
1352 spacedim>
1353 &output_data) const
1354{
1355 return get_data(flags,
1356 mapping,
1358 this->reference_cell(), quadrature),
1359 output_data);
1360}
1361
1362
1363
1364template <int dim, int spacedim>
1366FiniteElement<dim, spacedim>::base_element(const unsigned int index) const
1367{
1368 AssertIndexRange(index, 1);
1369 // This function should not be
1370 // called for a system element
1371 Assert(base_to_block_indices.size() == 1, ExcInternalError());
1372 return *this;
1373}
1374
1375
1376#endif
1377/*------------------------------- Explicit Instantiations -------------*/
1378#include "fe/fe.inst"
1379
1380
*  iterator end()
*  *  for(const auto &cell :triangulation.active_cell_iterators())
*  *  iterator begin()
bool represents_the_all_selected_mask() const
unsigned int size() const
bool represents_the_all_selected_mask() const
unsigned int size() const
const unsigned int components
Definition fe_data.h:444
unsigned int n_dofs_per_cell() const
unsigned int n_dofs_per_line() const
unsigned int n_components() const
virtual std::size_t memory_consumption() const
bool constraints_are_implemented(const ::internal::SubfaceCase< dim > &subface_case=::internal::SubfaceCase< dim >::case_isotropic) const
bool isotropic_prolongation_is_implemented() const
virtual std::string get_name() const =0
virtual Point< dim > unit_support_point(const unsigned int index) const
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &fe_other, const unsigned int codim=0) const
const std::vector< unsigned int > n_nonzero_components_table
Definition fe.h:2731
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const
bool prolongation_is_implemented() const
virtual std::pair< Table< 2, bool >, std::vector< unsigned int > > get_constant_modes() const
virtual const FiniteElement< dim, spacedim > & base_element(const unsigned int index) const
virtual Tensor< 1, dim > shape_grad(const unsigned int i, const Point< dim > &p) const
virtual std::unique_ptr< InternalDataBase > get_face_data(const UpdateFlags update_flags, const Mapping< dim, spacedim > &mapping, const hp::QCollection< dim - 1 > &quadrature, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const
virtual Point< dim - 1 > unit_face_support_point(const unsigned int index, const unsigned int face_no=0) const
static std::vector< unsigned int > compute_n_nonzero_components(const std::vector< ComponentMask > &nonzero_components)
virtual std::unique_ptr< InternalDataBase > get_subface_data(const UpdateFlags update_flags, const Mapping< dim, spacedim > &mapping, const Quadrature< dim - 1 > &quadrature, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const
bool has_face_support_points(const unsigned int face_no=0) const
const bool cached_primitivity
Definition fe.h:2738
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
ComponentMask component_mask(const FEValuesExtractors::Scalar &scalar) const
bool operator!=(const FiniteElement< dim, spacedim > &) const
bool has_support_points() const
bool has_generalized_support_points() const
virtual Tensor< 2, dim > shape_grad_grad(const unsigned int i, const Point< dim > &p) const
virtual bool operator==(const FiniteElement< dim, spacedim > &fe) const
const std::vector< Point< dim > > & get_unit_support_points() const
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
void reinit_restriction_and_prolongation_matrices(const bool isotropic_restriction_only=false, const bool isotropic_prolongation_only=false)
const std::vector< Point< dim - 1 > > & get_unit_face_support_points(const unsigned int face_no=0) const
bool isotropic_restriction_is_implemented() const
std::vector< int > adjust_line_dof_index_for_line_orientation_table
Definition fe.h:2634
virtual bool has_support_on_face(const unsigned int shape_index, const unsigned int face_index) const
const FiniteElement< dim, spacedim > & get_sub_fe(const ComponentMask &mask) const
virtual Tensor< 4, dim > shape_4th_derivative_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
virtual double shape_value_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
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
unsigned int component_to_block_index(const unsigned int component) const
BlockMask block_mask(const FEValuesExtractors::Scalar &scalar) const
virtual void get_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix) const
virtual Tensor< 3, dim > shape_3rd_derivative(const unsigned int i, const Point< dim > &p) const
std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > system_to_base_table
Definition fe.h:2670
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const
virtual void convert_generalized_support_point_values_to_dof_values(const std::vector< Vector< double > > &support_point_values, std::vector< double > &nodal_values) const
FiniteElement(const FiniteElementData< dim > &fe_data, const std::vector< bool > &restriction_is_additive_flags, const std::vector< ComponentMask > &nonzero_components)
virtual Tensor< 3, dim > shape_3rd_derivative_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
const FullMatrix< double > & constraints(const ::internal::SubfaceCase< dim > &subface_case=::internal::SubfaceCase< dim >::case_isotropic) const
std::pair< std::unique_ptr< FiniteElement< dim, spacedim > >, unsigned int > operator^(const unsigned int multiplicity) const
const std::vector< bool > restriction_is_additive_flags
Definition fe.h:2713
virtual unsigned int face_to_cell_index(const unsigned int face_dof_index, const unsigned int face, const types::geometric_orientation combined_orientation=numbers::default_geometric_orientation) const
std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > component_to_base_table
Definition fe.h:2706
TableIndices< 2 > interface_constraints_size() const
virtual Tensor< 1, dim > shape_grad_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
bool restriction_is_implemented() const
FullMatrix< double > interface_constraints
Definition fe.h:2573
const std::vector< Point< dim > > & get_generalized_support_points() const
virtual Tensor< 2, dim > shape_grad_grad_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
virtual const FullMatrix< double > & get_prolongation_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const
virtual double shape_value(const unsigned int i, const Point< dim > &p) const
virtual void get_face_interpolation_matrix(const FiniteElement< dim, spacedim > &source, FullMatrix< double > &matrix, const unsigned int face_no=0) const
virtual std::size_t memory_consumption() const
virtual Tensor< 4, dim > shape_4th_derivative(const unsigned int i, const Point< dim > &p) const
const std::vector< ComponentMask > nonzero_components
Definition fe.h:2722
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const
virtual bool hp_constraints_are_implemented() const
Abstract base class for mapping classes.
Definition mapping.h:318
Definition point.h:111
Class which transforms dim - 1-dimensional quadrature rules to dim-dimensional face quadratures.
Definition qprojector.h:68
unsigned int size() const
Definition collection.h:314
#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_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
Point< 2 > first
Definition grid_out.cc:4639
#define Assert(cond, exc)
#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_default
No update.
std::size_t size
Definition mpi.cc:733
void reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell< dim > &reference_cell)
constexpr char U
std::enable_if_t< IsBlockVector< VectorType >::value, unsigned int > n_blocks(const VectorType &vector)
Definition operators.h:47
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
*  *  if(update_pressure &update_flags) *  compute_pressure(constitutive_request
*  *  *  *  std::vector< Number > ThermoPlasticMaterial< dim, ViscoplasticYieldLaw, Number >::get_state_parameters   const
constexpr ReferenceCell< 2 > Quadrilateral
constexpr ReferenceCell< 2 > Triangle
std::vector< Point< dim > > unit_support_points(const std::vector< Point< 1 > > &line_support_points, const std::vector< unsigned int > &renumbering)
constexpr unsigned int invalid_unsigned_int
Definition types.h:228
constexpr types::geometric_orientation default_geometric_orientation
Definition types.h:342
STL namespace.
std::uint8_t geometric_orientation
Definition types.h:38