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_hermite.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) 2023 - 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
13#include <deal.II/base/config.h>
14
17#include <deal.II/base/table.h>
19
21
22#include <deal.II/fe/fe_dgq.h>
23#include <deal.II/fe/fe_face.h>
27#include <deal.II/fe/fe_q.h>
30#include <deal.II/fe/fe_tools.h>
34
36
45#include <deal.II/lac/vector.h>
46
48
49#include <algorithm>
50#include <cmath>
51#include <iostream>
52#include <iterator>
53#include <memory>
54#include <sstream>
55
57
58
59
60namespace internal
61{
62 namespace
63 {
64 unsigned int
65 get_regularity_from_degree(const unsigned int fe_degree)
66 {
67 Assert(fe_degree % 2 == 1,
68 ExcMessage("FE_Hermite only supports odd polynomial degrees."));
69 return (fe_degree == 0) ? 0 : (fe_degree - 1) / 2;
70 }
71
72
73
74 std::vector<unsigned int>
75 get_hermite_dpo_vector(const unsigned int dim,
76 const unsigned int regularity)
77 {
78 std::vector<unsigned int> result(dim + 1, 0);
79 result[0] = Utilities::pow(regularity + 1, dim);
80
81 return result;
82 }
83
84
85
86 /*
87 * Renumbering function. Function needs different levels of for loop nesting
88 * for different values of dim, so different definitions are used for
89 * simplicity.
90 */
91 template <int dim>
92 void
93 hermite_hierarchic_to_lexicographic_numbering(
94 const unsigned int regularity,
95 std::vector<unsigned int> &h2l);
96
97
98
99 template <>
100 void
101 hermite_hierarchic_to_lexicographic_numbering<1>(
102 const unsigned int regularity,
103 std::vector<unsigned int> &h2l)
104 {
105 const unsigned int node_dofs_1d = regularity + 1;
106
107 AssertDimension(h2l.size(), 2 * node_dofs_1d);
108
109 // Assign DOFs at vertices
110 for (unsigned int di = 0; di < 2; ++di)
111 for (unsigned int i = 0; i < node_dofs_1d; ++i)
112 h2l[i + di * node_dofs_1d] = i + di * node_dofs_1d;
113 }
114
115
116
117 template <>
118 void
119 hermite_hierarchic_to_lexicographic_numbering<2>(
120 const unsigned int regularity,
121 std::vector<unsigned int> &h2l)
122 {
123 const unsigned int node_dofs_1d = regularity + 1;
124 const unsigned int dim_dofs_1d = 2 * node_dofs_1d;
125 unsigned int offset = 0;
126
127 AssertDimension(h2l.size(), dim_dofs_1d * dim_dofs_1d);
128
129 // Assign DOFs at vertices
130 for (unsigned int di = 0; di < 2; ++di)
131 for (unsigned int dj = 0; dj < 2; ++dj)
132 {
133 for (unsigned int i = 0; i < node_dofs_1d; ++i)
134 for (unsigned int j = 0; j < node_dofs_1d; ++j)
135 h2l[j + i * node_dofs_1d + offset] =
136 j + i * dim_dofs_1d + (dj + di * dim_dofs_1d) * node_dofs_1d;
137
138 offset += node_dofs_1d * node_dofs_1d;
139 }
140 }
141
142
143
144 template <>
145 void
146 hermite_hierarchic_to_lexicographic_numbering<3>(
147 const unsigned int regularity,
148 std::vector<unsigned int> &h2l)
149 {
150 const unsigned int node_dofs_1d = regularity + 1;
151 const unsigned int node_dofs_2d = node_dofs_1d * node_dofs_1d;
152
153 const unsigned int dim_dofs_1d = 2 * node_dofs_1d;
154 const unsigned int dim_dofs_2d = dim_dofs_1d * dim_dofs_1d;
155
156 unsigned int offset = 0;
157
158 AssertDimension(h2l.size(), dim_dofs_2d * dim_dofs_1d);
159
160 // Assign DOFs at nodes
161 for (unsigned int di = 0; di < 2; ++di)
162 for (unsigned int dj = 0; dj < 2; ++dj)
163 for (unsigned int dk = 0; dk < 2; ++dk)
164 {
165 for (unsigned int i = 0; i < node_dofs_1d; ++i)
166 for (unsigned int j = 0; j < node_dofs_1d; ++j)
167 for (unsigned int k = 0; k < node_dofs_1d; ++k)
168 h2l[k + j * node_dofs_1d + i * node_dofs_2d + offset] =
169 k + j * dim_dofs_1d + i * dim_dofs_2d +
170 node_dofs_1d * (dk + dj * dim_dofs_1d + di * dim_dofs_2d);
171
172 offset += node_dofs_1d * node_dofs_2d;
173 }
174 }
175
176
177
178 template <int dim>
179 std::vector<unsigned int>
180 hermite_hierarchic_to_lexicographic_numbering(const unsigned int regularity)
181 {
182 const std::vector<unsigned int> dpo =
183 get_hermite_dpo_vector(dim, regularity);
184 const ::FiniteElementData<dim> face_data(dpo,
185 1,
186 2 * regularity + 1);
187 std::vector<unsigned int> renumbering(face_data.dofs_per_cell);
188
189 hermite_hierarchic_to_lexicographic_numbering<dim>(regularity,
190 renumbering);
191
192 return renumbering;
193 }
194
195
196
197 template <int dim>
198 std::vector<unsigned int>
199 hermite_lexicographic_to_hierarchic_numbering(const unsigned int regularity)
200 {
202 hermite_hierarchic_to_lexicographic_numbering<dim>(regularity));
203 }
204
205
206
207 template <int dim>
209 get_hermite_polynomials(const unsigned int fe_degree)
210 {
211 const unsigned int regularity = get_regularity_from_degree(fe_degree);
212
213 TensorProductPolynomials<dim> polynomial_basis(
215
216 std::vector<unsigned int> renumber =
217 internal::hermite_hierarchic_to_lexicographic_numbering<dim>(
218 regularity);
219 polynomial_basis.set_numbering(renumber);
220
221 return polynomial_basis;
222 }
223
224
225
232 class Rescaler
233 {
234 public:
235 template <int spacedim, typename Number>
236 void
237 rescale_fe_hermite_values(
238 const FE_Hermite<1, spacedim> &fe_herm,
239 const typename Mapping<1, spacedim>::InternalDataBase &mapping_data,
240 Table<2, Number> &value_list)
241 {
242 double cell_extent = 1.0;
243
244 // Check mapping_data is associated with a compatible mapping class
245 if (dynamic_cast<const typename MappingCartesian<1>::InternalData *>(
246 &mapping_data) != nullptr)
247 {
249 dynamic_cast<const typename MappingCartesian<1>::InternalData *>(
250 &mapping_data);
251 cell_extent = data->cell_extents[0];
252 }
253 else
255
256 const unsigned int regularity = fe_herm.get_regularity();
257 const unsigned int n_dofs_per_cell = fe_herm.n_dofs_per_cell();
258 const unsigned int n_q_points_out = value_list.size(1);
259 (void)n_dofs_per_cell;
260
261 AssertDimension(value_list.size(0), n_dofs_per_cell);
262 AssertDimension(n_dofs_per_cell, 2 * regularity + 2);
263
264 std::vector<unsigned int> l2h =
265 internal::hermite_lexicographic_to_hierarchic_numbering<1>(
266 regularity);
267
268 for (unsigned int q = 0; q < n_q_points_out; ++q)
269 {
270 double factor_1 = 1.0;
271
272 for (unsigned int d1 = 0, d2 = regularity + 1; d2 < n_dofs_per_cell;
273 ++d1, ++d2)
274 {
275 /*
276 * d1 is used to count over indices on the left and d2 counts
277 * over indices on the right. These variables are used
278 * to avoid the need to loop over vertices.
279 */
280 value_list(l2h[d1], q) *= factor_1;
281 value_list(l2h[d2], q) *= factor_1;
282
283 factor_1 *= cell_extent;
284 }
285 }
286 }
287
288
289
290 template <int spacedim, typename Number>
291 void
292 rescale_fe_hermite_values(
293 const FE_Hermite<2, spacedim> &fe_herm,
294 const typename Mapping<2, spacedim>::InternalDataBase &mapping_data,
295 Table<2, Number> &value_list)
296 {
297 Tensor<1, 2> cell_extents;
298
299 // Check mapping_data is associated with a compatible mapping class
300 if (dynamic_cast<const typename MappingCartesian<2>::InternalData *>(
301 &mapping_data) != nullptr)
302 {
304 dynamic_cast<const typename MappingCartesian<2>::InternalData *>(
305 &mapping_data);
306 cell_extents = data->cell_extents;
307 }
308 else
310
311 const unsigned int regularity = fe_herm.get_regularity();
312 const unsigned int n_dofs_per_cell = fe_herm.n_dofs_per_cell();
313 const unsigned int n_dofs_per_dim = 2 * regularity + 2;
314 const unsigned int n_q_points_out = value_list.size(1);
315 (void)n_dofs_per_cell;
316
317 AssertDimension(value_list.size(0), n_dofs_per_cell);
318 AssertDimension(n_dofs_per_dim * n_dofs_per_dim, n_dofs_per_cell);
319
320 std::vector<unsigned int> l2h =
321 internal::hermite_lexicographic_to_hierarchic_numbering<2>(
322 regularity);
323
324 AssertDimension(l2h.size(), n_dofs_per_cell);
325
326 for (unsigned int q = 0; q < n_q_points_out; ++q)
327 {
328 double factor_2 = 1.0;
329
330 for (unsigned int d3 = 0, d4 = regularity + 1; d4 < n_dofs_per_dim;
331 ++d3, ++d4)
332 {
333 double factor_1 = factor_2;
334
335 for (unsigned int d1 = 0, d2 = regularity + 1;
336 d2 < n_dofs_per_dim;
337 ++d1, ++d2)
338 {
339 /*
340 * d1 and d2 represent "left" and "right" in the
341 * x-direction, d3 and d4 represent "bottom" and "top"
342 * in the y-direction. As before, this is to avoid looping
343 * over vertices.
344 */
345 value_list(l2h[d1 + d3 * n_dofs_per_dim], q) *= factor_1;
346 value_list(l2h[d2 + d3 * n_dofs_per_dim], q) *= factor_1;
347 value_list(l2h[d1 + d4 * n_dofs_per_dim], q) *= factor_1;
348 value_list(l2h[d2 + d4 * n_dofs_per_dim], q) *= factor_1;
349
350 factor_1 *= cell_extents[0];
351 }
352
353 factor_2 *= cell_extents[1];
354 }
355 }
356 }
357
358
359
360 template <int spacedim, typename Number>
361 void
362 rescale_fe_hermite_values(
363 const FE_Hermite<3, spacedim> &fe_herm,
364 const typename Mapping<3, spacedim>::InternalDataBase &mapping_data,
365 Table<2, Number> &value_list)
366 {
367 Tensor<1, 3> cell_extents;
368
369 // Check mapping_data is associated with a compatible mapping class
370 if (dynamic_cast<const typename MappingCartesian<3>::InternalData *>(
371 &mapping_data) != nullptr)
372 {
374 dynamic_cast<const typename MappingCartesian<3>::InternalData *>(
375 &mapping_data);
376 cell_extents = data->cell_extents;
377 }
378 else
380
381 const unsigned int regularity = fe_herm.get_regularity();
382 const unsigned int n_dofs_per_cell = fe_herm.n_dofs_per_cell();
383 const unsigned int n_dofs_per_dim = 2 * regularity + 2;
384 const unsigned int n_dofs_per_quad = n_dofs_per_dim * n_dofs_per_dim;
385 const unsigned int n_q_points_out = value_list.size(1);
386 (void)n_dofs_per_cell;
387
388 AssertDimension(value_list.size(0), n_dofs_per_cell);
389 AssertDimension(Utilities::pow(n_dofs_per_dim, 3), n_dofs_per_cell);
390
391 std::vector<unsigned int> l2h =
392 internal::hermite_lexicographic_to_hierarchic_numbering<3>(
393 regularity);
394
395 for (unsigned int q = 0; q < n_q_points_out; ++q)
396 {
397 double factor_3 = 1.0;
398
399 for (unsigned int d5 = 0, d6 = regularity + 1; d6 < n_dofs_per_dim;
400 ++d5, ++d6)
401 {
402 double factor_2 = factor_3;
403
404 for (unsigned int d3 = 0, d4 = regularity + 1;
405 d4 < n_dofs_per_dim;
406 ++d3, ++d4)
407 {
408 double factor_1 = factor_2;
409
410 for (unsigned int d1 = 0, d2 = regularity + 1;
411 d2 < n_dofs_per_dim;
412 ++d1, ++d2)
413 {
414 /*
415 * d1, d2: "left" and "right" (x-direction)
416 * d3, d4: "bottom" and "top" (y-direction)
417 * d5, d6: "down" and "up" (z-direction)
418 * This avoids looping over vertices
419 */
420 value_list(
421 l2h[d1 + d3 * n_dofs_per_dim + d5 * n_dofs_per_quad],
422 q) *= factor_1;
423 value_list(
424 l2h[d2 + d3 * n_dofs_per_dim + d5 * n_dofs_per_quad],
425 q) *= factor_1;
426 value_list(
427 l2h[d1 + d4 * n_dofs_per_dim + d5 * n_dofs_per_quad],
428 q) *= factor_1;
429 value_list(
430 l2h[d2 + d4 * n_dofs_per_dim + d5 * n_dofs_per_quad],
431 q) *= factor_1;
432 value_list(
433 l2h[d1 + d3 * n_dofs_per_dim + d6 * n_dofs_per_quad],
434 q) *= factor_1;
435 value_list(
436 l2h[d2 + d3 * n_dofs_per_dim + d6 * n_dofs_per_quad],
437 q) *= factor_1;
438 value_list(
439 l2h[d1 + d4 * n_dofs_per_dim + d6 * n_dofs_per_quad],
440 q) *= factor_1;
441 value_list(
442 l2h[d2 + d4 * n_dofs_per_dim + d6 * n_dofs_per_quad],
443 q) *= factor_1;
444
445 factor_1 *= cell_extents[0];
446 }
447
448 factor_2 *= cell_extents[1];
449 }
450
451 factor_3 *= cell_extents[2];
452 }
453 }
454 }
455 }; // class Rescaler
456 } // namespace
457} // namespace internal
458
459
460
461// Constructors
462template <int dim, int spacedim>
463FE_Hermite<dim, spacedim>::FE_Hermite(const unsigned int fe_degree)
464 : FE_Poly<dim, spacedim>(
465 internal::get_hermite_polynomials<dim>(fe_degree),
466 FiniteElementData<dim>(internal::get_hermite_dpo_vector(
467 dim,
468 internal::get_regularity_from_degree(fe_degree)),
469 1,
470 std::max(1U, fe_degree),
471 ((fe_degree > 2) ? FiniteElementData<dim>::H2 :
472 FiniteElementData<dim>::H1)),
473 std::vector<bool>(Utilities::pow(std::max(2U, fe_degree + 1), dim),
474 false),
475 std::vector<ComponentMask>(Utilities::pow(std::max(2U, fe_degree + 1),
476 dim),
477 ComponentMask(1, true)))
478 , regularity(internal::get_regularity_from_degree(fe_degree))
479{
480 Assert((fe_degree % 2 == 1),
482 "ERROR: The current implementation of Hermite interpolation "
483 "polynomials is only defined for odd polynomial degrees. Running "
484 "in release mode will use a polynomial degree of max(1,fe_degree-1) "
485 "to protect against unexpected internal bugs."));
486}
487
488
489
490template <int dim, int spacedim>
491std::string
493{
494 std::ostringstream name_buffer;
495 name_buffer << "FE_Hermite<" << Utilities::dim_string(dim, spacedim) << ">("
496 << this->degree << ")";
497 return name_buffer.str();
498}
499
500
501
502template <int dim, int spacedim>
503std::unique_ptr<FiniteElement<dim, spacedim>>
505{
506 return std::make_unique<FE_Hermite<dim, spacedim>>(*this);
507}
508
509
510
511template <int dim, int spacedim>
514{
518 out |= update_rescale; // since we need to rescale values, gradients, ...
519 return out;
520}
521
522
523
530template <int dim, int spacedim>
531std::vector<std::pair<unsigned int, unsigned int>>
533 const FiniteElement<dim, spacedim> &fe_other) const
534{
535 if (dynamic_cast<const FE_Q_Base<dim, spacedim> *>(&fe_other) != nullptr)
536 {
537 // there should be exactly one single DoF of FE_Q_Base at a vertex, and it
538 // should have an identical value to the first Hermite DoF
539 return {{0U, 0U}};
540 }
541 else if (dynamic_cast<const FE_SimplexP<dim, spacedim> *>(&fe_other) !=
542 nullptr)
543 {
544 // there should be exactly one single DoF of FE_Q_Base at a vertex, and it
545 // should have an identical value to the first Hermite DoF
546 return {{0U, 0U}};
547 }
548 else if (dynamic_cast<const FE_Nothing<dim> *>(&fe_other) != nullptr)
549 {
550 // the FE_Nothing has no degrees of freedom, so there are no
551 // equivalencies to be recorded
552 return {};
553 }
554 else if (fe_other.n_unique_faces() == 1 && fe_other.n_dofs_per_face(0) == 0)
555 {
556 // if the other element has no elements on faces at all,
557 // then it would be impossible to enforce any kind of
558 // continuity even if we knew exactly what kind of element
559 // we have -- simply because the other element declares
560 // that it is discontinuous because it has no DoFs on
561 // its faces. in that case, just state that we have no
562 // constraints to declare
563 return {};
564 }
565 else if (const FE_Hermite<dim, spacedim> *fe_herm_other =
566 dynamic_cast<const FE_Hermite<dim, spacedim> *>(&fe_other))
567 {
569 return {};
570 }
571 else
572 {
574 return {};
575 }
576}
577
578
579
585template <int dim, int spacedim>
586std::vector<std::pair<unsigned int, unsigned int>>
588 const FiniteElement<dim, spacedim> &fe_other) const
589{
590 (void)fe_other;
591 return {};
592}
593
594
595
600template <int dim, int spacedim>
601std::vector<std::pair<unsigned int, unsigned int>>
603 const FiniteElement<dim, spacedim> &fe_other,
604 const unsigned int face_no) const
605{
606 (void)fe_other;
607 (void)face_no;
608 return {};
609}
610
611
612
613/*
614 * The layout of this function is largely copied directly from FE_Q,
615 * however FE_Hermite can behave significantly differently in terms
616 * of domination due to how the function space is defined */
617template <int dim, int spacedim>
620 const FiniteElement<dim, spacedim> &fe_other,
621 const unsigned int codim) const
622{
623 Assert(codim <= dim, ExcImpossibleInDim(dim));
624
625 if (codim > 0)
626 if (dynamic_cast<const FE_DGQ<dim, spacedim> *>(&fe_other) != nullptr)
627 // there are no requirements between continuous and discontinuous elements
629
630
631 // vertex/line/face domination
632 // (if fe_other is not derived from FE_DGQ)
633 // & cell domination
634 // ----------------------------------------
635 if (const FE_Hermite<dim, spacedim> *fe_hermite_other =
636 dynamic_cast<const FE_Hermite<dim, spacedim> *>(&fe_other))
637 {
638 if (this->degree < fe_hermite_other->degree)
640 else if (this->degree == fe_hermite_other->degree)
642 else
644 }
645 if (const FE_Q<dim, spacedim> *fe_q_other =
646 dynamic_cast<const FE_Q<dim, spacedim> *>(&fe_other))
647 {
648 if (fe_q_other->degree == 1)
649 {
650 if (this->degree == 1)
652 else
654 }
655 else if (this->degree <= fe_q_other->degree)
657 else
659 }
660 else if (const FE_SimplexP<dim, spacedim> *fe_p_other =
661 dynamic_cast<const FE_SimplexP<dim, spacedim> *>(&fe_other))
662 {
663 if (fe_p_other->degree == 1)
664 {
665 if (this->degree == 1)
667 else
669 }
670 else if (this->degree <= fe_p_other->degree)
672 else
674 }
675 else if (const FE_WedgeP<dim, spacedim> *fe_wp_other =
676 dynamic_cast<const FE_WedgeP<dim, spacedim> *>(&fe_other))
677 {
678 if (fe_wp_other->degree == 1)
679 {
680 if (this->degree == 1)
682 else
684 }
685 else if (this->degree <= fe_wp_other->degree)
687 else
689 }
690 else if (const FE_PyramidP<dim, spacedim> *fe_pp_other =
691 dynamic_cast<const FE_PyramidP<dim, spacedim> *>(&fe_other))
692 {
693 if (fe_pp_other->degree == 1)
694 {
695 if (this->degree == 1)
697 else
699 }
700 else if (this->degree <= fe_pp_other->degree)
702 else
704 }
705 else if (const FE_Nothing<dim, spacedim> *fe_nothing =
706 dynamic_cast<const FE_Nothing<dim, spacedim> *>(&fe_other))
707 {
708 if (fe_nothing->is_dominating())
710 else
711 // the FE_Nothing has no degrees of freedom and it is typically used
712 // in a context where we don't require any continuity along the
713 // interface
715 }
716
719}
720
721
722
723template <int dim, int spacedim>
724std::vector<unsigned int>
726{
727 return internal::hermite_lexicographic_to_hierarchic_numbering<dim>(
728 this->regularity);
729}
730
731
732
733template <int dim, int spacedim>
736 const unsigned int derivative_order) const
737{
738 /*
739 * Create a look-up table for finding relevant dofs on all
740 * 2*dim faces of reference cell
741 */
742 const unsigned int degree = this->degree;
743 const unsigned int regularity = this->get_regularity();
744 const unsigned int dofs_per_face = this->n_dofs_per_face();
745 AssertIndexRange(derivative_order, regularity + 1);
746 AssertDimension(dofs_per_face,
747 (regularity + 1) * Utilities::pow(degree + 1, dim - 1));
748
749 const unsigned int relevant_dofs_per_face = dofs_per_face / (regularity + 1);
750 Table<2, unsigned int> dofs_on_each_face(2 * dim, relevant_dofs_per_face);
751
752 /*
753 * Use knowledge of the local degree numbering for this version,
754 * saving expensive calls to reinit().
755 */
756 const std::vector<unsigned int> l2h =
757 get_lexicographic_to_hierarchic_numbering();
758 const unsigned int dofs_per_cell = Utilities::pow(degree + 1, dim);
759 AssertDimension(dofs_per_cell, l2h.size());
760 (void)dofs_per_cell;
761
762 /*
763 * The following loop uses the variables batch_size, batch_index
764 * and local_index to simplify calculations. The idea is to find
765 * relevant DoFs in batches, with each batch representing a
766 * set of DoFs of interest on a given face that occur consecutively
767 * in the ordering of all DoFs on the reference cell.
768 * To quickly summarise what the variables mean:
769 * sublist_index: index of a DoF in the list of relevant DoF indices
770 * index: index of a DoF in the list of all DoFs on the cell
771 * batch_size: Number of consecutive DoFs in the ordering that are
772 * all of interest,
773 * batch index: Index of the current batch in the list of batches
774 * local_index: Index of the current DoF within a batch
775 *
776 * The variable correction is used because the pattern of relevant
777 * DoFs on opposite face pairs is always the same, just separated by
778 * a constant offset value in the indices, so it's easier to calculate
779 * the pattern once and find this offset value.
780 */
781 for (unsigned int d = 0, batch_size = 1; d < dim;
782 ++d, batch_size *= degree + 1)
783 for (unsigned int sublist_index = 0; sublist_index < relevant_dofs_per_face;
784 ++sublist_index)
785 {
786 const unsigned int local_index = sublist_index % batch_size;
787 const unsigned int batch_index = sublist_index / batch_size;
788
789 unsigned int index =
790 local_index +
791 (batch_index * (degree + 1) + derivative_order) * batch_size;
792 unsigned int correction = batch_size * (regularity + 1);
793 Assert(index + correction < dofs_per_cell,
794 ExcDimensionMismatch(index + correction, dofs_per_cell));
795
796 dofs_on_each_face(2 * d, sublist_index) = l2h[index];
797 dofs_on_each_face(2 * d + 1, sublist_index) = l2h[index + correction];
798 }
799
800 return dofs_on_each_face;
801}
802
803
804
805template <int dim, int spacedim>
806void
809 const CellSimilarity::Similarity cell_similarity,
810 const Quadrature<dim> & /*quadrature*/,
811 const Mapping<dim, spacedim> &mapping,
812 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal,
813 const ::internal::FEValuesImplementation::MappingRelatedData<dim,
814 spacedim>
815 & /*mapping_data*/,
816 const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
818 spacedim>
819 &output_data) const
820{
821 // Convert data object to internal data for this class.
822 // Fails with an exception if that is not possible.
823 Assert(
824 (dynamic_cast<const typename FE_Hermite<dim, spacedim>::InternalData *>(
825 &fe_internal) != nullptr),
827 const typename FE_Hermite<dim, spacedim>::InternalData &fe_data =
828 static_cast<const typename FE_Hermite<dim, spacedim>::InternalData &>(
829 fe_internal);
830
831 const UpdateFlags flags(fe_data.update_each);
832
833 // Transform values, gradients and higher derivatives. Values also need to
834 // be rescaled according the the nodal derivative they correspond to.
835 if ((flags & update_values) &&
836 (cell_similarity != CellSimilarity::translation))
837 {
838 internal::Rescaler shape_fix;
839 for (unsigned int i = 0; i < output_data.shape_values.size(0); ++i)
840 for (unsigned int q = 0; q < output_data.shape_values.size(1); ++q)
841 output_data.shape_values(i, q) = fe_data.shape_values(i, q);
842 shape_fix.rescale_fe_hermite_values(*this,
843 mapping_internal,
844 output_data.shape_values);
845 }
846
847 if ((flags & update_gradients) &&
848 (cell_similarity != CellSimilarity::translation))
849 {
850 for (unsigned int k = 0; k < this->n_dofs_per_cell(); ++k)
851 mapping.transform(make_array_view(fe_data.shape_gradients, k),
853 mapping_internal,
854 make_array_view(output_data.shape_gradients, k));
855
856 internal::Rescaler grad_fix;
857 grad_fix.rescale_fe_hermite_values(*this,
858 mapping_internal,
859 output_data.shape_gradients);
860 }
861
862 if ((flags & update_hessians) &&
863 (cell_similarity != CellSimilarity::translation))
864 {
865 for (unsigned int k = 0; k < this->n_dofs_per_cell(); ++k)
866 mapping.transform(make_array_view(fe_data.shape_hessians, k),
868 mapping_internal,
869 make_array_view(output_data.shape_hessians, k));
870
871 internal::Rescaler hessian_fix;
872 hessian_fix.rescale_fe_hermite_values(*this,
873 mapping_internal,
874 output_data.shape_hessians);
875 }
876
877 if ((flags & update_3rd_derivatives) &&
878 (cell_similarity != CellSimilarity::translation))
879 {
880 for (unsigned int k = 0; k < this->n_dofs_per_cell(); ++k)
883 mapping_internal,
884 make_array_view(output_data.shape_3rd_derivatives,
885 k));
886
887 internal::Rescaler third_dev_fix;
888 third_dev_fix.rescale_fe_hermite_values(
889 *this, mapping_internal, output_data.shape_3rd_derivatives);
890 }
891}
892
893
894
895template <int dim, int spacedim>
896void
899 const unsigned int face_no,
900 const hp::QCollection<dim - 1> &quadrature,
901 const Mapping<dim, spacedim> &mapping,
902 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_internal,
903 const ::internal::FEValuesImplementation::MappingRelatedData<dim,
904 spacedim>
905 &,
906 const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
908 spacedim>
909 &output_data) const
910{
911 /*
912 * Convert data object to internal data for this class. Fails with
913 * an exception if that is not possible.
914 */
915 Assert(
916 (dynamic_cast<const typename FE_Hermite<dim, spacedim>::InternalData *>(
917 &fe_internal) != nullptr),
919 const typename FE_Hermite<dim, spacedim>::InternalData &fe_data =
920 static_cast<const typename FE_Hermite<dim, spacedim>::InternalData &>(
921 fe_internal);
922
923 Assert((dynamic_cast<
925 &mapping_internal) != nullptr),
927
928 AssertDimension(quadrature.size(), 1U);
929
930 /*
931 * offset determines which data set to take (all data sets for all
932 * faces are stored contiguously)
933 */
934 const typename QProjector<dim>::DataSetDescriptor offset =
936 ReferenceCells::get_hypercube<dim>(),
937 face_no,
938 cell->combined_face_orientation(face_no),
939 quadrature[0].size());
940
941 const UpdateFlags flags(fe_data.update_each);
942
943 // Transform values, gradients and higher derivatives.
944 if (flags & update_values)
945 {
946 for (unsigned int k = 0; k < this->dofs_per_cell; ++k)
947 for (unsigned int i = 0; i < quadrature[0].size(); ++i)
948 output_data.shape_values(k, i) = fe_data.shape_values[k][i + offset];
949
950 internal::Rescaler shape_face_fix;
951 shape_face_fix.rescale_fe_hermite_values(*this,
952 mapping_internal,
953 output_data.shape_values);
954 }
955
956 if (flags & update_gradients)
957 {
958 for (unsigned int k = 0; k < this->dofs_per_cell; ++k)
960 k,
961 offset,
962 quadrature[0].size()),
964 mapping_internal,
965 make_array_view(output_data.shape_gradients, k));
966
967 internal::Rescaler grad_face_fix;
968 grad_face_fix.rescale_fe_hermite_values(*this,
969 mapping_internal,
970 output_data.shape_gradients);
971 }
972
973 if (flags & update_hessians)
974 {
975 for (unsigned int k = 0; k < this->dofs_per_cell; ++k)
977 k,
978 offset,
979 quadrature[0].size()),
981 mapping_internal,
982 make_array_view(output_data.shape_hessians, k));
983
984 internal::Rescaler hessian_face_fix;
985 hessian_face_fix.rescale_fe_hermite_values(*this,
986 mapping_internal,
987 output_data.shape_hessians);
988 }
989
990 if (flags & update_3rd_derivatives)
991 {
992 for (unsigned int k = 0; k < this->dofs_per_cell; ++k)
994 k,
995 offset,
996 quadrature[0].size()),
998 mapping_internal,
999 make_array_view(output_data.shape_3rd_derivatives,
1000 k));
1001
1002 internal::Rescaler shape_3rd_face_fix;
1003 shape_3rd_face_fix.rescale_fe_hermite_values(
1004 *this, mapping_internal, output_data.shape_3rd_derivatives);
1005 }
1006}
1007
1008
1009
1010// Explicit instantiations
1011#include "fe/fe_hermite.inst"
1012
ArrayView< std::remove_reference_t< typename std::iterator_traits< Iterator >::reference >, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
virtual std::unique_ptr< FiniteElement< dim, spacedim > > clone() const override
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_vertex_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Table< 2, unsigned int > get_dofs_corresponding_to_outward_normal_derivatives(const unsigned int derivative_order) const
unsigned int get_regularity() const
Definition fe_hermite.h:293
virtual FiniteElementDomination::Domination compare_for_domination(const FiniteElement< dim, spacedim > &other_fe, const unsigned int codim) const override
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 typename FiniteElement< dim, spacedim >::InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
virtual std::string get_name() const override
std::vector< unsigned int > get_lexicographic_to_hierarchic_numbering() const
FE_Hermite(const unsigned int fe_degree)
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 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 typename FiniteElement< dim, spacedim >::InternalDataBase &fe_internal, ::internal::FEValuesImplementation::FiniteElementRelatedData< dim, spacedim > &output_data) const override
virtual std::vector< std::pair< unsigned int, unsigned int > > hp_line_dof_identities(const FiniteElement< dim, spacedim > &fe_other) const override
Table< 2, double > shape_values
Definition fe_poly.h:436
Table< 2, Tensor< 3, dim > > shape_3rd_derivatives
Definition fe_poly.h:469
Table< 2, Tensor< 2, dim > > shape_hessians
Definition fe_poly.h:458
Table< 2, Tensor< 1, dim > > shape_gradients
Definition fe_poly.h:447
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
Definition fe_q.h:552
unsigned int n_dofs_per_cell() const
unsigned int n_dofs_per_face(unsigned int face_no=0, unsigned int child=0) const
unsigned int n_unique_faces() const
Abstract base class for mapping classes.
Definition mapping.h:318
virtual void transform(const ArrayView< const Tensor< 1, dim > > &input, const MappingKind kind, const typename Mapping< dim, spacedim >::InternalDataBase &internal, const ArrayView< Tensor< 1, spacedim > > &output) const =0
static std::vector< Polynomial< double > > generate_complete_basis(const unsigned int regularity)
Class storing the offset index into a Quadrature rule created by project_to_all_faces() or project_to...
Definition qprojector.h:204
static DataSetDescriptor face(const ReferenceCell< dim > &reference_cell, const unsigned int face_no, const types::geometric_orientation combined_orientation, const unsigned int n_quadrature_points)
unsigned int size() const
Definition collection.h:314
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_ASSERT_UNREACHABLE()
#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)
UpdateFlags
@ update_rescale
@ update_hessians
Second derivatives of shape functions.
@ update_values
Shape function values.
@ update_3rd_derivatives
Third derivatives of shape functions.
@ update_gradients
Shape function gradients.
@ mapping_covariant_gradient
Definition mapping.h:100
@ mapping_covariant
Definition mapping.h:89
@ mapping_covariant_hessian
Definition mapping.h:150
std::vector< index_type > data
Definition mpi.cc:734
std::string dim_string(const int dim, const int spacedim)
Definition utilities.cc:547
constexpr T pow(const T base, const int iexp)
Definition utilities.h:966
std::vector< Integer > invert_permutation(const std::vector< Integer > &permutation)
Definition utilities.h:1670
STL namespace.