version GIT relicensing-7278-g091132d5eb 2026-12-02 03:10:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
mapping_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) 2015 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
21#include <deal.II/base/table.h>
23
24#include <deal.II/fe/fe_poly.h>
28
31#include <deal.II/grid/tria.h>
33
35
37
38#include <boost/container/small_vector.hpp>
39
40#include <algorithm>
41#include <array>
42#include <cmath>
43#include <memory>
44#include <numeric>
45
46
48
49
50template <int dim, int spacedim>
53 : fe(fe)
54 , polynomial_degree(fe.tensor_degree())
55 , n_shape_functions(fe.n_dofs_per_cell())
56{}
57
58
59
60template <int dim, int spacedim>
61std::size_t
76
77
78
79template <int dim, int spacedim>
80void
82 const Quadrature<dim> &q)
83{
84 // store the flags in the internal data object so we can access them
85 // in fill_fe_*_values()
86 this->update_each = update_flags;
87
88 const unsigned int n_q_points = q.size();
89
90 if (this->update_each & update_covariant_transformation)
91 covariant.resize(n_q_points);
92
93 if (this->update_each & update_contravariant_transformation)
94 contravariant.resize(n_q_points);
95
96 if (this->update_each & update_volume_elements)
97 volume_elements.resize(n_q_points);
98
99 // see if we need the (transformation) shape function values
100 // and/or gradients and resize the necessary arrays
101 if (this->update_each & update_quadrature_points)
102 shape_values.resize(n_shape_functions * n_q_points);
103
104 if (this->update_each &
112 shape_derivatives.resize(n_shape_functions * n_q_points);
113
114 if (this->update_each &
116 shape_second_derivatives.resize(n_shape_functions * n_q_points);
117
118 if (this->update_each & (update_jacobian_2nd_derivatives |
120 shape_third_derivatives.resize(n_shape_functions * n_q_points);
121
122 if (this->update_each & (update_jacobian_3rd_derivatives |
124 shape_fourth_derivatives.resize(n_shape_functions * n_q_points);
125
126 // now also fill the various fields with their correct values
127 compute_shape_function_values(q.get_points());
128
129 // copy (projected) quadrature weights
130 quadrature_weights = q.get_weights();
131}
132
133
134
135template <int dim, int spacedim>
136void
138 const UpdateFlags update_flags,
139 const Quadrature<dim> &q,
140 const unsigned int n_original_q_points)
141{
142 reinit(update_flags, q);
143
144 if (this->update_each &
147 {
148 aux.resize(dim - 1,
149 std::vector<Tensor<1, spacedim>>(n_original_q_points));
150
151 // Compute tangentials to the faces of the unit cell. In 1d, a
152 // face is a point, so there is no tangent space.
153 if constexpr (dim > 1)
154 {
155 const auto reference_cell = this->fe.reference_cell();
156 const auto n_faces = reference_cell.n_faces();
157
158 for (unsigned int i = 0; i < n_faces; ++i)
159 {
160 unit_tangentials[i].resize(n_original_q_points);
161 std::fill(unit_tangentials[i].begin(),
162 unit_tangentials[i].end(),
163 reference_cell.face_tangent_vector(i, 0));
164 if constexpr (dim > 2)
165 {
166 unit_tangentials[n_faces + i].resize(n_original_q_points);
167 std::fill(unit_tangentials[n_faces + i].begin(),
168 unit_tangentials[n_faces + i].end(),
169 reference_cell.face_tangent_vector(i, 1));
170 }
171 }
172 }
173 }
174}
175
176
177
178template <int dim, int spacedim>
179void
181 const std::vector<Point<dim>> &unit_points)
182{
183 const auto fe_poly = dynamic_cast<const FE_Poly<dim, spacedim> *>(&this->fe);
184
185 Assert(fe_poly != nullptr, ExcNotImplemented());
186
187 const auto &tensor_pols = fe_poly->get_poly_space();
188
189 const unsigned int n_shape_functions = fe.n_dofs_per_cell();
190 const unsigned int n_points = unit_points.size();
191
192 std::vector<double> values;
193 std::vector<Tensor<1, dim>> grads;
194 if (shape_values.size() != 0)
195 {
196 Assert(shape_values.size() == n_shape_functions * n_points,
198 values.resize(n_shape_functions);
199 }
200 if (shape_derivatives.size() != 0)
201 {
202 Assert(shape_derivatives.size() == n_shape_functions * n_points,
204 grads.resize(n_shape_functions);
205 }
206
207 std::vector<Tensor<2, dim>> grad2;
208 if (shape_second_derivatives.size() != 0)
209 {
210 Assert(shape_second_derivatives.size() == n_shape_functions * n_points,
212 grad2.resize(n_shape_functions);
213 }
214
215 std::vector<Tensor<3, dim>> grad3;
216 if (shape_third_derivatives.size() != 0)
217 {
218 Assert(shape_third_derivatives.size() == n_shape_functions * n_points,
220 grad3.resize(n_shape_functions);
221 }
222
223 std::vector<Tensor<4, dim>> grad4;
224 if (shape_fourth_derivatives.size() != 0)
225 {
226 Assert(shape_fourth_derivatives.size() == n_shape_functions * n_points,
228 grad4.resize(n_shape_functions);
229 }
230
231
232 if (shape_values.size() != 0 || shape_derivatives.size() != 0 ||
233 shape_second_derivatives.size() != 0 ||
234 shape_third_derivatives.size() != 0 ||
235 shape_fourth_derivatives.size() != 0)
236 for (unsigned int point = 0; point < n_points; ++point)
237 {
238 tensor_pols.evaluate(
239 unit_points[point], values, grads, grad2, grad3, grad4);
240
241 if (shape_values.size() != 0)
242 for (unsigned int i = 0; i < n_shape_functions; ++i)
243 shape(point, i) = values[i];
244
245 if (shape_derivatives.size() != 0)
246 for (unsigned int i = 0; i < n_shape_functions; ++i)
247 derivative(point, i) = grads[i];
248
249 if (shape_second_derivatives.size() != 0)
250 for (unsigned int i = 0; i < n_shape_functions; ++i)
251 second_derivative(point, i) = grad2[i];
252
253 if (shape_third_derivatives.size() != 0)
254 for (unsigned int i = 0; i < n_shape_functions; ++i)
255 third_derivative(point, i) = grad3[i];
256
257 if (shape_fourth_derivatives.size() != 0)
258 for (unsigned int i = 0; i < n_shape_functions; ++i)
259 fourth_derivative(point, i) = grad4[i];
260 }
261}
262
263
264namespace internal
265{
266 namespace MappingFEImplementation
267 {
268 namespace
269 {
276 template <int dim, int spacedim>
277 void
278 maybe_compute_q_points(
279 const typename QProjector<dim>::DataSetDescriptor data_set,
280 const typename ::MappingFE<dim, spacedim>::InternalData &data,
281 std::vector<Point<spacedim>> &quadrature_points,
282 const unsigned int n_q_points)
283 {
284 const UpdateFlags update_flags = data.update_each;
285
286 if (update_flags & update_quadrature_points)
287 for (unsigned int point = 0; point < n_q_points; ++point)
288 {
289 const double *shape = &data.shape(point + data_set, 0);
290 Point<spacedim> result =
291 (shape[0] * data.mapping_support_points[0]);
292 for (unsigned int k = 1; k < data.n_shape_functions; ++k)
293 for (unsigned int i = 0; i < spacedim; ++i)
294 result[i] += shape[k] * data.mapping_support_points[k][i];
295 quadrature_points[point] = result;
296 }
297 }
298
299
300
309 template <int dim, int spacedim>
310 void
311 maybe_update_Jacobians(
312 const CellSimilarity::Similarity cell_similarity,
313 const typename ::QProjector<dim>::DataSetDescriptor data_set,
314 const typename ::MappingFE<dim, spacedim>::InternalData &data,
315 const unsigned int n_q_points)
316 {
317 const UpdateFlags update_flags = data.update_each;
318
319 if (update_flags & update_contravariant_transformation)
320 // if the current cell is just a
321 // translation of the previous one, no
322 // need to recompute jacobians...
323 if (cell_similarity != CellSimilarity::translation)
324 {
325 std::fill(data.contravariant.begin(),
326 data.contravariant.end(),
328
329 Assert(data.n_shape_functions > 0, ExcInternalError());
330
331 for (unsigned int point = 0; point < n_q_points; ++point)
332 {
333 double result[spacedim][dim];
334
335 // peel away part of sum to avoid zeroing the
336 // entries and adding for the first time
337 for (unsigned int i = 0; i < spacedim; ++i)
338 for (unsigned int j = 0; j < dim; ++j)
339 result[i][j] = data.derivative(point + data_set, 0)[j] *
340 data.mapping_support_points[0][i];
341 for (unsigned int k = 1; k < data.n_shape_functions; ++k)
342 for (unsigned int i = 0; i < spacedim; ++i)
343 for (unsigned int j = 0; j < dim; ++j)
344 result[i][j] +=
345 data.derivative(point + data_set, k)[j] *
346 data.mapping_support_points[k][i];
347
348 // write result into contravariant data. for
349 // j=dim in the case dim<spacedim, there will
350 // never be any nonzero data that arrives in
351 // here, so it is ok anyway because it was
352 // initialized to zero at the initialization
353 for (unsigned int i = 0; i < spacedim; ++i)
354 for (unsigned int j = 0; j < dim; ++j)
355 data.contravariant[point][i][j] = result[i][j];
356 }
357 }
358
359 if (update_flags & update_covariant_transformation)
360 if (cell_similarity != CellSimilarity::translation)
361 {
362 for (unsigned int point = 0; point < n_q_points; ++point)
363 {
364 data.covariant[point] =
365 (data.contravariant[point]).covariant_form();
366 }
367 }
368
369 if (update_flags & update_volume_elements)
370 if (cell_similarity != CellSimilarity::translation)
371 {
372 for (unsigned int point = 0; point < n_q_points; ++point)
373 data.volume_elements[point] =
374 data.contravariant[point].determinant();
375 }
376 }
377
384 template <int dim, int spacedim>
385 void
386 maybe_update_jacobian_grads(
387 const CellSimilarity::Similarity cell_similarity,
388 const typename QProjector<dim>::DataSetDescriptor data_set,
389 const typename ::MappingFE<dim, spacedim>::InternalData &data,
390 std::vector<DerivativeForm<2, dim, spacedim>> &jacobian_grads,
391 const unsigned int n_q_points)
392 {
393 const UpdateFlags update_flags = data.update_each;
394 if (update_flags & update_jacobian_grads)
395 {
396 AssertIndexRange(n_q_points, jacobian_grads.size() + 1);
397
398 if (cell_similarity != CellSimilarity::translation)
399 for (unsigned int point = 0; point < n_q_points; ++point)
400 {
401 const Tensor<2, dim> *second =
402 &data.second_derivative(point + data_set, 0);
403 double result[spacedim][dim][dim];
404 for (unsigned int i = 0; i < spacedim; ++i)
405 for (unsigned int j = 0; j < dim; ++j)
406 for (unsigned int l = 0; l < dim; ++l)
407 result[i][j][l] =
408 (second[0][j][l] * data.mapping_support_points[0][i]);
409 for (unsigned int k = 1; k < data.n_shape_functions; ++k)
410 for (unsigned int i = 0; i < spacedim; ++i)
411 for (unsigned int j = 0; j < dim; ++j)
412 for (unsigned int l = 0; l < dim; ++l)
413 result[i][j][l] +=
414 (second[k][j][l] *
415 data.mapping_support_points[k][i]);
416
417 for (unsigned int i = 0; i < spacedim; ++i)
418 for (unsigned int j = 0; j < dim; ++j)
419 for (unsigned int l = 0; l < dim; ++l)
420 jacobian_grads[point][i][j][l] = result[i][j][l];
421 }
422 }
423 }
424
431 template <int dim, int spacedim>
432 void
433 maybe_update_jacobian_pushed_forward_grads(
434 const CellSimilarity::Similarity cell_similarity,
435 const typename QProjector<dim>::DataSetDescriptor data_set,
436 const typename ::MappingFE<dim, spacedim>::InternalData &data,
437 std::vector<Tensor<3, spacedim>> &jacobian_pushed_forward_grads,
438 const unsigned int n_q_points)
439 {
440 const UpdateFlags update_flags = data.update_each;
441 if (update_flags & update_jacobian_pushed_forward_grads)
442 {
443 AssertIndexRange(n_q_points,
444 jacobian_pushed_forward_grads.size() + 1);
445
446 if (cell_similarity != CellSimilarity::translation)
447 {
448 double tmp[spacedim][spacedim][spacedim];
449 for (unsigned int point = 0; point < n_q_points; ++point)
450 {
451 const Tensor<2, dim> *second =
452 &data.second_derivative(point + data_set, 0);
453 double result[spacedim][dim][dim];
454 for (unsigned int i = 0; i < spacedim; ++i)
455 for (unsigned int j = 0; j < dim; ++j)
456 for (unsigned int l = 0; l < dim; ++l)
457 result[i][j][l] = (second[0][j][l] *
458 data.mapping_support_points[0][i]);
459 for (unsigned int k = 1; k < data.n_shape_functions; ++k)
460 for (unsigned int i = 0; i < spacedim; ++i)
461 for (unsigned int j = 0; j < dim; ++j)
462 for (unsigned int l = 0; l < dim; ++l)
463 result[i][j][l] +=
464 (second[k][j][l] *
465 data.mapping_support_points[k][i]);
466
467 // first push forward the j-components
468 for (unsigned int i = 0; i < spacedim; ++i)
469 for (unsigned int j = 0; j < spacedim; ++j)
470 for (unsigned int l = 0; l < dim; ++l)
471 {
472 tmp[i][j][l] =
473 result[i][0][l] * data.covariant[point][j][0];
474 for (unsigned int jr = 1; jr < dim; ++jr)
475 {
476 tmp[i][j][l] += result[i][jr][l] *
477 data.covariant[point][j][jr];
478 }
479 }
480
481 // now, pushing forward the l-components
482 for (unsigned int i = 0; i < spacedim; ++i)
483 for (unsigned int j = 0; j < spacedim; ++j)
484 for (unsigned int l = 0; l < spacedim; ++l)
485 {
486 jacobian_pushed_forward_grads[point][i][j][l] =
487 tmp[i][j][0] * data.covariant[point][l][0];
488 for (unsigned int lr = 1; lr < dim; ++lr)
489 {
490 jacobian_pushed_forward_grads[point][i][j][l] +=
491 tmp[i][j][lr] * data.covariant[point][l][lr];
492 }
493 }
494 }
495 }
496 }
497 }
498
505 template <int dim, int spacedim>
506 void
507 maybe_update_jacobian_2nd_derivatives(
508 const CellSimilarity::Similarity cell_similarity,
509 const typename QProjector<dim>::DataSetDescriptor data_set,
510 const typename ::MappingFE<dim, spacedim>::InternalData &data,
511 std::vector<DerivativeForm<3, dim, spacedim>> &jacobian_2nd_derivatives,
512 const unsigned int n_q_points)
513 {
514 const UpdateFlags update_flags = data.update_each;
515 if (update_flags & update_jacobian_2nd_derivatives)
516 {
517 AssertIndexRange(n_q_points, jacobian_2nd_derivatives.size() + 1);
518
519 if (cell_similarity != CellSimilarity::translation)
520 {
521 for (unsigned int point = 0; point < n_q_points; ++point)
522 {
523 const Tensor<3, dim> *third =
524 &data.third_derivative(point + data_set, 0);
525 double result[spacedim][dim][dim][dim];
526 for (unsigned int i = 0; i < spacedim; ++i)
527 for (unsigned int j = 0; j < dim; ++j)
528 for (unsigned int l = 0; l < dim; ++l)
529 for (unsigned int m = 0; m < dim; ++m)
530 result[i][j][l][m] =
531 (third[0][j][l][m] *
532 data.mapping_support_points[0][i]);
533 for (unsigned int k = 1; k < data.n_shape_functions; ++k)
534 for (unsigned int i = 0; i < spacedim; ++i)
535 for (unsigned int j = 0; j < dim; ++j)
536 for (unsigned int l = 0; l < dim; ++l)
537 for (unsigned int m = 0; m < dim; ++m)
538 result[i][j][l][m] +=
539 (third[k][j][l][m] *
540 data.mapping_support_points[k][i]);
541
542 for (unsigned int i = 0; i < spacedim; ++i)
543 for (unsigned int j = 0; j < dim; ++j)
544 for (unsigned int l = 0; l < dim; ++l)
545 for (unsigned int m = 0; m < dim; ++m)
546 jacobian_2nd_derivatives[point][i][j][l][m] =
547 result[i][j][l][m];
548 }
549 }
550 }
551 }
552
560 template <int dim, int spacedim>
561 void
562 maybe_update_jacobian_pushed_forward_2nd_derivatives(
563 const CellSimilarity::Similarity cell_similarity,
564 const typename QProjector<dim>::DataSetDescriptor data_set,
565 const typename ::MappingFE<dim, spacedim>::InternalData &data,
566 std::vector<Tensor<4, spacedim>>
567 &jacobian_pushed_forward_2nd_derivatives,
568 const unsigned int n_q_points)
569 {
570 const UpdateFlags update_flags = data.update_each;
572 {
573 AssertIndexRange(n_q_points,
574 jacobian_pushed_forward_2nd_derivatives.size() +
575 1);
576
577 if (cell_similarity != CellSimilarity::translation)
578 {
579 double tmp[spacedim][spacedim][spacedim][spacedim];
580 for (unsigned int point = 0; point < n_q_points; ++point)
581 {
582 const Tensor<3, dim> *third =
583 &data.third_derivative(point + data_set, 0);
584 double result[spacedim][dim][dim][dim];
585 for (unsigned int i = 0; i < spacedim; ++i)
586 for (unsigned int j = 0; j < dim; ++j)
587 for (unsigned int l = 0; l < dim; ++l)
588 for (unsigned int m = 0; m < dim; ++m)
589 result[i][j][l][m] =
590 (third[0][j][l][m] *
591 data.mapping_support_points[0][i]);
592 for (unsigned int k = 1; k < data.n_shape_functions; ++k)
593 for (unsigned int i = 0; i < spacedim; ++i)
594 for (unsigned int j = 0; j < dim; ++j)
595 for (unsigned int l = 0; l < dim; ++l)
596 for (unsigned int m = 0; m < dim; ++m)
597 result[i][j][l][m] +=
598 (third[k][j][l][m] *
599 data.mapping_support_points[k][i]);
600
601 // push forward the j-coordinate
602 for (unsigned int i = 0; i < spacedim; ++i)
603 for (unsigned int j = 0; j < spacedim; ++j)
604 for (unsigned int l = 0; l < dim; ++l)
605 for (unsigned int m = 0; m < dim; ++m)
606 {
607 jacobian_pushed_forward_2nd_derivatives
608 [point][i][j][l][m] =
609 result[i][0][l][m] *
610 data.covariant[point][j][0];
611 for (unsigned int jr = 1; jr < dim; ++jr)
612 jacobian_pushed_forward_2nd_derivatives[point]
613 [i][j][l]
614 [m] +=
615 result[i][jr][l][m] *
616 data.covariant[point][j][jr];
617 }
618
619 // push forward the l-coordinate
620 for (unsigned int i = 0; i < spacedim; ++i)
621 for (unsigned int j = 0; j < spacedim; ++j)
622 for (unsigned int l = 0; l < spacedim; ++l)
623 for (unsigned int m = 0; m < dim; ++m)
624 {
625 tmp[i][j][l][m] =
626 jacobian_pushed_forward_2nd_derivatives[point]
627 [i][j][0]
628 [m] *
629 data.covariant[point][l][0];
630 for (unsigned int lr = 1; lr < dim; ++lr)
631 tmp[i][j][l][m] +=
632 jacobian_pushed_forward_2nd_derivatives
633 [point][i][j][lr][m] *
634 data.covariant[point][l][lr];
635 }
636
637 // push forward the m-coordinate
638 for (unsigned int i = 0; i < spacedim; ++i)
639 for (unsigned int j = 0; j < spacedim; ++j)
640 for (unsigned int l = 0; l < spacedim; ++l)
641 for (unsigned int m = 0; m < spacedim; ++m)
642 {
643 jacobian_pushed_forward_2nd_derivatives
644 [point][i][j][l][m] =
645 tmp[i][j][l][0] * data.covariant[point][m][0];
646 for (unsigned int mr = 1; mr < dim; ++mr)
647 jacobian_pushed_forward_2nd_derivatives[point]
648 [i][j][l]
649 [m] +=
650 tmp[i][j][l][mr] *
651 data.covariant[point][m][mr];
652 }
653 }
654 }
655 }
656 }
657
664 template <int dim, int spacedim>
665 void
666 maybe_update_jacobian_3rd_derivatives(
667 const CellSimilarity::Similarity cell_similarity,
668 const typename QProjector<dim>::DataSetDescriptor data_set,
669 const typename ::MappingFE<dim, spacedim>::InternalData &data,
670 std::vector<DerivativeForm<4, dim, spacedim>> &jacobian_3rd_derivatives,
671 const unsigned int n_q_points)
672 {
673 const UpdateFlags update_flags = data.update_each;
674 if (update_flags & update_jacobian_3rd_derivatives)
675 {
676 AssertIndexRange(n_q_points, jacobian_3rd_derivatives.size() + 1);
677
678 if (cell_similarity != CellSimilarity::translation)
679 {
680 for (unsigned int point = 0; point < n_q_points; ++point)
681 {
682 const Tensor<4, dim> *fourth =
683 &data.fourth_derivative(point + data_set, 0);
684 double result[spacedim][dim][dim][dim][dim];
685 for (unsigned int i = 0; i < spacedim; ++i)
686 for (unsigned int j = 0; j < dim; ++j)
687 for (unsigned int l = 0; l < dim; ++l)
688 for (unsigned int m = 0; m < dim; ++m)
689 for (unsigned int n = 0; n < dim; ++n)
690 result[i][j][l][m][n] =
691 (fourth[0][j][l][m][n] *
692 data.mapping_support_points[0][i]);
693 for (unsigned int k = 1; k < data.n_shape_functions; ++k)
694 for (unsigned int i = 0; i < spacedim; ++i)
695 for (unsigned int j = 0; j < dim; ++j)
696 for (unsigned int l = 0; l < dim; ++l)
697 for (unsigned int m = 0; m < dim; ++m)
698 for (unsigned int n = 0; n < dim; ++n)
699 result[i][j][l][m][n] +=
700 (fourth[k][j][l][m][n] *
701 data.mapping_support_points[k][i]);
702
703 for (unsigned int i = 0; i < spacedim; ++i)
704 for (unsigned int j = 0; j < dim; ++j)
705 for (unsigned int l = 0; l < dim; ++l)
706 for (unsigned int m = 0; m < dim; ++m)
707 for (unsigned int n = 0; n < dim; ++n)
708 jacobian_3rd_derivatives[point][i][j][l][m][n] =
709 result[i][j][l][m][n];
710 }
711 }
712 }
713 }
714
722 template <int dim, int spacedim>
723 void
724 maybe_update_jacobian_pushed_forward_3rd_derivatives(
725 const CellSimilarity::Similarity cell_similarity,
726 const typename QProjector<dim>::DataSetDescriptor data_set,
727 const typename ::MappingFE<dim, spacedim>::InternalData &data,
728 std::vector<Tensor<5, spacedim>>
729 &jacobian_pushed_forward_3rd_derivatives,
730 const unsigned int n_q_points)
731 {
732 const UpdateFlags update_flags = data.update_each;
734 {
735 AssertIndexRange(n_q_points,
736 jacobian_pushed_forward_3rd_derivatives.size() +
737 1);
738
739 if (cell_similarity != CellSimilarity::translation)
740 {
741 double tmp[spacedim][spacedim][spacedim][spacedim][spacedim];
742 for (unsigned int point = 0; point < n_q_points; ++point)
743 {
744 const Tensor<4, dim> *fourth =
745 &data.fourth_derivative(point + data_set, 0);
746 double result[spacedim][dim][dim][dim][dim];
747 for (unsigned int i = 0; i < spacedim; ++i)
748 for (unsigned int j = 0; j < dim; ++j)
749 for (unsigned int l = 0; l < dim; ++l)
750 for (unsigned int m = 0; m < dim; ++m)
751 for (unsigned int n = 0; n < dim; ++n)
752 result[i][j][l][m][n] =
753 (fourth[0][j][l][m][n] *
754 data.mapping_support_points[0][i]);
755 for (unsigned int k = 1; k < data.n_shape_functions; ++k)
756 for (unsigned int i = 0; i < spacedim; ++i)
757 for (unsigned int j = 0; j < dim; ++j)
758 for (unsigned int l = 0; l < dim; ++l)
759 for (unsigned int m = 0; m < dim; ++m)
760 for (unsigned int n = 0; n < dim; ++n)
761 result[i][j][l][m][n] +=
762 (fourth[k][j][l][m][n] *
763 data.mapping_support_points[k][i]);
764
765 // push-forward the j-coordinate
766 for (unsigned int i = 0; i < spacedim; ++i)
767 for (unsigned int j = 0; j < spacedim; ++j)
768 for (unsigned int l = 0; l < dim; ++l)
769 for (unsigned int m = 0; m < dim; ++m)
770 for (unsigned int n = 0; n < dim; ++n)
771 {
772 tmp[i][j][l][m][n] =
773 result[i][0][l][m][n] *
774 data.covariant[point][j][0];
775 for (unsigned int jr = 1; jr < dim; ++jr)
776 tmp[i][j][l][m][n] +=
777 result[i][jr][l][m][n] *
778 data.covariant[point][j][jr];
779 }
780
781 // push-forward the l-coordinate
782 for (unsigned int i = 0; i < spacedim; ++i)
783 for (unsigned int j = 0; j < spacedim; ++j)
784 for (unsigned int l = 0; l < spacedim; ++l)
785 for (unsigned int m = 0; m < dim; ++m)
786 for (unsigned int n = 0; n < dim; ++n)
787 {
788 jacobian_pushed_forward_3rd_derivatives
789 [point][i][j][l][m][n] =
790 tmp[i][j][0][m][n] *
791 data.covariant[point][l][0];
792 for (unsigned int lr = 1; lr < dim; ++lr)
793 jacobian_pushed_forward_3rd_derivatives
794 [point][i][j][l][m][n] +=
795 tmp[i][j][lr][m][n] *
796 data.covariant[point][l][lr];
797 }
798
799 // push-forward the m-coordinate
800 for (unsigned int i = 0; i < spacedim; ++i)
801 for (unsigned int j = 0; j < spacedim; ++j)
802 for (unsigned int l = 0; l < spacedim; ++l)
803 for (unsigned int m = 0; m < spacedim; ++m)
804 for (unsigned int n = 0; n < dim; ++n)
805 {
806 tmp[i][j][l][m][n] =
807 jacobian_pushed_forward_3rd_derivatives
808 [point][i][j][l][0][n] *
809 data.covariant[point][m][0];
810 for (unsigned int mr = 1; mr < dim; ++mr)
811 tmp[i][j][l][m][n] +=
812 jacobian_pushed_forward_3rd_derivatives
813 [point][i][j][l][mr][n] *
814 data.covariant[point][m][mr];
815 }
816
817 // push-forward the n-coordinate
818 for (unsigned int i = 0; i < spacedim; ++i)
819 for (unsigned int j = 0; j < spacedim; ++j)
820 for (unsigned int l = 0; l < spacedim; ++l)
821 for (unsigned int m = 0; m < spacedim; ++m)
822 for (unsigned int n = 0; n < spacedim; ++n)
823 {
824 jacobian_pushed_forward_3rd_derivatives
825 [point][i][j][l][m][n] =
826 tmp[i][j][l][m][0] *
827 data.covariant[point][n][0];
828 for (unsigned int nr = 1; nr < dim; ++nr)
829 jacobian_pushed_forward_3rd_derivatives
830 [point][i][j][l][m][n] +=
831 tmp[i][j][l][m][nr] *
832 data.covariant[point][n][nr];
833 }
834 }
835 }
836 }
837 }
838 } // namespace
839 } // namespace MappingFEImplementation
840} // namespace internal
841
842
843
844template <int dim, int spacedim>
846 : fe(fe.clone())
847 , polynomial_degree(fe.tensor_degree())
848{
850 ExcMessage("It only makes sense to create polynomial mappings "
851 "with a polynomial degree greater or equal to one."));
852 Assert(fe.n_components() == 1, ExcNotImplemented());
853
854 Assert(fe.has_support_points(), ExcNotImplemented());
855
856 const auto &mapping_support_points = fe.get_unit_support_points();
857
858 const auto reference_cell = fe.reference_cell();
859
860 const unsigned int n_points = mapping_support_points.size();
861 const unsigned int n_shape_functions = reference_cell.n_vertices();
862
864 Table<2, double>(n_points, n_shape_functions);
865
866 for (unsigned int point = 0; point < n_points; ++point)
867 for (unsigned int i = 0; i < n_shape_functions; ++i)
869 reference_cell.d_linear_shape_function(mapping_support_points[point],
870 i);
871}
872
873
874
875template <int dim, int spacedim>
877 : fe(mapping.fe->clone())
878 , polynomial_degree(mapping.polynomial_degree)
879 , mapping_support_point_weights(mapping.mapping_support_point_weights)
880{}
881
882
883
884template <int dim, int spacedim>
885std::unique_ptr<Mapping<dim, spacedim>>
887{
888 return std::make_unique<MappingFE<dim, spacedim>>(*this);
889}
890
891
892
893template <int dim, int spacedim>
894unsigned int
896{
897 return polynomial_degree;
898}
899
900
901
902template <int dim, int spacedim>
906 const Point<dim> &p) const
907{
908 const auto support_points = this->compute_mapping_support_points(cell);
909
910 Point<spacedim> mapped_point;
911
912 for (unsigned int i = 0; i < this->fe->n_dofs_per_cell(); ++i)
913 mapped_point += support_points[i] * this->fe->shape_value(i, p);
914
915 return mapped_point;
916}
917
918
919
920template <int dim, int spacedim>
924 const Point<spacedim> &p) const
925{
926 const auto support_points = this->compute_mapping_support_points(cell);
927
928 const double eps = 1.e-12 * cell->diameter();
929 const double step_reduction_factor = 0.5;
930 const unsigned int n_step_reductions = 10;
931 const unsigned int loop_limit = 10;
932
933 // Start the iteration from the inverse of the affine map through the
934 // vertices for simplices, which is exact for cells with straight edges, and
935 // from the barycenter of the reference cell otherwise. The barycenter is
936 // also the fallback if the iteration does not converge from the former or
937 // converges to a point outside of the reference cell, e.g., for strongly
938 // curved cells, where the affine map is a poor approximation or even
939 // inverted.
940 const ReferenceCell<dim> reference_cell = this->fe->reference_cell();
941
942 std::array<Point<dim>, 2> initial_guesses;
943 unsigned int n_initial_guesses = 0;
944 if (reference_cell.is_simplex() && this->fe->n_dofs_per_vertex() > 0)
945 {
946 // The first support points are the vertices, the vertices of the
947 // reference cell are the origin and the unit vectors. Least squares for
948 // spacedim > dim.
949 Tensor<2, dim> metric;
950 Tensor<1, dim> rhs;
951 for (unsigned int i = 0; i < dim; ++i)
952 {
953 const Tensor<1, spacedim> a_i =
954 support_points[i + 1] - support_points[0];
955 rhs[i] = a_i * (p - support_points[0]);
956 for (unsigned int j = 0; j < dim; ++j)
957 metric[i][j] = a_i * (support_points[j + 1] - support_points[0]);
958 }
959 if (determinant(metric) > 0.)
960 initial_guesses[n_initial_guesses++] = Point<dim>(invert(metric) * rhs);
961 }
962 initial_guesses[n_initial_guesses++] = reference_cell.barycenter();
963
964 // Evaluate the residual p - F(p_unit) and the transpose of the gradient of
965 // the map F.
966 const auto evaluate = [&](const Point<dim> &p_unit_trial,
967 Tensor<1, spacedim> &residual,
969 Point<spacedim> mapped_point;
971 for (unsigned int i = 0; i < this->fe->n_dofs_per_cell(); ++i)
972 {
973 mapped_point +=
974 support_points[i] * this->fe->shape_value(i, p_unit_trial);
975 const auto grad_F_i = this->fe->shape_grad(i, p_unit_trial);
976 for (unsigned int j = 0; j < dim; ++j)
977 grad_FT[j] += grad_F_i[j] * support_points[i];
978 }
979 residual = p - mapped_point;
980 };
981
982 // The map is in general not injective outside of the reference cell, i.e.,
983 // the iteration may converge to a preimage outside of the reference cell for
984 // a point inside the cell. Hence, the iteration is restarted from the
985 // barycenter for a result outside of the reference cell. If all results are
986 // outside, the point is assumed to be outside the cell and the result
987 // closest to the reference cell is returned.
988 const double tolerance_inside = 1.e-10;
989 bool found_outside = false;
990 Point<dim> p_unit_outside;
991 double distance_outside = 0.;
992
993 for (unsigned int g = 0; g < n_initial_guesses; ++g)
994 {
995 Point<dim> p_unit = initial_guesses[g];
996 Tensor<1, spacedim> residual;
998 evaluate(p_unit, residual, grad_FT);
999
1000 // This loop solves grad_F^T residual = 0 with the Gauss-Newton method,
1001 // i.e., the Newton method for dim == spacedim, reducing the step by the
1002 // step reduction factor until the residual decreases. The projection of
1003 // the residual on the reference coordinate system filters the
1004 // components orthogonal to the manifold for spacedim > dim.
1005 bool converged = apply_transformation(grad_FT, residual).norm() <= eps;
1006 for (unsigned int loop = 0; loop < loop_limit && !converged; ++loop)
1007 {
1008 const auto grad_FT_residual = apply_transformation(grad_FT, residual);
1009
1010 Tensor<2, dim> metric_tensor;
1011 for (unsigned int j = 0; j < dim; ++j)
1012 for (unsigned int l = 0; l < dim; ++l)
1013 metric_tensor[j][l] = grad_FT[j] * grad_FT[l];
1014 const Tensor<1, dim> step = invert(metric_tensor) * grad_FT_residual;
1015
1016 bool step_accepted = false;
1017 double step_length = 1.0;
1018 for (unsigned int i = 0; i < n_step_reductions && !step_accepted; ++i)
1019 {
1020 const Point<dim> p_unit_trial = p_unit + step_length * step;
1021
1022 Tensor<1, spacedim> residual_trial;
1024 evaluate(p_unit_trial, residual_trial, grad_FT_trial);
1025
1026 if (residual_trial.norm() < residual.norm())
1027 {
1028 p_unit = p_unit_trial;
1029 residual = residual_trial;
1030 grad_FT = grad_FT_trial;
1031 step_accepted = true;
1032 }
1033 else
1034 step_length *= step_reduction_factor;
1035 }
1036
1037 converged = apply_transformation(grad_FT, residual).norm() <= eps;
1038 if (!step_accepted)
1039 break;
1040 }
1041
1042 if (converged)
1043 {
1044 if (reference_cell.contains_point(p_unit, tolerance_inside))
1045 return p_unit;
1046
1047 const double distance =
1048 reference_cell.closest_point(p_unit).distance(p_unit);
1049 if (!found_outside || distance < distance_outside)
1050 {
1051 found_outside = true;
1052 p_unit_outside = p_unit;
1053 distance_outside = distance;
1054 }
1055 }
1056 }
1057
1058 AssertThrow(found_outside,
1060
1061 return p_unit_outside;
1062}
1063
1064
1065
1066template <int dim, int spacedim>
1069{
1070 // add flags if the respective quantities are necessary to compute
1071 // what we need. note that some flags appear in both the conditions
1072 // and in subsequent set operations. this leads to some circular
1073 // logic. the only way to treat this is to iterate. since there are
1074 // 5 if-clauses in the loop, it will take at most 5 iterations to
1075 // converge. do them:
1076 UpdateFlags out = in;
1077 for (unsigned int i = 0; i < 5; ++i)
1078 {
1079 // The following is a little incorrect:
1080 // If not applied on a face,
1081 // update_boundary_forms does not
1082 // make sense. On the other hand,
1083 // it is necessary on a
1084 // face. Currently,
1085 // update_boundary_forms is simply
1086 // ignored for the interior of a
1087 // cell.
1089 out |= update_boundary_forms;
1090
1095
1096 if (out &
1101
1102 // The contravariant transformation is used in the Piola
1103 // transformation, which requires the determinant of the Jacobi
1104 // matrix of the transformation. Because we have no way of
1105 // knowing here whether the finite element wants to use the
1106 // contravariant or the Piola transforms, we add the JxW values
1107 // to the list of flags to be updated for each cell.
1110
1111 // the same is true when computing normal vectors: they require
1112 // the determinant of the Jacobian
1113 if (out & update_normal_vectors)
1115 }
1116
1117 return out;
1118}
1119
1120
1121
1122template <int dim, int spacedim>
1123std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
1125 const Quadrature<dim> &q) const
1126{
1127 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr =
1128 std::make_unique<InternalData>(*this->fe);
1129 data_ptr->reinit(this->requires_update_flags(update_flags), q);
1130 return data_ptr;
1131}
1132
1133
1134
1135template <int dim, int spacedim>
1136std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
1138 const UpdateFlags update_flags,
1139 const hp::QCollection<dim - 1> &quadrature) const
1140{
1141 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr =
1142 std::make_unique<InternalData>(*this->fe);
1143 auto &data = dynamic_cast<InternalData &>(*data_ptr);
1144 data.initialize_face(this->requires_update_flags(update_flags),
1146 this->fe->reference_cell(), quadrature),
1147 quadrature.max_n_quadrature_points());
1148
1149 return data_ptr;
1150}
1151
1152
1153
1154template <int dim, int spacedim>
1155std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
1157 const UpdateFlags update_flags,
1158 const Quadrature<dim - 1> &quadrature) const
1159{
1160 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr =
1161 std::make_unique<InternalData>(*this->fe);
1162 auto &data = dynamic_cast<InternalData &>(*data_ptr);
1163 data.initialize_face(this->requires_update_flags(update_flags),
1165 this->fe->reference_cell(), quadrature),
1166 quadrature.size());
1167
1168 return data_ptr;
1169}
1170
1171
1172
1173template <int dim, int spacedim>
1177 const CellSimilarity::Similarity cell_similarity,
1178 const Quadrature<dim> &quadrature,
1179 const typename Mapping<dim, spacedim>::InternalDataBase &internal_data,
1181 &output_data) const
1182{
1183 // ensure that the following static_cast is really correct:
1184 Assert(dynamic_cast<const InternalData *>(&internal_data) != nullptr,
1186 const InternalData &data = static_cast<const InternalData &>(internal_data);
1187
1188 const unsigned int n_q_points = quadrature.size();
1189
1190 // recompute the support points of the transformation of this
1191 // cell. we tried to be clever here in an earlier version of the
1192 // library by checking whether the cell is the same as the one we
1193 // had visited last, but it turns out to be difficult to determine
1194 // that because a cell for the purposes of a mapping is
1195 // characterized not just by its (triangulation, level, index)
1196 // triple, but also by the locations of its vertices, the manifold
1197 // object attached to the cell and all of its bounding faces/edges,
1198 // etc. to reliably test that the "cell" we are on is, therefore,
1199 // not easily done
1200 const auto support_points = this->compute_mapping_support_points(cell);
1201 data.mapping_support_points.assign(support_points.begin(),
1202 support_points.end());
1203
1204 // if the order of the mapping is greater than 1, then do not reuse any cell
1205 // similarity information. This is necessary because the cell similarity
1206 // value is computed with just cell vertices and does not take into account
1207 // cell curvature.
1208 const CellSimilarity::Similarity computed_cell_similarity =
1209 (polynomial_degree == 1 ? cell_similarity : CellSimilarity::none);
1210
1211 internal::MappingFEImplementation::maybe_compute_q_points<dim, spacedim>(
1213 data,
1214 output_data.quadrature_points,
1215 n_q_points);
1216
1217 internal::MappingFEImplementation::maybe_update_Jacobians<dim, spacedim>(
1218 computed_cell_similarity,
1220 data,
1221 n_q_points);
1222
1223 internal::MappingFEImplementation::maybe_update_jacobian_grads<dim, spacedim>(
1224 computed_cell_similarity,
1226 data,
1227 output_data.jacobian_grads,
1228 n_q_points);
1229
1230 internal::MappingFEImplementation::maybe_update_jacobian_pushed_forward_grads<
1231 dim,
1232 spacedim>(computed_cell_similarity,
1234 data,
1236 n_q_points);
1237
1238 internal::MappingFEImplementation::maybe_update_jacobian_2nd_derivatives<
1239 dim,
1240 spacedim>(computed_cell_similarity,
1242 data,
1243 output_data.jacobian_2nd_derivatives,
1244 n_q_points);
1245
1246 internal::MappingFEImplementation::
1247 maybe_update_jacobian_pushed_forward_2nd_derivatives<dim, spacedim>(
1248 computed_cell_similarity,
1250 data,
1252 n_q_points);
1253
1254 internal::MappingFEImplementation::maybe_update_jacobian_3rd_derivatives<
1255 dim,
1256 spacedim>(computed_cell_similarity,
1258 data,
1259 output_data.jacobian_3rd_derivatives,
1260 n_q_points);
1261
1262 internal::MappingFEImplementation::
1263 maybe_update_jacobian_pushed_forward_3rd_derivatives<dim, spacedim>(
1264 computed_cell_similarity,
1266 data,
1268 n_q_points);
1269
1270 const UpdateFlags update_flags = data.update_each;
1271 const std::vector<double> &weights = quadrature.get_weights();
1272
1273 // Multiply quadrature weights by absolute value of Jacobian determinants or
1274 // the area element g=sqrt(DX^t DX) in case of codim > 0
1275
1276 if (update_flags & (update_normal_vectors | update_JxW_values))
1277 {
1278 AssertDimension(output_data.JxW_values.size(), n_q_points);
1279
1280 Assert(!(update_flags & update_normal_vectors) ||
1281 (output_data.normal_vectors.size() == n_q_points),
1282 ExcDimensionMismatch(output_data.normal_vectors.size(),
1283 n_q_points));
1284
1285
1286 if (computed_cell_similarity != CellSimilarity::translation)
1287 for (unsigned int point = 0; point < n_q_points; ++point)
1288 {
1289 if (dim == spacedim)
1290 {
1291 const double det = data.contravariant[point].determinant();
1292
1293 // check for distorted cells.
1294
1295 // TODO: this allows for anisotropies of up to 1e6 in 3d and
1296 // 1e12 in 2d. might want to find a finer
1297 // (dimension-independent) criterion
1298 Assert(det >
1299 1e-12 * Utilities::fixed_power<dim>(
1300 cell->diameter() / std::sqrt(double(dim))),
1302 cell->center(), det, point)));
1303
1304 output_data.JxW_values[point] = weights[point] * det;
1305 }
1306 // if dim==spacedim, then there is no cell normal to
1307 // compute. since this is for FEValues (and not FEFaceValues),
1308 // there are also no face normals to compute
1309 else // codim>0 case
1310 {
1311 Tensor<1, spacedim> DX_t[dim];
1312 for (unsigned int i = 0; i < spacedim; ++i)
1313 for (unsigned int j = 0; j < dim; ++j)
1314 DX_t[j][i] = data.contravariant[point][i][j];
1315
1316 Tensor<2, dim> G; // First fundamental form
1317 for (unsigned int i = 0; i < dim; ++i)
1318 for (unsigned int j = 0; j < dim; ++j)
1319 G[i][j] = DX_t[i] * DX_t[j];
1320
1321 output_data.JxW_values[point] =
1322 std::sqrt(determinant(G)) * weights[point];
1323
1324 if (computed_cell_similarity ==
1326 {
1327 // we only need to flip the normal
1328 if (update_flags & update_normal_vectors)
1329 output_data.normal_vectors[point] *= -1.;
1330 }
1331 else
1332 {
1333 if (update_flags & update_normal_vectors)
1334 {
1335 Assert(spacedim == dim + 1,
1336 ExcMessage(
1337 "There is no (unique) cell normal for " +
1339 "-dimensional cells in " +
1340 Utilities::int_to_string(spacedim) +
1341 "-dimensional space. This only works if the "
1342 "space dimension is one greater than the "
1343 "dimensionality of the mesh cells."));
1344
1345 if (dim == 1)
1346 output_data.normal_vectors[point] =
1347 cross_product_2d(-DX_t[0]);
1348 else // dim == 2
1349 output_data.normal_vectors[point] =
1350 cross_product_3d(DX_t[0], DX_t[1]);
1351
1352 output_data.normal_vectors[point] /=
1353 output_data.normal_vectors[point].norm();
1354
1355 if (cell->direction_flag() == false)
1356 output_data.normal_vectors[point] *= -1.;
1357 }
1358 }
1359 } // codim>0 case
1360 }
1361 }
1362
1363
1364
1365 // copy values from InternalData to vector given by reference
1366 if (update_flags & update_jacobians)
1367 {
1368 AssertDimension(output_data.jacobians.size(), n_q_points);
1369 if (computed_cell_similarity != CellSimilarity::translation)
1370 for (unsigned int point = 0; point < n_q_points; ++point)
1371 output_data.jacobians[point] = data.contravariant[point];
1372 }
1373
1374 // copy values from InternalData to vector given by reference
1375 if (update_flags & update_inverse_jacobians)
1376 {
1377 AssertDimension(output_data.inverse_jacobians.size(), n_q_points);
1378 if (computed_cell_similarity != CellSimilarity::translation)
1379 for (unsigned int point = 0; point < n_q_points; ++point)
1380 output_data.inverse_jacobians[point] =
1381 data.covariant[point].transpose();
1382 }
1383
1384 return computed_cell_similarity;
1385}
1386
1387
1388
1389namespace internal
1390{
1391 namespace MappingFEImplementation
1392 {
1393 namespace
1394 {
1405 template <int dim, int spacedim>
1406 void
1407 maybe_compute_face_data(
1408 const ::MappingFE<dim, spacedim> &mapping,
1409 const typename ::Triangulation<dim, spacedim>::cell_iterator
1410 &cell,
1411 const unsigned int face_no,
1412 const unsigned int subface_no,
1413 const unsigned int n_q_points,
1414 const typename QProjector<dim>::DataSetDescriptor data_set,
1415 const typename ::MappingFE<dim, spacedim>::InternalData &data,
1417 &output_data)
1418 {
1419 const UpdateFlags update_flags = data.update_each;
1420
1421 if (update_flags &
1424 {
1425 if (update_flags & update_boundary_forms)
1426 AssertIndexRange(n_q_points,
1427 output_data.boundary_forms.size() + 1);
1428 if (update_flags & update_normal_vectors)
1429 AssertIndexRange(n_q_points,
1430 output_data.normal_vectors.size() + 1);
1431 if (update_flags & update_JxW_values)
1432 AssertIndexRange(n_q_points, output_data.JxW_values.size() + 1);
1433
1434 Assert(data.aux.size() + 1 >= dim, ExcInternalError());
1435
1436 // first compute some common data that is used for evaluating
1437 // all of the flags below
1438
1439 // map the unit tangentials to the real cell. checking for
1440 // d!=dim-1 eliminates compiler warnings regarding unsigned int
1441 // expressions < 0.
1442 for (unsigned int d = 0; d != dim - 1; ++d)
1443 {
1444 Assert(face_no + cell->n_faces() * d <
1445 data.unit_tangentials.size(),
1447 Assert(
1448 data.aux[d].size() <=
1449 data.unit_tangentials[face_no + cell->n_faces() * d].size(),
1451
1452 mapping.transform(
1454 data.unit_tangentials[face_no + cell->n_faces() * d]),
1456 data,
1457 make_array_view(data.aux[d]));
1458 }
1459
1460 if (update_flags & update_boundary_forms)
1461 {
1462 // if dim==spacedim, we can use the unit tangentials to
1463 // compute the boundary form by simply taking the cross
1464 // product
1465 if (dim == spacedim)
1466 {
1467 for (unsigned int i = 0; i < n_q_points; ++i)
1468 switch (dim)
1469 {
1470 case 1:
1471 // in 1d, we don't have access to any of the
1472 // data.aux fields (because it has only dim-1
1473 // components), but we can still compute the
1474 // boundary form by simply looking at the number
1475 // of the face
1476 output_data.boundary_forms[i][0] =
1477 (face_no == 0 ? -1 : +1);
1478 break;
1479 case 2:
1480 output_data.boundary_forms[i] =
1481 cross_product_2d(data.aux[0][i]);
1482 break;
1483 case 3:
1484 output_data.boundary_forms[i] =
1485 cross_product_3d(data.aux[0][i], data.aux[1][i]);
1486 break;
1487 default:
1489 }
1490 }
1491 else //(dim < spacedim)
1492 {
1493 // in the codim-one case, the boundary form results from
1494 // the cross product of all the face tangential vectors
1495 // and the cell normal vector
1496 //
1497 // to compute the cell normal, use the same method used in
1498 // fill_fe_values for cells above
1499 AssertIndexRange(n_q_points, data.contravariant.size() + 1);
1500
1501 for (unsigned int point = 0; point < n_q_points; ++point)
1502 {
1503 if (dim == 1)
1504 {
1505 // J is a tangent vector
1506 output_data.boundary_forms[point] =
1507 data.contravariant[point].transpose()[0];
1508 output_data.boundary_forms[point] /=
1509 (face_no == 0 ? -1. : +1.) *
1510 output_data.boundary_forms[point].norm();
1511 }
1512
1513 if (dim == 2)
1514 {
1516 data.contravariant[point].transpose();
1517
1518 Tensor<1, spacedim> cell_normal =
1519 cross_product_3d(DX_t[0], DX_t[1]);
1520 cell_normal /= cell_normal.norm();
1521
1522 // then compute the face normal from the face
1523 // tangent and the cell normal:
1524 output_data.boundary_forms[point] =
1525 cross_product_3d(data.aux[0][point], cell_normal);
1526 }
1527 }
1528 }
1529 }
1530
1531 if (update_flags & update_JxW_values)
1532 for (unsigned int i = 0; i < n_q_points; ++i)
1533 {
1534 output_data.JxW_values[i] =
1535 output_data.boundary_forms[i].norm() *
1536 data.quadrature_weights[i + data_set];
1537
1538 if (subface_no != numbers::invalid_unsigned_int)
1539 {
1540 if (dim == 2)
1541 {
1542 const double area_ratio =
1543 1. / cell->reference_cell()
1544 .face_reference_cell(face_no)
1545 .n_isotropic_children();
1546 output_data.JxW_values[i] *= area_ratio;
1547 }
1548 else
1550 }
1551 }
1552
1553 if (update_flags & update_normal_vectors)
1554 for (unsigned int i = 0; i < n_q_points; ++i)
1555 output_data.normal_vectors[i] =
1556 Point<spacedim>(output_data.boundary_forms[i] /
1557 output_data.boundary_forms[i].norm());
1558
1559 if (update_flags & update_jacobians)
1560 for (unsigned int point = 0; point < n_q_points; ++point)
1561 output_data.jacobians[point] = data.contravariant[point];
1562
1563 if (update_flags & update_inverse_jacobians)
1564 for (unsigned int point = 0; point < n_q_points; ++point)
1565 output_data.inverse_jacobians[point] =
1566 data.covariant[point].transpose();
1567 }
1568 }
1569
1570
1577 template <int dim, int spacedim>
1578 void
1580 const ::MappingFE<dim, spacedim> &mapping,
1581 const typename ::Triangulation<dim, spacedim>::cell_iterator
1582 &cell,
1583 const unsigned int face_no,
1584 const unsigned int subface_no,
1585 const typename QProjector<dim>::DataSetDescriptor data_set,
1586 const Quadrature<dim - 1> &quadrature,
1587 const typename ::MappingFE<dim, spacedim>::InternalData &data,
1589 &output_data)
1590 {
1591 const unsigned int n_q_points = quadrature.size();
1592
1593 maybe_compute_q_points<dim, spacedim>(data_set,
1594 data,
1595 output_data.quadrature_points,
1596 n_q_points);
1597 maybe_update_Jacobians<dim, spacedim>(CellSimilarity::none,
1598 data_set,
1599 data,
1600 n_q_points);
1601 maybe_update_jacobian_grads<dim, spacedim>(CellSimilarity::none,
1602 data_set,
1603 data,
1604 output_data.jacobian_grads,
1605 n_q_points);
1606 maybe_update_jacobian_pushed_forward_grads<dim, spacedim>(
1608 data_set,
1609 data,
1611 n_q_points);
1612 maybe_update_jacobian_2nd_derivatives<dim, spacedim>(
1614 data_set,
1615 data,
1616 output_data.jacobian_2nd_derivatives,
1617 n_q_points);
1618 maybe_update_jacobian_pushed_forward_2nd_derivatives<dim, spacedim>(
1620 data_set,
1621 data,
1623 n_q_points);
1624 maybe_update_jacobian_3rd_derivatives<dim, spacedim>(
1626 data_set,
1627 data,
1628 output_data.jacobian_3rd_derivatives,
1629 n_q_points);
1630 maybe_update_jacobian_pushed_forward_3rd_derivatives<dim, spacedim>(
1632 data_set,
1633 data,
1635 n_q_points);
1636
1638 cell,
1639 face_no,
1640 subface_no,
1641 n_q_points,
1642 data_set,
1643 data,
1644 output_data);
1645 }
1646 } // namespace
1647 } // namespace MappingFEImplementation
1648} // namespace internal
1649
1650
1651
1652template <int dim, int spacedim>
1653void
1656 const unsigned int face_no,
1657 const hp::QCollection<dim - 1> &quadrature,
1658 const typename Mapping<dim, spacedim>::InternalDataBase &internal_data,
1660 &output_data) const
1661{
1662 // ensure that the following cast is really correct:
1663 Assert((dynamic_cast<const InternalData *>(&internal_data) != nullptr),
1665 const InternalData &data = static_cast<const InternalData &>(internal_data);
1666
1667 const auto support_points = this->compute_mapping_support_points(cell);
1668 data.mapping_support_points.assign(support_points.begin(),
1669 support_points.end());
1670
1671 internal::MappingFEImplementation::do_fill_fe_face_values(
1672 *this,
1673 cell,
1674 face_no,
1676 QProjector<dim>::DataSetDescriptor::face(this->fe->reference_cell(),
1677 face_no,
1678 cell->combined_face_orientation(
1679 face_no),
1680 quadrature),
1681 quadrature[quadrature.size() == 1 ? 0 : face_no],
1682 data,
1683 output_data);
1684}
1685
1686
1687
1688template <int dim, int spacedim>
1689void
1692 const unsigned int face_no,
1693 const unsigned int subface_no,
1694 const Quadrature<dim - 1> &quadrature,
1695 const typename Mapping<dim, spacedim>::InternalDataBase &internal_data,
1697 &output_data) const
1698{
1699 // ensure that the following cast is really correct:
1700 Assert((dynamic_cast<const InternalData *>(&internal_data) != nullptr),
1702 const InternalData &data = static_cast<const InternalData &>(internal_data);
1703
1704 const auto support_points = this->compute_mapping_support_points(cell);
1705 data.mapping_support_points.assign(support_points.begin(),
1706 support_points.end());
1707
1708 internal::MappingFEImplementation::do_fill_fe_face_values(
1709 *this,
1710 cell,
1711 face_no,
1712 subface_no,
1713 QProjector<dim>::DataSetDescriptor::subface(this->fe->reference_cell(),
1714 face_no,
1715 subface_no,
1716 cell->combined_face_orientation(
1717 face_no),
1718 quadrature.size(),
1719 cell->subface_case(face_no)),
1720 quadrature,
1721 data,
1722 output_data);
1723}
1724
1725
1726
1727namespace internal
1728{
1729 namespace MappingFEImplementation
1730 {
1731 namespace
1732 {
1733 template <int dim, int spacedim, int rank>
1734 void
1735 transform_fields(
1736 const ArrayView<const Tensor<rank, dim>> &input,
1737 const MappingKind mapping_kind,
1738 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data,
1739 const ArrayView<Tensor<rank, spacedim>> &output)
1740 {
1741 // In the case of wedges and pyramids, faces might have different
1742 // numbers of quadrature points on each face with the result
1743 // that input and output have different sizes, since input has
1744 // the correct size but the size of output is the maximum of
1745 // all possible sizes.
1746 AssertIndexRange(input.size(), output.size() + 1);
1747
1748 Assert(
1749 (dynamic_cast<
1750 const typename ::MappingFE<dim, spacedim>::InternalData *>(
1751 &mapping_data) != nullptr),
1753 const typename ::MappingFE<dim, spacedim>::InternalData &data =
1754 static_cast<
1755 const typename ::MappingFE<dim, spacedim>::InternalData &>(
1756 mapping_data);
1757
1758 switch (mapping_kind)
1759 {
1761 {
1762 Assert(
1765 "update_contravariant_transformation"));
1766
1767 for (unsigned int i = 0; i < input.size(); ++i)
1768 output[i] =
1769 apply_transformation(data.contravariant[i], input[i]);
1770
1771 return;
1772 }
1773
1774 case mapping_piola:
1775 {
1776 Assert(
1779 "update_contravariant_transformation"));
1780 Assert(
1781 data.update_each & update_volume_elements,
1783 "update_volume_elements"));
1784 Assert(rank == 1, ExcMessage("Only for rank 1"));
1785 if (rank != 1)
1786 return;
1787
1788 for (unsigned int i = 0; i < input.size(); ++i)
1789 {
1790 output[i] =
1791 apply_transformation(data.contravariant[i], input[i]);
1792 output[i] /= data.volume_elements[i];
1793 }
1794 return;
1795 }
1796 // We still allow this operation as in the
1797 // reference cell Derivatives are Tensor
1798 // rather than DerivativeForm
1799 case mapping_covariant:
1800 {
1801 Assert(
1804 "update_covariant_transformation"));
1805
1806 for (unsigned int i = 0; i < input.size(); ++i)
1807 output[i] = apply_transformation(data.covariant[i], input[i]);
1808
1809 return;
1810 }
1811
1812 default:
1814 }
1815 }
1816
1817
1818 template <int dim, int spacedim, int rank>
1819 void
1821 const ArrayView<const Tensor<rank, dim>> &input,
1822 const MappingKind mapping_kind,
1823 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data,
1824 const ArrayView<Tensor<rank, spacedim>> &output)
1825 {
1826 AssertDimension(input.size(), output.size());
1827 Assert(
1828 (dynamic_cast<
1829 const typename ::MappingFE<dim, spacedim>::InternalData *>(
1830 &mapping_data) != nullptr),
1832 const typename ::MappingFE<dim, spacedim>::InternalData &data =
1833 static_cast<
1834 const typename ::MappingFE<dim, spacedim>::InternalData &>(
1835 mapping_data);
1836
1837 switch (mapping_kind)
1838 {
1840 {
1841 Assert(
1844 "update_covariant_transformation"));
1845 Assert(
1848 "update_contravariant_transformation"));
1849 Assert(rank == 2, ExcMessage("Only for rank 2"));
1850
1851 for (unsigned int i = 0; i < output.size(); ++i)
1852 {
1854 apply_transformation(data.contravariant[i],
1855 transpose(input[i]));
1856 output[i] =
1857 apply_transformation(data.covariant[i], A.transpose());
1858 }
1859
1860 return;
1861 }
1862
1864 {
1865 Assert(
1868 "update_covariant_transformation"));
1869 Assert(rank == 2, ExcMessage("Only for rank 2"));
1870
1871 for (unsigned int i = 0; i < output.size(); ++i)
1872 if constexpr (dim == spacedim)
1874 input[i], static_cast<Tensor<2, dim>>(data.covariant[i]));
1875 else
1876 {
1878 apply_transformation(data.covariant[i],
1879 transpose(input[i]));
1880 output[i] =
1881 apply_transformation(data.covariant[i], A.transpose());
1882 }
1883
1884 return;
1885 }
1886
1888 {
1889 Assert(
1892 "update_covariant_transformation"));
1893 Assert(
1896 "update_contravariant_transformation"));
1897 Assert(
1898 data.update_each & update_volume_elements,
1900 "update_volume_elements"));
1901 Assert(rank == 2, ExcMessage("Only for rank 2"));
1902
1903 for (unsigned int i = 0; i < output.size(); ++i)
1904 output[i] =
1906 data.contravariant[i],
1907 data.volume_elements[i],
1908 input[i]);
1909
1910 return;
1911 }
1912
1913 default:
1915 }
1916 }
1917
1918
1919
1920 template <int dim, int spacedim>
1921 void
1923 const ArrayView<const Tensor<3, dim>> &input,
1924 const MappingKind mapping_kind,
1925 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data,
1926 const ArrayView<Tensor<3, spacedim>> &output)
1927 {
1928 AssertDimension(input.size(), output.size());
1929 Assert(
1930 (dynamic_cast<
1931 const typename ::MappingFE<dim, spacedim>::InternalData *>(
1932 &mapping_data) != nullptr),
1934 const typename ::MappingFE<dim, spacedim>::InternalData &data =
1935 static_cast<
1936 const typename ::MappingFE<dim, spacedim>::InternalData &>(
1937 mapping_data);
1938
1939 switch (mapping_kind)
1940 {
1942 {
1943 Assert(
1946 "update_covariant_transformation"));
1947 Assert(
1950 "update_contravariant_transformation"));
1951
1952 for (unsigned int q = 0; q < output.size(); ++q)
1953 output[q] =
1955 data.contravariant[q],
1956 input[q]);
1957
1958 return;
1959 }
1960
1962 {
1963 Assert(
1966 "update_covariant_transformation"));
1967
1968 for (unsigned int q = 0; q < output.size(); ++q)
1969 output[q] =
1971 input[q]);
1972
1973 return;
1974 }
1975
1977 {
1978 Assert(
1981 "update_covariant_transformation"));
1982 Assert(
1985 "update_contravariant_transformation"));
1986 Assert(
1987 data.update_each & update_volume_elements,
1989 "update_volume_elements"));
1990
1991 for (unsigned int q = 0; q < output.size(); ++q)
1992 output[q] =
1994 data.contravariant[q],
1995 data.volume_elements[q],
1996 input[q]);
1997
1998 return;
1999 }
2000
2001 default:
2003 }
2004 }
2005
2006
2007
2008 template <int dim, int spacedim, int rank>
2009 void
2012 const MappingKind mapping_kind,
2013 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data,
2015 {
2016 AssertDimension(input.size(), output.size());
2017 Assert(
2018 (dynamic_cast<
2019 const typename ::MappingFE<dim, spacedim>::InternalData *>(
2020 &mapping_data) != nullptr),
2022 const typename ::MappingFE<dim, spacedim>::InternalData &data =
2023 static_cast<
2024 const typename ::MappingFE<dim, spacedim>::InternalData &>(
2025 mapping_data);
2026
2027 switch (mapping_kind)
2028 {
2029 case mapping_covariant:
2030 {
2031 Assert(
2034 "update_covariant_transformation"));
2035
2036 for (unsigned int i = 0; i < output.size(); ++i)
2037 output[i] = apply_transformation(data.covariant[i], input[i]);
2038
2039 return;
2040 }
2041 default:
2043 }
2044 }
2045 } // namespace
2046 } // namespace MappingFEImplementation
2047} // namespace internal
2048
2049
2050
2051template <int dim, int spacedim>
2052void
2054 const ArrayView<const Tensor<1, dim>> &input,
2055 const MappingKind mapping_kind,
2056 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data,
2057 const ArrayView<Tensor<1, spacedim>> &output) const
2058{
2059 internal::MappingFEImplementation::transform_fields(input,
2060 mapping_kind,
2061 mapping_data,
2062 output);
2063}
2064
2065
2066
2067template <int dim, int spacedim>
2068void
2070 const ArrayView<const DerivativeForm<1, dim, spacedim>> &input,
2071 const MappingKind mapping_kind,
2072 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data,
2073 const ArrayView<Tensor<2, spacedim>> &output) const
2074{
2075 internal::MappingFEImplementation::transform_differential_forms(input,
2076 mapping_kind,
2077 mapping_data,
2078 output);
2079}
2080
2081
2082
2083template <int dim, int spacedim>
2084void
2086 const ArrayView<const Tensor<2, dim>> &input,
2087 const MappingKind mapping_kind,
2088 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data,
2089 const ArrayView<Tensor<2, spacedim>> &output) const
2090{
2091 switch (mapping_kind)
2092 {
2094 internal::MappingFEImplementation::transform_fields(input,
2095 mapping_kind,
2096 mapping_data,
2097 output);
2098 return;
2099
2103 internal::MappingFEImplementation::transform_gradients(input,
2104 mapping_kind,
2105 mapping_data,
2106 output);
2107 return;
2108 default:
2110 }
2111}
2112
2113
2114
2115template <int dim, int spacedim>
2116void
2118 const ArrayView<const DerivativeForm<2, dim, spacedim>> &input,
2119 const MappingKind mapping_kind,
2120 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data,
2121 const ArrayView<Tensor<3, spacedim>> &output) const
2122{
2123 AssertDimension(input.size(), output.size());
2124 Assert(dynamic_cast<const InternalData *>(&mapping_data) != nullptr,
2126 const InternalData &data = static_cast<const InternalData &>(mapping_data);
2127
2128 switch (mapping_kind)
2129 {
2131 {
2134 "update_covariant_transformation"));
2135
2136 for (unsigned int q = 0; q < output.size(); ++q)
2137 output[q] =
2138 internal::apply_covariant_gradient(data.covariant[q], input[q]);
2139
2140 return;
2141 }
2142
2143 default:
2145 }
2146}
2147
2148
2149
2150template <int dim, int spacedim>
2151void
2153 const ArrayView<const Tensor<3, dim>> &input,
2154 const MappingKind mapping_kind,
2155 const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data,
2156 const ArrayView<Tensor<3, spacedim>> &output) const
2157{
2158 switch (mapping_kind)
2159 {
2163 internal::MappingFEImplementation::transform_hessians(input,
2164 mapping_kind,
2165 mapping_data,
2166 output);
2167 return;
2168 default:
2170 }
2171}
2172
2173
2174
2175namespace
2176{
2177 template <int spacedim>
2178 bool
2179 check_all_manifold_ids_identical(
2181 {
2182 return true;
2183 }
2184
2185
2186
2187 template <int spacedim>
2188 bool
2189 check_all_manifold_ids_identical(
2191 {
2192 const auto m_id = cell->manifold_id();
2193
2194 for (const auto f : cell->face_indices())
2195 if (m_id != cell->face(f)->manifold_id())
2196 return false;
2197
2198 return true;
2199 }
2200
2201
2202
2203 template <int spacedim>
2204 bool
2205 check_all_manifold_ids_identical(
2207 {
2208 const auto m_id = cell->manifold_id();
2209
2210 for (const auto f : cell->face_indices())
2211 if (m_id != cell->face(f)->manifold_id())
2212 return false;
2213
2214 for (const auto l : cell->line_indices())
2215 if (m_id != cell->line(l)->manifold_id())
2216 return false;
2217
2218 return true;
2219 }
2220} // namespace
2221
2222
2223
2224template <int dim, int spacedim>
2225boost::container::small_vector<Point<spacedim>, 200>
2227 const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
2228{
2229 boost::container::small_vector<Point<spacedim>, 200> points;
2231 ReferenceCells::max_n_vertices<dim>()>
2232 vertices(cell->n_vertices());
2233 for (const unsigned int i : cell->vertex_indices())
2234 vertices[i] = cell->vertex(i);
2235
2236 points.resize(mapping_support_point_weights.size(0));
2237 if (check_all_manifold_ids_identical(cell))
2238 {
2239 // version 1) all geometric entities have the same manifold:
2240 cell->get_manifold().get_new_points(ArrayView<const Point<spacedim>>(
2241 vertices),
2242 mapping_support_point_weights,
2243 ArrayView<Point<spacedim>>(points));
2244 }
2245 else
2246 {
2247 // version 1) geometric entities have different manifold
2248
2249 // helper function to compute mapped points on subentities
2250 // note[PM]: this function currently only uses the vertices
2251 // of cells to create new points on subentities; however,
2252 // one should use all bounding points to create new points
2253 // as in the case of MappingQ.
2254 const auto process = [&](const auto &manifold,
2255 const auto &indices,
2256 const unsigned n_points) {
2257 if ((indices.size() == 0) || (n_points == 0))
2258 return;
2259
2260 const unsigned int n_shape_functions =
2261 this->fe->reference_cell().n_vertices();
2262
2263 Table<2, double> mapping_support_point_weights_local(n_points,
2264 n_shape_functions);
2265 std::vector<Point<spacedim>> mapping_support_points_local(n_points);
2266
2267 for (unsigned int p = 0; p < n_points; ++p)
2268 for (unsigned int i = 0; i < n_shape_functions; ++i)
2269 mapping_support_point_weights_local(p, i) =
2270 mapping_support_point_weights(
2271 indices[p + (indices.size() - n_points)], i);
2272
2273 manifold.get_new_points(ArrayView<const Point<spacedim>>(vertices),
2274 mapping_support_point_weights_local,
2276 mapping_support_points_local));
2277
2278 for (unsigned int p = 0; p < n_points; ++p)
2279 points[indices[p + (indices.size() - n_points)]] =
2280 mapping_support_points_local[p];
2281 };
2282
2283 // create dummy DoFHandler to extract indices on subobjects
2284 const auto &fe = *this->fe;
2286 GridGenerator::reference_cell(tria, fe.reference_cell());
2287 DoFHandler<dim, spacedim> dof_handler(tria);
2288 dof_handler.distribute_dofs(fe);
2289 const auto &cell_ref = dof_handler.begin_active();
2290
2291 std::vector<types::global_dof_index> indices;
2292
2293 // add vertices
2294 for (const unsigned int i : cell->vertex_indices())
2295 points[i] = vertices[i];
2296
2297 // process and add line support points
2298 for (unsigned int l = 0; l < cell_ref->n_lines(); ++l)
2299 {
2300 const auto accessor = cell_ref->line(l);
2301 indices.resize(fe.n_dofs_per_line() + 2 * fe.n_dofs_per_vertex());
2302 accessor->get_dof_indices(indices);
2303 process(cell->line(l)->get_manifold(), indices, fe.n_dofs_per_line());
2304 }
2305
2306 // process and add face support points
2307 if constexpr (dim >= 3)
2308 {
2309 for (unsigned int f = 0; f < cell_ref->n_faces(); ++f)
2310 {
2311 const auto accessor = cell_ref->face(f);
2312 indices.resize(fe.n_dofs_per_face());
2313 accessor->get_dof_indices(indices);
2314 process(cell->face(f)->get_manifold(),
2315 indices,
2316 fe.n_dofs_per_quad());
2317 }
2318 }
2319
2320 // process and add volume support points
2321 if constexpr (dim >= 2)
2322 {
2323 indices.resize(fe.n_dofs_per_cell());
2324 cell_ref->get_dof_indices(indices);
2325 process(cell->get_manifold(),
2326 indices,
2327 (dim == 2) ? fe.n_dofs_per_quad() : fe.n_dofs_per_hex());
2328 }
2329 }
2330
2331 return points;
2332}
2333
2334
2335
2336template <int dim, int spacedim>
2339 const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
2340{
2341 return BoundingBox<spacedim>(this->compute_mapping_support_points(cell));
2342}
2343
2344
2345
2346template <int dim, int spacedim>
2347bool
2349 const ReferenceCell<dim> &reference_cell) const
2350{
2351 Assert(dim == reference_cell.get_dimension(),
2352 ExcMessage("The dimension of your mapping (" +
2354 ") and the reference cell cell_type (" +
2355 Utilities::to_string(reference_cell.get_dimension()) +
2356 " ) do not agree."));
2357
2358 return fe->reference_cell() == reference_cell;
2359}
2360
2361
2362
2363//--------------------------- Explicit instantiations -----------------------
2364#include "fe/mapping_fe.inst"
2365
2366
*  iterator end()
*  *  iterator begin()
ArrayView< std::remove_reference_t< typename std::iterator_traits< Iterator >::reference >, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
DerivativeForm< 1, spacedim, dim, Number > transpose() const
void distribute_dofs(const FiniteElement< dim, spacedim > &fe)
active_cell_iterator begin_active(const unsigned int level=0) const
void initialize_face(const UpdateFlags update_flags, const Quadrature< dim > &quadrature, const unsigned int n_original_q_points)
void compute_shape_function_values(const std::vector< Point< dim > > &unit_points)
virtual std::size_t memory_consumption() const override
Definition mapping_fe.cc:62
InternalData(const FiniteElement< dim, spacedim > &fe)
Definition mapping_fe.cc:51
virtual void reinit(const UpdateFlags update_flags, const Quadrature< dim > &quadrature) override
Definition mapping_fe.cc:81
virtual CellSimilarity::Similarity fill_fe_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellSimilarity::Similarity cell_similarity, const Quadrature< dim > &quadrature, const typename Mapping< dim, spacedim >::InternalDataBase &internal_data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const override
const unsigned int polynomial_degree
Definition mapping_fe.h:456
MappingFE(const FiniteElement< dim, spacedim > &fe)
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_face_data(const UpdateFlags flags, const hp::QCollection< dim - 1 > &quadrature) const override
virtual Point< dim > transform_real_to_unit_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< spacedim > &p) const override
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
virtual boost::container::small_vector< Point< spacedim >, 200 > compute_mapping_support_points(const typename Triangulation< dim, spacedim >::cell_iterator &cell) 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 typename Mapping< dim, spacedim >::InternalDataBase &internal_data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const override
Table< 2, double > mapping_support_point_weights
Definition mapping_fe.h:466
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 override
virtual BoundingBox< spacedim > get_bounding_box(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const override
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_data(const UpdateFlags, const Quadrature< dim > &quadrature) const override
virtual bool is_compatible_with(const ReferenceCell< dim > &reference_cell) const override
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_subface_data(const UpdateFlags flags, const Quadrature< dim - 1 > &quadrature) const override
unsigned int get_degree() const
virtual void fill_fe_subface_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const unsigned int subface_no, const Quadrature< dim - 1 > &quadrature, const typename Mapping< dim, spacedim >::InternalDataBase &internal_data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const override
virtual std::unique_ptr< Mapping< dim, spacedim > > clone() const override
virtual Point< spacedim > transform_unit_to_real_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< dim > &p) const override
const std::unique_ptr< FiniteElement< dim, spacedim > > fe
Definition mapping_fe.h:450
Abstract base class for mapping classes.
Definition mapping.h:318
Definition point.h:111
Class storing the offset index into a Quadrature rule created by project_to_all_faces() or project_to...
Definition qprojector.h:204
static DataSetDescriptor cell()
Definition qprojector.h:314
Class which transforms dim - 1-dimensional quadrature rules to dim-dimensional face quadratures.
Definition qprojector.h:68
const std::vector< double > & get_weights() const
const std::vector< Point< dim > > & get_points() const
unsigned int size() const
numbers::NumberTraits< Number >::real_type norm() const
unsigned int size() const
Definition collection.h:314
unsigned int max_n_quadrature_points() const
std::vector< DerivativeForm< 1, spacedim, dim > > inverse_jacobians
std::vector< Tensor< 5, spacedim > > jacobian_pushed_forward_3rd_derivatives
std::vector< DerivativeForm< 4, dim, spacedim > > jacobian_3rd_derivatives
std::vector< DerivativeForm< 3, dim, spacedim > > jacobian_2nd_derivatives
std::vector< Tensor< 4, spacedim > > jacobian_pushed_forward_2nd_derivatives
std::vector< Tensor< 3, spacedim > > jacobian_pushed_forward_grads
std::vector< DerivativeForm< 2, dim, spacedim > > jacobian_grads
std::vector< DerivativeForm< 1, dim, spacedim > > jacobians
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
DerivativeForm< 1, spacedim, dim, Number > transpose(const DerivativeForm< 1, dim, spacedim, Number > &DF)
Tensor< 1, spacedim, typename ProductType< Number1, Number2 >::type > apply_transformation(const DerivativeForm< 1, dim, spacedim, Number1 > &grad_F, const Tensor< 1, dim, Number2 > &d_x)
#define DEAL_II_NOT_IMPLEMENTED()
Point< 2 > second
Definition grid_out.cc:4640
static ::ExceptionBase & ExcNotImplemented()
#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_jacobian_pushed_forward_2nd_derivatives
@ update_volume_elements
Determinant of the Jacobian.
@ update_contravariant_transformation
Contravariant transformation.
@ update_jacobian_pushed_forward_grads
@ update_jacobian_3rd_derivatives
@ update_jacobian_grads
Gradient of volume element.
@ update_normal_vectors
Normal vectors.
@ update_JxW_values
Transformed quadrature weights.
@ update_covariant_transformation
Covariant transformation.
@ update_jacobians
Volume element.
@ update_inverse_jacobians
Volume element.
@ update_quadrature_points
Transformed quadrature points.
@ update_jacobian_pushed_forward_3rd_derivatives
@ update_boundary_forms
Outer normal vector, not normalized.
@ update_jacobian_2nd_derivatives
MappingKind
Definition mapping.h:79
@ mapping_piola
Definition mapping.h:114
@ mapping_covariant_gradient
Definition mapping.h:100
@ mapping_covariant
Definition mapping.h:89
@ mapping_contravariant
Definition mapping.h:94
@ mapping_contravariant_hessian
Definition mapping.h:156
@ mapping_covariant_hessian
Definition mapping.h:150
@ mapping_contravariant_gradient
Definition mapping.h:106
@ mapping_piola_gradient
Definition mapping.h:120
@ mapping_piola_hessian
Definition mapping.h:162
std::vector< index_type > data
Definition mpi.cc:734
void reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell< dim > &reference_cell)
constexpr char A
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
Definition utilities.cc:190
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
Tensor< 1, dim, Number > basis_transformation(const Tensor< 1, dim, Number > &V, const Tensor< 2, dim, Number > &B)
*  *  if(update_pressure &update_flags) *  compute_pressure(constitutive_request
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition utilities.cc:473
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition utilities.cc:464
void transform_differential_forms(const ArrayView< const DerivativeForm< rank, dim, spacedim > > &input, const MappingKind mapping_kind, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_data, const ArrayView< Tensor< rank+1, spacedim > > &output)
void do_fill_fe_face_values(const ::MappingQ< dim, spacedim > &mapping, const typename ::Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const unsigned int subface_no, const typename QProjector< dim >::DataSetDescriptor data_set, const Quadrature< dim - 1 > &quadrature, const typename ::MappingQ< dim, spacedim >::InternalData &data, const std::vector< Polynomials::Polynomial< double > > &polynomials_1d, const std::vector< unsigned int > &renumber_lexicographic_to_hierarchic, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data)
void transform_gradients(const ArrayView< const Tensor< rank, dim > > &input, const MappingKind mapping_kind, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_data, const ArrayView< Tensor< rank, spacedim > > &output)
void transform_hessians(const ArrayView< const Tensor< 3, dim > > &input, const MappingKind mapping_kind, const typename Mapping< dim, spacedim >::InternalDataBase &mapping_data, const ArrayView< Tensor< 3, spacedim > > &output)
void maybe_compute_face_data(const ::MappingQ< dim, spacedim > &mapping, const typename ::Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const unsigned int subface_no, const unsigned int n_q_points, const std::vector< double > &weights, const typename ::MappingQ< dim, spacedim >::InternalData &data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data)
Tensor< 3, spacedim, Number > apply_contravariant_hessian(const DerivativeForm< 1, dim, spacedim, Number > &covariant, const DerivativeForm< 1, dim, spacedim, Number > &contravariant, const Tensor< 3, dim, Number > &input)
Tensor< 3, spacedim, Number > apply_piola_hessian(const DerivativeForm< 1, dim, spacedim, Number > &covariant, const DerivativeForm< 1, dim, spacedim, Number > &contravariant, const Number &volume_element, const Tensor< 3, dim, Number > &input)
Tensor< 2, spacedim, Number > apply_piola_gradient(const DerivativeForm< 1, dim, spacedim, Number > &covariant, const DerivativeForm< 1, dim, spacedim, Number > &contravariant, const Number &volume_element, const Tensor< 2, dim, Number > &input)
Tensor< 3, spacedim, Number > apply_covariant_gradient(const DerivativeForm< 1, dim, spacedim, Number > &covariant, const DerivativeForm< 2, dim, spacedim, Number > &input)
Tensor< 3, spacedim, Number > apply_covariant_hessian(const DerivativeForm< 1, dim, spacedim, Number > &covariant, const Tensor< 3, dim, Number > &input)
constexpr unsigned int invalid_unsigned_int
Definition types.h:228
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
unsigned int manifold_id
Definition types.h:171
constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)
constexpr SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &)