36#include <boost/container/small_vector.hpp>
48template <
int dim,
int spacedim>
52 , polynomial_degree(fe.tensor_degree())
53 , n_shape_functions(fe.n_dofs_per_cell())
58template <
int dim,
int spacedim>
78template <
int dim,
int spacedim>
83 const unsigned int n_original_q_points)
87 this->update_each = update_flags;
89 const unsigned int n_q_points = q.
size();
92 covariant.resize(n_original_q_points);
95 contravariant.resize(n_original_q_points);
98 volume_elements.resize(n_original_q_points);
103 shape_values.resize(n_shape_functions * n_q_points);
105 if (this->update_each &
113 shape_derivatives.resize(n_shape_functions * n_q_points);
115 if (this->update_each &
117 shape_second_derivatives.resize(n_shape_functions * n_q_points);
121 shape_third_derivatives.resize(n_shape_functions * n_q_points);
125 shape_fourth_derivatives.resize(n_shape_functions * n_q_points);
128 compute_shape_function_values(q.
get_points());
136template <
int dim,
int spacedim>
141 const unsigned int n_original_q_points)
143 initialize(update_flags, q, n_original_q_points);
145 if (this->update_each &
153 const auto reference_cell = this->
fe.reference_cell();
154 const auto n_faces = reference_cell.n_faces();
156 for (
unsigned int i = 0; i < n_faces; ++i)
158 unit_tangentials[i].resize(n_original_q_points);
159 std::fill(unit_tangentials[i].begin(),
160 unit_tangentials[i].end(),
161 reference_cell.template unit_tangential_vectors<dim>(i, 0));
164 unit_tangentials[n_faces + i].resize(n_original_q_points);
166 unit_tangentials[n_faces + i].begin(),
167 unit_tangentials[n_faces + i].end(),
168 reference_cell.template unit_tangential_vectors<dim>(i, 1));
176template <
int dim,
int spacedim>
185 const auto &tensor_pols = fe_poly->get_poly_space();
187 const unsigned int n_shape_functions =
fe.n_dofs_per_cell();
188 const unsigned int n_points = unit_points.size();
190 std::vector<double> values;
191 std::vector<Tensor<1, dim>> grads;
192 if (shape_values.size() != 0)
194 Assert(shape_values.size() == n_shape_functions * n_points,
196 values.resize(n_shape_functions);
198 if (shape_derivatives.size() != 0)
200 Assert(shape_derivatives.size() == n_shape_functions * n_points,
202 grads.resize(n_shape_functions);
205 std::vector<Tensor<2, dim>> grad2;
206 if (shape_second_derivatives.size() != 0)
208 Assert(shape_second_derivatives.size() == n_shape_functions * n_points,
210 grad2.resize(n_shape_functions);
213 std::vector<Tensor<3, dim>> grad3;
214 if (shape_third_derivatives.size() != 0)
216 Assert(shape_third_derivatives.size() == n_shape_functions * n_points,
218 grad3.resize(n_shape_functions);
221 std::vector<Tensor<4, dim>> grad4;
222 if (shape_fourth_derivatives.size() != 0)
224 Assert(shape_fourth_derivatives.size() == n_shape_functions * n_points,
226 grad4.resize(n_shape_functions);
230 if (shape_values.size() != 0 || shape_derivatives.size() != 0 ||
231 shape_second_derivatives.size() != 0 ||
232 shape_third_derivatives.size() != 0 ||
233 shape_fourth_derivatives.size() != 0)
234 for (
unsigned int point = 0; point < n_points; ++point)
236 tensor_pols.evaluate(
237 unit_points[point], values, grads, grad2, grad3, grad4);
239 if (shape_values.size() != 0)
240 for (
unsigned int i = 0; i < n_shape_functions; ++i)
241 shape(point, i) = values[i];
243 if (shape_derivatives.size() != 0)
244 for (
unsigned int i = 0; i < n_shape_functions; ++i)
245 derivative(point, i) = grads[i];
247 if (shape_second_derivatives.size() != 0)
248 for (
unsigned int i = 0; i < n_shape_functions; ++i)
249 second_derivative(point, i) = grad2[i];
251 if (shape_third_derivatives.size() != 0)
252 for (
unsigned int i = 0; i < n_shape_functions; ++i)
253 third_derivative(point, i) = grad3[i];
255 if (shape_fourth_derivatives.size() != 0)
256 for (
unsigned int i = 0; i < n_shape_functions; ++i)
257 fourth_derivative(point, i) = grad4[i];
264 namespace MappingFEImplementation
274 template <
int dim,
int spacedim>
276 maybe_compute_q_points(
278 const typename ::MappingFE<dim, spacedim>::InternalData &data,
280 const unsigned int n_q_points)
285 for (
unsigned int point = 0; point < n_q_points; ++point)
287 const double * shape = &data.shape(point + data_set, 0);
289 (shape[0] * data.mapping_support_points[0]);
290 for (
unsigned int k = 1; k < data.n_shape_functions; ++k)
291 for (
unsigned int i = 0; i < spacedim; ++i)
292 result[i] += shape[k] * data.mapping_support_points[k][i];
293 quadrature_points[point] = result;
307 template <
int dim,
int spacedim>
309 maybe_update_Jacobians(
311 const typename ::QProjector<dim>::DataSetDescriptor data_set,
312 const typename ::MappingFE<dim, spacedim>::InternalData &data,
313 const unsigned int n_q_points)
323 std::fill(data.contravariant.begin(),
324 data.contravariant.end(),
329 for (
unsigned int point = 0; point < n_q_points; ++point)
331 double result[spacedim][dim];
335 for (
unsigned int i = 0; i < spacedim; ++i)
336 for (
unsigned int j = 0; j < dim; ++j)
337 result[i][j] = data.derivative(point + data_set, 0)[j] *
338 data.mapping_support_points[0][i];
339 for (
unsigned int k = 1; k < data.n_shape_functions; ++k)
340 for (
unsigned int i = 0; i < spacedim; ++i)
341 for (
unsigned int j = 0; j < dim; ++j)
343 data.derivative(point + data_set, k)[j] *
344 data.mapping_support_points[k][i];
351 for (
unsigned int i = 0; i < spacedim; ++i)
352 for (
unsigned int j = 0; j < dim; ++j)
353 data.contravariant[point][i][j] = result[i][j];
360 for (
unsigned int point = 0; point < n_q_points; ++point)
362 data.covariant[point] =
363 (data.contravariant[point]).covariant_form();
370 for (
unsigned int point = 0; point < n_q_points; ++point)
371 data.volume_elements[point] =
372 data.contravariant[point].determinant();
382 template <
int dim,
int spacedim>
384 maybe_update_jacobian_grads(
387 const typename ::MappingFE<dim, spacedim>::InternalData &data,
389 const unsigned int n_q_points)
397 for (
unsigned int point = 0; point < n_q_points; ++point)
400 &data.second_derivative(point + data_set, 0);
401 double result[spacedim][dim][dim];
402 for (
unsigned int i = 0; i < spacedim; ++i)
403 for (
unsigned int j = 0; j < dim; ++j)
404 for (
unsigned int l = 0; l < dim; ++l)
406 (
second[0][j][l] * data.mapping_support_points[0][i]);
407 for (
unsigned int k = 1; k < data.n_shape_functions; ++k)
408 for (
unsigned int i = 0; i < spacedim; ++i)
409 for (
unsigned int j = 0; j < dim; ++j)
410 for (
unsigned int l = 0; l < dim; ++l)
413 data.mapping_support_points[k][i]);
415 for (
unsigned int i = 0; i < spacedim; ++i)
416 for (
unsigned int j = 0; j < dim; ++j)
417 for (
unsigned int l = 0; l < dim; ++l)
418 jacobian_grads[point][i][j][l] = result[i][j][l];
429 template <
int dim,
int spacedim>
431 maybe_update_jacobian_pushed_forward_grads(
434 const typename ::MappingFE<dim, spacedim>::InternalData &data,
436 const unsigned int n_q_points)
442 jacobian_pushed_forward_grads.size() + 1);
446 double tmp[spacedim][spacedim][spacedim];
447 for (
unsigned int point = 0; point < n_q_points; ++point)
450 &data.second_derivative(point + data_set, 0);
451 double result[spacedim][dim][dim];
452 for (
unsigned int i = 0; i < spacedim; ++i)
453 for (
unsigned int j = 0; j < dim; ++j)
454 for (
unsigned int l = 0; l < dim; ++l)
455 result[i][j][l] = (
second[0][j][l] *
456 data.mapping_support_points[0][i]);
457 for (
unsigned int k = 1; k < data.n_shape_functions; ++k)
458 for (
unsigned int i = 0; i < spacedim; ++i)
459 for (
unsigned int j = 0; j < dim; ++j)
460 for (
unsigned int l = 0; l < dim; ++l)
463 data.mapping_support_points[k][i]);
466 for (
unsigned int i = 0; i < spacedim; ++i)
467 for (
unsigned int j = 0; j < spacedim; ++j)
468 for (
unsigned int l = 0; l < dim; ++l)
471 result[i][0][l] * data.covariant[point][j][0];
472 for (
unsigned int jr = 1; jr < dim; ++jr)
474 tmp[i][j][l] += result[i][jr][l] *
475 data.covariant[point][j][jr];
480 for (
unsigned int i = 0; i < spacedim; ++i)
481 for (
unsigned int j = 0; j < spacedim; ++j)
482 for (
unsigned int l = 0; l < spacedim; ++l)
484 jacobian_pushed_forward_grads[point][i][j][l] =
485 tmp[i][j][0] * data.covariant[point][l][0];
486 for (
unsigned int lr = 1; lr < dim; ++lr)
488 jacobian_pushed_forward_grads[point][i][j][l] +=
489 tmp[i][j][lr] * data.covariant[point][l][lr];
503 template <
int dim,
int spacedim>
505 maybe_update_jacobian_2nd_derivatives(
508 const typename ::MappingFE<dim, spacedim>::InternalData &data,
510 const unsigned int n_q_points)
519 for (
unsigned int point = 0; point < n_q_points; ++point)
522 &data.third_derivative(point + data_set, 0);
523 double result[spacedim][dim][dim][dim];
524 for (
unsigned int i = 0; i < spacedim; ++i)
525 for (
unsigned int j = 0; j < dim; ++j)
526 for (
unsigned int l = 0; l < dim; ++l)
527 for (
unsigned int m = 0; m < dim; ++m)
530 data.mapping_support_points[0][i]);
531 for (
unsigned int k = 1; k < data.n_shape_functions; ++k)
532 for (
unsigned int i = 0; i < spacedim; ++i)
533 for (
unsigned int j = 0; j < dim; ++j)
534 for (
unsigned int l = 0; l < dim; ++l)
535 for (
unsigned int m = 0; m < dim; ++m)
536 result[i][j][l][m] +=
538 data.mapping_support_points[k][i]);
540 for (
unsigned int i = 0; i < spacedim; ++i)
541 for (
unsigned int j = 0; j < dim; ++j)
542 for (
unsigned int l = 0; l < dim; ++l)
543 for (
unsigned int m = 0; m < dim; ++m)
544 jacobian_2nd_derivatives[point][i][j][l][m] =
558 template <
int dim,
int spacedim>
560 maybe_update_jacobian_pushed_forward_2nd_derivatives(
563 const typename ::MappingFE<dim, spacedim>::InternalData &data,
565 & jacobian_pushed_forward_2nd_derivatives,
566 const unsigned int n_q_points)
572 jacobian_pushed_forward_2nd_derivatives.size() +
577 double tmp[spacedim][spacedim][spacedim][spacedim];
578 for (
unsigned int point = 0; point < n_q_points; ++point)
581 &data.third_derivative(point + data_set, 0);
582 double result[spacedim][dim][dim][dim];
583 for (
unsigned int i = 0; i < spacedim; ++i)
584 for (
unsigned int j = 0; j < dim; ++j)
585 for (
unsigned int l = 0; l < dim; ++l)
586 for (
unsigned int m = 0; m < dim; ++m)
589 data.mapping_support_points[0][i]);
590 for (
unsigned int k = 1; k < data.n_shape_functions; ++k)
591 for (
unsigned int i = 0; i < spacedim; ++i)
592 for (
unsigned int j = 0; j < dim; ++j)
593 for (
unsigned int l = 0; l < dim; ++l)
594 for (
unsigned int m = 0; m < dim; ++m)
595 result[i][j][l][m] +=
597 data.mapping_support_points[k][i]);
600 for (
unsigned int i = 0; i < spacedim; ++i)
601 for (
unsigned int j = 0; j < spacedim; ++j)
602 for (
unsigned int l = 0; l < dim; ++l)
603 for (
unsigned int m = 0; m < dim; ++m)
605 jacobian_pushed_forward_2nd_derivatives
606 [point][i][j][l][m] =
608 data.covariant[point][j][0];
609 for (
unsigned int jr = 1; jr < dim; ++jr)
610 jacobian_pushed_forward_2nd_derivatives[point]
613 result[i][jr][l][m] *
614 data.covariant[point][j][jr];
618 for (
unsigned int i = 0; i < spacedim; ++i)
619 for (
unsigned int j = 0; j < spacedim; ++j)
620 for (
unsigned int l = 0; l < spacedim; ++l)
621 for (
unsigned int m = 0; m < dim; ++m)
624 jacobian_pushed_forward_2nd_derivatives[point]
627 data.covariant[point][l][0];
628 for (
unsigned int lr = 1; lr < dim; ++lr)
630 jacobian_pushed_forward_2nd_derivatives
631 [point][i][j][lr][m] *
632 data.covariant[point][l][lr];
636 for (
unsigned int i = 0; i < spacedim; ++i)
637 for (
unsigned int j = 0; j < spacedim; ++j)
638 for (
unsigned int l = 0; l < spacedim; ++l)
639 for (
unsigned int m = 0; m < spacedim; ++m)
641 jacobian_pushed_forward_2nd_derivatives
642 [point][i][j][l][m] =
643 tmp[i][j][l][0] * data.covariant[point][m][0];
644 for (
unsigned int mr = 1; mr < dim; ++mr)
645 jacobian_pushed_forward_2nd_derivatives[point]
649 data.covariant[point][m][mr];
662 template <
int dim,
int spacedim>
664 maybe_update_jacobian_3rd_derivatives(
667 const typename ::MappingFE<dim, spacedim>::InternalData &data,
669 const unsigned int n_q_points)
678 for (
unsigned int point = 0; point < n_q_points; ++point)
681 &data.fourth_derivative(point + data_set, 0);
682 double result[spacedim][dim][dim][dim][dim];
683 for (
unsigned int i = 0; i < spacedim; ++i)
684 for (
unsigned int j = 0; j < dim; ++j)
685 for (
unsigned int l = 0; l < dim; ++l)
686 for (
unsigned int m = 0; m < dim; ++m)
687 for (
unsigned int n = 0; n < dim; ++n)
688 result[i][j][l][m][n] =
689 (fourth[0][j][l][m][n] *
690 data.mapping_support_points[0][i]);
691 for (
unsigned int k = 1; k < data.n_shape_functions; ++k)
692 for (
unsigned int i = 0; i < spacedim; ++i)
693 for (
unsigned int j = 0; j < dim; ++j)
694 for (
unsigned int l = 0; l < dim; ++l)
695 for (
unsigned int m = 0; m < dim; ++m)
696 for (
unsigned int n = 0; n < dim; ++n)
697 result[i][j][l][m][n] +=
698 (fourth[k][j][l][m][n] *
699 data.mapping_support_points[k][i]);
701 for (
unsigned int i = 0; i < spacedim; ++i)
702 for (
unsigned int j = 0; j < dim; ++j)
703 for (
unsigned int l = 0; l < dim; ++l)
704 for (
unsigned int m = 0; m < dim; ++m)
705 for (
unsigned int n = 0; n < dim; ++n)
706 jacobian_3rd_derivatives[point][i][j][l][m][n] =
707 result[i][j][l][m][n];
720 template <
int dim,
int spacedim>
722 maybe_update_jacobian_pushed_forward_3rd_derivatives(
725 const typename ::MappingFE<dim, spacedim>::InternalData &data,
727 & jacobian_pushed_forward_3rd_derivatives,
728 const unsigned int n_q_points)
734 jacobian_pushed_forward_3rd_derivatives.size() +
739 double tmp[spacedim][spacedim][spacedim][spacedim][spacedim];
740 for (
unsigned int point = 0; point < n_q_points; ++point)
743 &data.fourth_derivative(point + data_set, 0);
744 double result[spacedim][dim][dim][dim][dim];
745 for (
unsigned int i = 0; i < spacedim; ++i)
746 for (
unsigned int j = 0; j < dim; ++j)
747 for (
unsigned int l = 0; l < dim; ++l)
748 for (
unsigned int m = 0; m < dim; ++m)
749 for (
unsigned int n = 0; n < dim; ++n)
750 result[i][j][l][m][n] =
751 (fourth[0][j][l][m][n] *
752 data.mapping_support_points[0][i]);
753 for (
unsigned int k = 1; k < data.n_shape_functions; ++k)
754 for (
unsigned int i = 0; i < spacedim; ++i)
755 for (
unsigned int j = 0; j < dim; ++j)
756 for (
unsigned int l = 0; l < dim; ++l)
757 for (
unsigned int m = 0; m < dim; ++m)
758 for (
unsigned int n = 0; n < dim; ++n)
759 result[i][j][l][m][n] +=
760 (fourth[k][j][l][m][n] *
761 data.mapping_support_points[k][i]);
764 for (
unsigned int i = 0; i < spacedim; ++i)
765 for (
unsigned int j = 0; j < spacedim; ++j)
766 for (
unsigned int l = 0; l < dim; ++l)
767 for (
unsigned int m = 0; m < dim; ++m)
768 for (
unsigned int n = 0; n < dim; ++n)
771 result[i][0][l][m][n] *
772 data.covariant[point][j][0];
773 for (
unsigned int jr = 1; jr < dim; ++jr)
774 tmp[i][j][l][m][n] +=
775 result[i][jr][l][m][n] *
776 data.covariant[point][j][jr];
780 for (
unsigned int i = 0; i < spacedim; ++i)
781 for (
unsigned int j = 0; j < spacedim; ++j)
782 for (
unsigned int l = 0; l < spacedim; ++l)
783 for (
unsigned int m = 0; m < dim; ++m)
784 for (
unsigned int n = 0; n < dim; ++n)
786 jacobian_pushed_forward_3rd_derivatives
787 [point][i][j][l][m][n] =
789 data.covariant[point][l][0];
790 for (
unsigned int lr = 1; lr < dim; ++lr)
791 jacobian_pushed_forward_3rd_derivatives
792 [point][i][j][l][m][n] +=
793 tmp[i][j][lr][m][n] *
794 data.covariant[point][l][lr];
798 for (
unsigned int i = 0; i < spacedim; ++i)
799 for (
unsigned int j = 0; j < spacedim; ++j)
800 for (
unsigned int l = 0; l < spacedim; ++l)
801 for (
unsigned int m = 0; m < spacedim; ++m)
802 for (
unsigned int n = 0; n < dim; ++n)
805 jacobian_pushed_forward_3rd_derivatives
806 [point][i][j][l][0][n] *
807 data.covariant[point][m][0];
808 for (
unsigned int mr = 1; mr < dim; ++mr)
809 tmp[i][j][l][m][n] +=
810 jacobian_pushed_forward_3rd_derivatives
811 [point][i][j][l][mr][n] *
812 data.covariant[point][m][mr];
816 for (
unsigned int i = 0; i < spacedim; ++i)
817 for (
unsigned int j = 0; j < spacedim; ++j)
818 for (
unsigned int l = 0; l < spacedim; ++l)
819 for (
unsigned int m = 0; m < spacedim; ++m)
820 for (
unsigned int n = 0; n < spacedim; ++n)
822 jacobian_pushed_forward_3rd_derivatives
823 [point][i][j][l][m][n] =
825 data.covariant[point][n][0];
826 for (
unsigned int nr = 1; nr < dim; ++nr)
827 jacobian_pushed_forward_3rd_derivatives
828 [point][i][j][l][m][n] +=
829 tmp[i][j][l][m][nr] *
830 data.covariant[point][n][nr];
842template <
int dim,
int spacedim>
848 ExcMessage(
"It only makes sense to create polynomial mappings "
849 "with a polynomial degree greater or equal to one."));
854 const auto &mapping_support_points =
fe.get_unit_support_points();
856 const auto reference_cell =
fe.reference_cell();
858 const unsigned int n_points = mapping_support_points.size();
859 const unsigned int n_shape_functions = reference_cell.n_vertices();
864 for (
unsigned int point = 0; point < n_points; ++point)
865 for (
unsigned int i = 0; i < n_shape_functions; ++i)
867 reference_cell.d_linear_shape_function(mapping_support_points[point],
873template <
int dim,
int spacedim>
875 : fe(mapping.fe->clone())
876 , polynomial_degree(mapping.polynomial_degree)
877 , mapping_support_point_weights(mapping.mapping_support_point_weights)
882template <
int dim,
int spacedim>
883std::unique_ptr<Mapping<dim, spacedim>>
886 return std::make_unique<MappingFE<dim, spacedim>>(*this);
891template <
int dim,
int spacedim>
895 return polynomial_degree;
900template <
int dim,
int spacedim>
906 const std::vector<Point<spacedim>> support_points =
907 this->compute_mapping_support_points(cell);
911 for (
unsigned int i = 0; i < this->fe->n_dofs_per_cell(); ++i)
912 mapped_point += support_points[i] * this->fe->shape_value(i, p);
919template <
int dim,
int spacedim>
925 const std::vector<Point<spacedim>> support_points =
926 this->compute_mapping_support_points(cell);
928 const double eps = 1.e-12 * cell->diameter();
929 const unsigned int loop_limit = 10;
933 unsigned int loop = 0;
949 for (
unsigned int i = 0; i < this->fe->n_dofs_per_cell(); ++i)
951 mapped_point += support_points[i] * this->fe->shape_value(i, p_unit);
952 const auto grad_F_i = this->fe->shape_grad(i, p_unit);
953 const auto hessian_F_i = this->fe->shape_grad_grad(i, p_unit);
954 for (
unsigned int j = 0; j < dim; ++j)
956 grad_FT[j] += grad_F_i[j] * support_points[i];
957 for (
unsigned int l = 0; l < dim; ++l)
958 hess_FT[j][l] += hessian_F_i[j][l] * support_points[i];
963 const auto residual = p - mapped_point;
970 if (grad_FT_residual.norm() <= eps)
975 for (
unsigned int j = 0; j < dim; ++j)
976 for (
unsigned int l = 0; l < dim; ++l)
977 corrected_metric_tensor[j][l] =
978 -grad_FT[j] * grad_FT[l] + hess_FT[j][l] * residual;
981 const auto g_inverse =
invert(corrected_metric_tensor);
982 p_unit -=
Point<dim>(g_inverse * grad_FT_residual);
986 while (loop < loop_limit);
1000template <
int dim,
int spacedim>
1011 for (
unsigned int i = 0; i < 5; ++i)
1056template <
int dim,
int spacedim>
1057std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
1061 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr =
1062 std::make_unique<InternalData>(*this->fe);
1064 data.
initialize(this->requires_update_flags(update_flags), q, q.
size());
1071template <
int dim,
int spacedim>
1072std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
1077 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr =
1078 std::make_unique<InternalData>(*this->fe);
1082 this->fe->reference_cell(), quadrature),
1090template <
int dim,
int spacedim>
1091std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
1096 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr =
1097 std::make_unique<InternalData>(*this->fe);
1101 this->fe->reference_cell(), quadrature),
1109template <
int dim,
int spacedim>
1124 const unsigned int n_q_points = quadrature.
size();
1146 internal::MappingFEImplementation::maybe_compute_q_points<dim, spacedim>(
1152 internal::MappingFEImplementation::maybe_update_Jacobians<dim, spacedim>(
1153 computed_cell_similarity,
1158 internal::MappingFEImplementation::maybe_update_jacobian_grads<dim, spacedim>(
1159 computed_cell_similarity,
1165 internal::MappingFEImplementation::maybe_update_jacobian_pushed_forward_grads<
1167 spacedim>(computed_cell_similarity,
1173 internal::MappingFEImplementation::maybe_update_jacobian_2nd_derivatives<
1175 spacedim>(computed_cell_similarity,
1181 internal::MappingFEImplementation::
1182 maybe_update_jacobian_pushed_forward_2nd_derivatives<dim, spacedim>(
1183 computed_cell_similarity,
1189 internal::MappingFEImplementation::maybe_update_jacobian_3rd_derivatives<
1191 spacedim>(computed_cell_similarity,
1197 internal::MappingFEImplementation::
1198 maybe_update_jacobian_pushed_forward_3rd_derivatives<dim, spacedim>(
1199 computed_cell_similarity,
1205 const UpdateFlags update_flags = data.update_each;
1206 const std::vector<double> &weights = quadrature.
get_weights();
1222 for (
unsigned int point = 0; point < n_q_points; ++point)
1224 if (dim == spacedim)
1234 1e-12 * Utilities::fixed_power<dim>(
1235 cell->diameter() /
std::sqrt(
double(dim))),
1237 cell->center(), det, point)));
1239 output_data.
JxW_values[point] = weights[point] * det;
1247 for (
unsigned int i = 0; i < spacedim; ++i)
1248 for (
unsigned int j = 0; j < dim; ++j)
1252 for (
unsigned int i = 0; i < dim; ++i)
1253 for (
unsigned int j = 0; j < dim; ++j)
1254 G[i][j] = DX_t[i] * DX_t[j];
1259 if (computed_cell_similarity ==
1270 Assert(spacedim == dim + 1,
1272 "There is no (unique) cell normal for " +
1274 "-dimensional cells in " +
1276 "-dimensional space. This only works if the "
1277 "space dimension is one greater than the "
1278 "dimensionality of the mesh cells."));
1282 cross_product_2d(-DX_t[0]);
1285 cross_product_3d(DX_t[0], DX_t[1]);
1290 if (cell->direction_flag() ==
false)
1305 for (
unsigned int point = 0; point < n_q_points; ++point)
1314 for (
unsigned int point = 0; point < n_q_points; ++point)
1319 return computed_cell_similarity;
1326 namespace MappingFEImplementation
1340 template <
int dim,
int spacedim>
1342 maybe_compute_face_data(
1343 const ::MappingFE<dim, spacedim> &mapping,
1344 const typename ::Triangulation<dim, spacedim>::cell_iterator
1346 const unsigned int face_no,
1347 const unsigned int subface_no,
1348 const unsigned int n_q_points,
1350 const typename ::MappingFE<dim, spacedim>::InternalData &data,
1354 const UpdateFlags update_flags = data.update_each;
1377 for (
unsigned int d = 0; d != dim - 1; ++d)
1379 Assert(face_no + cell->n_faces() * d <
1380 data.unit_tangentials.size(),
1383 data.aux[d].size() <=
1384 data.unit_tangentials[face_no + cell->n_faces() * d].size(),
1389 data.unit_tangentials[face_no + cell->n_faces() * d]),
1400 if (dim == spacedim)
1402 for (
unsigned int i = 0; i < n_q_points; ++i)
1412 (face_no == 0 ? -1 : +1);
1416 cross_product_2d(data.aux[0][i]);
1420 cross_product_3d(data.aux[0][i], data.aux[1][i]);
1436 for (
unsigned int point = 0;
point < n_q_points; ++
point)
1442 data.contravariant[
point].transpose()[0];
1444 (face_no == 0 ? -1. : +1.) *
1454 cross_product_3d(DX_t[0], DX_t[1]);
1455 cell_normal /= cell_normal.
norm();
1460 cross_product_3d(data.aux[0][point], cell_normal);
1467 for (
unsigned int i = 0; i < n_q_points; ++i)
1471 data.quadrature_weights[i + data_set];
1476 const double area_ratio =
1478 cell->subface_case(face_no), subface_no);
1487 for (
unsigned int i = 0; i < n_q_points; ++i)
1493 for (
unsigned int point = 0;
point < n_q_points; ++
point)
1494 output_data.
jacobians[point] = data.contravariant[point];
1497 for (
unsigned int point = 0;
point < n_q_points; ++
point)
1499 data.covariant[point].transpose();
1510 template <
int dim,
int spacedim>
1513 const ::MappingFE<dim, spacedim> &mapping,
1514 const typename ::Triangulation<dim, spacedim>::cell_iterator
1516 const unsigned int face_no,
1517 const unsigned int subface_no,
1520 const typename ::MappingFE<dim, spacedim>::InternalData &data,
1524 const unsigned int n_q_points = quadrature.
size();
1526 maybe_compute_q_points<dim, spacedim>(data_set,
1539 maybe_update_jacobian_pushed_forward_grads<dim, spacedim>(
1545 maybe_update_jacobian_2nd_derivatives<dim, spacedim>(
1551 maybe_update_jacobian_pushed_forward_2nd_derivatives<dim, spacedim>(
1557 maybe_update_jacobian_3rd_derivatives<dim, spacedim>(
1563 maybe_update_jacobian_pushed_forward_3rd_derivatives<dim, spacedim>(
1585template <
int dim,
int spacedim>
1589 const unsigned int face_no,
1605 (&cell->get_triangulation() !=
1613 internal::MappingFEImplementation::do_fill_fe_face_values(
1620 cell->face_orientation(face_no),
1621 cell->face_flip(face_no),
1622 cell->face_rotation(face_no),
1624 quadrature[quadrature.
size() == 1 ? 0 : face_no],
1631template <
int dim,
int spacedim>
1635 const unsigned int face_no,
1636 const unsigned int subface_no,
1652 (&cell->get_triangulation() !=
1660 internal::MappingFEImplementation::do_fill_fe_face_values(
1668 cell->face_orientation(face_no),
1669 cell->face_flip(face_no),
1670 cell->face_rotation(face_no),
1672 cell->subface_case(face_no)),
1682 namespace MappingFEImplementation
1686 template <
int dim,
int spacedim,
int rank>
1703 const typename ::MappingFE<dim, spacedim>::InternalData *
>(
1704 &mapping_data) !=
nullptr),
1706 const typename ::MappingFE<dim, spacedim>::InternalData &data =
1708 const typename ::MappingFE<dim, spacedim>::InternalData &
>(
1711 switch (mapping_kind)
1718 "update_contravariant_transformation"));
1720 for (
unsigned int i = 0; i < input.size(); ++i)
1732 "update_contravariant_transformation"));
1736 "update_volume_elements"));
1741 for (
unsigned int i = 0; i < input.size(); ++i)
1745 output[i] /= data.volume_elements[i];
1757 "update_covariant_transformation"));
1759 for (
unsigned int i = 0; i < input.size(); ++i)
1771 template <
int dim,
int spacedim,
int rank>
1782 const typename ::MappingFE<dim, spacedim>::InternalData *
>(
1783 &mapping_data) !=
nullptr),
1785 const typename ::MappingFE<dim, spacedim>::InternalData &data =
1787 const typename ::MappingFE<dim, spacedim>::InternalData &
>(
1790 switch (mapping_kind)
1797 "update_covariant_transformation"));
1801 "update_contravariant_transformation"));
1804 for (
unsigned int i = 0; i < output.size(); ++i)
1821 "update_covariant_transformation"));
1824 for (
unsigned int i = 0; i < output.size(); ++i)
1841 "update_covariant_transformation"));
1845 "update_contravariant_transformation"));
1849 "update_volume_elements"));
1852 for (
unsigned int i = 0; i < output.size(); ++i)
1861 output[i] /= data.volume_elements[i];
1874 template <
int dim,
int spacedim>
1885 const typename ::MappingFE<dim, spacedim>::InternalData *
>(
1886 &mapping_data) !=
nullptr),
1888 const typename ::MappingFE<dim, spacedim>::InternalData &data =
1890 const typename ::MappingFE<dim, spacedim>::InternalData &
>(
1893 switch (mapping_kind)
1900 "update_covariant_transformation"));
1904 "update_contravariant_transformation"));
1906 for (
unsigned int q = 0; q < output.size(); ++q)
1907 for (
unsigned int i = 0; i < spacedim; ++i)
1909 double tmp1[dim][dim];
1910 for (
unsigned int J = 0; J < dim; ++J)
1911 for (
unsigned int K = 0;
K < dim; ++
K)
1914 data.contravariant[q][i][0] * input[q][0][J][
K];
1915 for (
unsigned int I = 1; I < dim; ++I)
1917 data.contravariant[q][i][I] * input[q][I][J][K];
1919 for (
unsigned int j = 0; j < spacedim; ++j)
1922 for (
unsigned int K = 0;
K < dim; ++
K)
1924 tmp2[
K] = data.covariant[q][j][0] * tmp1[0][
K];
1925 for (
unsigned int J = 1; J < dim; ++J)
1926 tmp2[K] += data.covariant[q][j][J] * tmp1[J][K];
1928 for (
unsigned int k = 0; k < spacedim; ++k)
1930 output[q][i][j][k] =
1931 data.covariant[q][k][0] * tmp2[0];
1932 for (
unsigned int K = 1;
K < dim; ++
K)
1933 output[q][i][j][k] +=
1934 data.covariant[q][k][K] * tmp2[K];
1946 "update_covariant_transformation"));
1948 for (
unsigned int q = 0; q < output.size(); ++q)
1949 for (
unsigned int i = 0; i < spacedim; ++i)
1951 double tmp1[dim][dim];
1952 for (
unsigned int J = 0; J < dim; ++J)
1953 for (
unsigned int K = 0;
K < dim; ++
K)
1956 data.covariant[q][i][0] * input[q][0][J][
K];
1957 for (
unsigned int I = 1; I < dim; ++I)
1959 data.covariant[q][i][I] * input[q][I][J][K];
1961 for (
unsigned int j = 0; j < spacedim; ++j)
1964 for (
unsigned int K = 0;
K < dim; ++
K)
1966 tmp2[
K] = data.covariant[q][j][0] * tmp1[0][
K];
1967 for (
unsigned int J = 1; J < dim; ++J)
1968 tmp2[K] += data.covariant[q][j][J] * tmp1[J][K];
1970 for (
unsigned int k = 0; k < spacedim; ++k)
1972 output[q][i][j][k] =
1973 data.covariant[q][k][0] * tmp2[0];
1974 for (
unsigned int K = 1;
K < dim; ++
K)
1975 output[q][i][j][k] +=
1976 data.covariant[q][k][K] * tmp2[K];
1989 "update_covariant_transformation"));
1993 "update_contravariant_transformation"));
1997 "update_volume_elements"));
1999 for (
unsigned int q = 0; q < output.size(); ++q)
2000 for (
unsigned int i = 0; i < spacedim; ++i)
2003 for (
unsigned int I = 0; I < dim; ++I)
2005 data.contravariant[q][i][I] / data.volume_elements[q];
2006 double tmp1[dim][dim];
2007 for (
unsigned int J = 0; J < dim; ++J)
2008 for (
unsigned int K = 0;
K < dim; ++
K)
2010 tmp1[J][
K] = factor[0] * input[q][0][J][
K];
2011 for (
unsigned int I = 1; I < dim; ++I)
2012 tmp1[J][K] += factor[I] * input[q][I][J][K];
2014 for (
unsigned int j = 0; j < spacedim; ++j)
2017 for (
unsigned int K = 0;
K < dim; ++
K)
2019 tmp2[
K] = data.covariant[q][j][0] * tmp1[0][
K];
2020 for (
unsigned int J = 1; J < dim; ++J)
2021 tmp2[K] += data.covariant[q][j][J] * tmp1[J][K];
2023 for (
unsigned int k = 0; k < spacedim; ++k)
2025 output[q][i][j][k] =
2026 data.covariant[q][k][0] * tmp2[0];
2027 for (
unsigned int K = 1;
K < dim; ++
K)
2028 output[q][i][j][k] +=
2029 data.covariant[q][k][K] * tmp2[K];
2044 template <
int dim,
int spacedim,
int rank>
2055 const typename ::MappingFE<dim, spacedim>::InternalData *
>(
2056 &mapping_data) !=
nullptr),
2058 const typename ::MappingFE<dim, spacedim>::InternalData &data =
2060 const typename ::MappingFE<dim, spacedim>::InternalData &
>(
2063 switch (mapping_kind)
2070 "update_covariant_transformation"));
2072 for (
unsigned int i = 0; i < output.size(); ++i)
2087template <
int dim,
int spacedim>
2095 internal::MappingFEImplementation::transform_fields(input,
2103template <
int dim,
int spacedim>
2111 internal::MappingFEImplementation::transform_differential_forms(input,
2119template <
int dim,
int spacedim>
2127 switch (mapping_kind)
2130 internal::MappingFEImplementation::transform_fields(input,
2139 internal::MappingFEImplementation::transform_gradients(input,
2151template <
int dim,
int spacedim>
2164 switch (mapping_kind)
2170 "update_covariant_transformation"));
2172 for (
unsigned int q = 0; q < output.size(); ++q)
2173 for (
unsigned int i = 0; i < spacedim; ++i)
2174 for (
unsigned int j = 0; j < spacedim; ++j)
2177 for (
unsigned int K = 0; K < dim; ++K)
2179 tmp[K] = data.
covariant[q][j][0] * input[q][i][0][K];
2180 for (
unsigned int J = 1; J < dim; ++J)
2181 tmp[K] += data.
covariant[q][j][J] * input[q][i][J][K];
2183 for (
unsigned int k = 0; k < spacedim; ++k)
2185 output[q][i][j][k] = data.
covariant[q][k][0] * tmp[0];
2186 for (
unsigned int K = 1; K < dim; ++K)
2187 output[q][i][j][k] += data.
covariant[q][k][K] * tmp[K];
2200template <
int dim,
int spacedim>
2208 switch (mapping_kind)
2213 internal::MappingFEImplementation::transform_hessians(input,
2227 template <
int spacedim>
2229 check_all_manifold_ids_identical(
2237 template <
int spacedim>
2239 check_all_manifold_ids_identical(
2242 const auto m_id = cell->manifold_id();
2244 for (
const auto f : cell->face_indices())
2253 template <
int spacedim>
2255 check_all_manifold_ids_identical(
2258 const auto m_id = cell->manifold_id();
2260 for (
const auto f : cell->face_indices())
2264 for (
const auto l : cell->line_indices())
2274template <
int dim,
int spacedim>
2275std::vector<Point<spacedim>>
2280 check_all_manifold_ids_identical(cell),
2282 "All entities of a cell need to have the same manifold id as the cell has."));
2284 std::vector<Point<spacedim>>
vertices(cell->n_vertices());
2286 for (
const unsigned int i : cell->vertex_indices())
2289 std::vector<Point<spacedim>> mapping_support_points(
2290 fe->get_unit_support_points().size());
2292 cell->get_manifold().get_new_points(
vertices,
2293 mapping_support_point_weights,
2294 mapping_support_points);
2296 return mapping_support_points;
2301template <
int dim,
int spacedim>
2311template <
int dim,
int spacedim>
2316 Assert(dim == reference_cell.get_dimension(),
2317 ExcMessage(
"The dimension of your mapping (" +
2319 ") and the reference cell cell_type (" +
2321 " ) do not agree."));
2323 return fe->reference_cell() == reference_cell;
2329#include "mapping_fe.inst"
ArrayView< typename std::remove_reference< typename std::iterator_traits< Iterator >::reference >::type, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
void initialize_face(const UpdateFlags update_flags, const Quadrature< dim > &quadrature, const unsigned int n_original_q_points)
std::vector< Point< spacedim > > mapping_support_points
void initialize(const UpdateFlags update_flags, const Quadrature< dim > &quadrature, const unsigned int n_original_q_points)
Triangulation< dim, spacedim >::cell_iterator cell_of_current_support_points
void compute_shape_function_values(const std::vector< Point< dim > > &unit_points)
std::vector< DerivativeForm< 1, dim, spacedim > > contravariant
std::vector< DerivativeForm< 1, dim, spacedim > > covariant
virtual std::size_t memory_consumption() const override
InternalData(const FiniteElement< dim, spacedim > &fe)
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
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 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
virtual std::vector< Point< spacedim > > compute_mapping_support_points(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
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 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 bool is_compatible_with(const ReferenceCell &reference_cell) const override
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
Abstract base class for mapping classes.
static DataSetDescriptor cell()
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
Triangulation< dim, spacedim > & get_triangulation()
unsigned int size() const
unsigned int max_n_quadrature_points() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
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)
@ 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
@ mapping_covariant_gradient
@ mapping_contravariant_hessian
@ mapping_covariant_hessian
@ mapping_contravariant_gradient
CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt K
std::enable_if_t< std::is_fundamental< T >::value, std::size_t > memory_consumption(const T &t)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
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)
static const unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
static double subface_ratio(const internal::SubfaceCase< dim > &subface_case, const unsigned int subface_no)
DEAL_II_HOST constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)
DEAL_II_HOST constexpr SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &)