61template <
int dim,
int spacedim,
typename VectorType>
66 , n_shape_functions(fe.n_dofs_per_cell())
68 , local_dof_indices(fe.n_dofs_per_cell())
69 , local_dof_values(fe.n_dofs_per_cell())
74template <
int dim,
int spacedim,
typename VectorType>
85template <
int dim,
int spacedim,
typename VectorType>
88 const unsigned int qpoint,
89 const unsigned int shape_nr)
91 AssertIndexRange(qpoint * n_shape_functions + shape_nr, shape_values.size());
92 return shape_values[qpoint * n_shape_functions + shape_nr];
96template <
int dim,
int spacedim,
typename VectorType>
99 const unsigned int qpoint,
100 const unsigned int shape_nr)
const
103 shape_derivatives.size());
104 return shape_derivatives[qpoint * n_shape_functions + shape_nr];
109template <
int dim,
int spacedim,
typename VectorType>
112 const unsigned int qpoint,
113 const unsigned int shape_nr)
116 shape_derivatives.size());
117 return shape_derivatives[qpoint * n_shape_functions + shape_nr];
121template <
int dim,
int spacedim,
typename VectorType>
125 const unsigned int shape_nr)
const
128 shape_second_derivatives.size());
129 return shape_second_derivatives[qpoint * n_shape_functions + shape_nr];
134template <
int dim,
int spacedim,
typename VectorType>
140 shape_second_derivatives.size());
141 return shape_second_derivatives[qpoint * n_shape_functions + shape_nr];
145template <
int dim,
int spacedim,
typename VectorType>
148 const unsigned int qpoint,
149 const unsigned int shape_nr)
const
152 shape_third_derivatives.size());
153 return shape_third_derivatives[qpoint * n_shape_functions + shape_nr];
158template <
int dim,
int spacedim,
typename VectorType>
161 const unsigned int qpoint,
162 const unsigned int shape_nr)
165 shape_third_derivatives.size());
166 return shape_third_derivatives[qpoint * n_shape_functions + shape_nr];
170template <
int dim,
int spacedim,
typename VectorType>
174 const unsigned int shape_nr)
const
177 shape_fourth_derivatives.size());
178 return shape_fourth_derivatives[qpoint * n_shape_functions + shape_nr];
183template <
int dim,
int spacedim,
typename VectorType>
189 shape_fourth_derivatives.size());
190 return shape_fourth_derivatives[qpoint * n_shape_functions + shape_nr];
195template <
int dim,
int spacedim,
typename VectorType>
198 const VectorType & euler_vector,
200 : reference_cell(euler_dof_handler.get_fe().reference_cell())
201 , uses_level_dofs(false)
202 , euler_vector({&euler_vector})
203 , euler_dof_handler(&euler_dof_handler)
204 , fe_mask(mask.size() != 0u ?
207 euler_dof_handler.get_fe().get_nonzero_components(0).size(),
210 , fe_values(this->euler_dof_handler->get_fe(),
211 reference_cell.template get_nodal_type_quadrature<dim>(),
214 unsigned int size = 0;
215 for (
unsigned int i = 0; i < fe_mask.size(); ++i)
218 fe_to_real[i] = size++;
225template <
int dim,
int spacedim,
typename VectorType>
228 const std::vector<VectorType> & euler_vector,
230 : reference_cell(euler_dof_handler.get_fe().reference_cell())
231 , uses_level_dofs(true)
232 , euler_dof_handler(&euler_dof_handler)
233 , fe_mask(mask.size() != 0u ?
236 euler_dof_handler.get_fe().get_nonzero_components(0).size(),
238 , fe_to_real(fe_mask.size(),
numbers::invalid_unsigned_int)
239 , fe_values(this->euler_dof_handler->get_fe(),
240 reference_cell.template get_nodal_type_quadrature<dim>(),
243 unsigned int size = 0;
244 for (
unsigned int i = 0; i < fe_mask.size(); ++i)
247 fe_to_real[i] = size++;
252 ExcMessage(
"The underlying DoFHandler object did not call "
253 "distribute_mg_dofs(). In this case, the construction via "
254 "level vectors does not make sense."));
257 this->euler_vector.clear();
258 this->euler_vector.resize(euler_vector.size());
259 for (
unsigned int i = 0; i < euler_vector.size(); ++i)
260 this->euler_vector[i] = &euler_vector[i];
265template <
int dim,
int spacedim,
typename VectorType>
270 : reference_cell(euler_dof_handler.get_fe().reference_cell())
271 , uses_level_dofs(true)
272 , euler_dof_handler(&euler_dof_handler)
273 , fe_mask(mask.size() != 0u ?
276 euler_dof_handler.get_fe().get_nonzero_components(0).size(),
278 , fe_to_real(fe_mask.size(),
numbers::invalid_unsigned_int)
279 , fe_values(this->euler_dof_handler->get_fe(),
280 reference_cell.template get_nodal_type_quadrature<dim>(),
283 unsigned int size = 0;
284 for (
unsigned int i = 0; i < fe_mask.size(); ++i)
287 fe_to_real[i] = size++;
292 ExcMessage(
"The underlying DoFHandler object did not call "
293 "distribute_mg_dofs(). In this case, the construction via "
294 "level vectors does not make sense."));
297 this->euler_vector.clear();
298 this->euler_vector.
resize(
302 this->euler_vector[i] = &euler_vector[i];
307template <
int dim,
int spacedim,
typename VectorType>
310 : reference_cell(mapping.reference_cell)
311 , uses_level_dofs(mapping.uses_level_dofs)
312 , euler_vector(mapping.euler_vector)
313 , euler_dof_handler(mapping.euler_dof_handler)
314 , fe_mask(mapping.fe_mask)
315 , fe_to_real(mapping.fe_to_real)
316 , fe_values(mapping.euler_dof_handler->get_fe(),
317 reference_cell.template get_nodal_type_quadrature<dim>(),
323template <
int dim,
int spacedim,
typename VectorType>
326 const unsigned int qpoint,
327 const unsigned int shape_nr)
const
329 AssertIndexRange(qpoint * n_shape_functions + shape_nr, shape_values.size());
330 return shape_values[qpoint * n_shape_functions + shape_nr];
335template <
int dim,
int spacedim,
typename VectorType>
345template <
int dim,
int spacedim,
typename VectorType>
350 Assert(dim == reference_cell.get_dimension(),
351 ExcMessage(
"The dimension of your mapping (" +
353 ") and the reference cell cell_type (" +
355 " ) do not agree."));
357 return this->reference_cell == reference_cell;
362template <
int dim,
int spacedim,
typename VectorType>
363boost::container::small_vector<Point<spacedim>,
371 *cell, euler_dof_handler);
373 Assert(uses_level_dofs || dof_cell->is_active() ==
true, ExcInactiveCell());
376 euler_dof_handler->get_fe().n_components());
381 euler_dof_handler->n_dofs(cell->level()));
387 std::lock_guard<std::mutex> lock(fe_values_mutex);
388 fe_values.reinit(dof_cell);
390 const unsigned int dofs_per_cell =
391 euler_dof_handler->get_fe().n_dofs_per_cell();
392 std::vector<types::global_dof_index> dof_indices(dofs_per_cell);
394 dof_cell->get_mg_dof_indices(dof_indices);
396 dof_cell->get_dof_indices(dof_indices);
398 const VectorType &vector =
399 uses_level_dofs ? *euler_vector[cell->level()] : *euler_vector[0];
401 boost::container::small_vector<Point<spacedim>,
404 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
406 const unsigned int comp = fe_to_real
407 [euler_dof_handler->get_fe().system_to_component_index(i).first];
410 typename VectorType::value_type value =
412 if (euler_dof_handler->get_fe().is_primitive(i))
413 for (
const unsigned int v : cell->vertex_indices())
414 vertices[v][comp] += fe_values.shape_value(i, v) * value;
425template <
int dim,
int spacedim,
typename VectorType>
432 const auto fe = &euler_dof_handler->get_fe();
433 const unsigned int n_points = unit_points.size();
435 for (
unsigned int point = 0; point < n_points; ++point)
437 if (data.shape_values.size() != 0)
438 for (
unsigned int i = 0; i < data.n_shape_functions; ++i)
439 data.shape(point, i) = fe->shape_value(i, unit_points[point]);
441 if (data.shape_derivatives.size() != 0)
442 for (
unsigned int i = 0; i < data.n_shape_functions; ++i)
443 data.derivative(point, i) = fe->shape_grad(i, unit_points[point]);
445 if (data.shape_second_derivatives.size() != 0)
446 for (
unsigned int i = 0; i < data.n_shape_functions; ++i)
447 data.second_derivative(point, i) =
448 fe->shape_grad_grad(i, unit_points[point]);
450 if (data.shape_third_derivatives.size() != 0)
451 for (
unsigned int i = 0; i < data.n_shape_functions; ++i)
452 data.third_derivative(point, i) =
453 fe->shape_3rd_derivative(i, unit_points[point]);
455 if (data.shape_fourth_derivatives.size() != 0)
456 for (
unsigned int i = 0; i < data.n_shape_functions; ++i)
457 data.fourth_derivative(point, i) =
458 fe->shape_4th_derivative(i, unit_points[point]);
463template <
int dim,
int spacedim,
typename VectorType>
475 for (
unsigned int i = 0; i < 5; ++i)
518template <
int dim,
int spacedim,
typename VectorType>
523 const unsigned int n_original_q_points,
524 InternalData & data)
const
529 data.update_each = requires_update_flags(update_flags);
531 const unsigned int n_q_points = q.
size();
536 data.shape_values.resize(data.n_shape_functions * n_q_points);
538 if (data.update_each &
542 data.shape_derivatives.resize(data.n_shape_functions * n_q_points);
545 data.covariant.resize(n_original_q_points);
548 data.contravariant.resize(n_original_q_points);
551 data.volume_elements.resize(n_original_q_points);
553 if (data.update_each &
555 data.shape_second_derivatives.resize(data.n_shape_functions * n_q_points);
559 data.shape_third_derivatives.resize(data.n_shape_functions * n_q_points);
563 data.shape_fourth_derivatives.resize(data.n_shape_functions * n_q_points);
573template <
int dim,
int spacedim,
typename VectorType>
578 const unsigned int n_original_q_points,
579 InternalData & data)
const
581 compute_data(update_flags, q, n_original_q_points, data);
592 const auto n_faces = reference_cell.n_faces();
595 for (
unsigned int i = 0; i < n_faces; ++i)
597 data.unit_tangentials[i].resize(n_original_q_points);
599 data.unit_tangentials[i].begin(),
600 data.unit_tangentials[i].end(),
601 reference_cell.template unit_tangential_vectors<dim>(i, 0));
604 data.unit_tangentials[n_faces + i].resize(
605 n_original_q_points);
607 data.unit_tangentials[n_faces + i].begin(),
608 data.unit_tangentials[n_faces + i].end(),
609 reference_cell.template unit_tangential_vectors<dim>(i, 1));
617template <
int dim,
int spacedim,
typename VectorType>
618typename std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
623 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr =
624 std::make_unique<InternalData>(euler_dof_handler->get_fe(), fe_mask);
625 auto &data =
dynamic_cast<InternalData &
>(*data_ptr);
626 this->compute_data(update_flags, quadrature, quadrature.
size(), data);
633template <
int dim,
int spacedim,
typename VectorType>
634std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
641 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr =
642 std::make_unique<InternalData>(euler_dof_handler->get_fe(), fe_mask);
643 auto & data =
dynamic_cast<InternalData &
>(*data_ptr);
646 this->compute_face_data(update_flags, q, quadrature[0].size(), data);
652template <
int dim,
int spacedim,
typename VectorType>
653std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
658 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr =
659 std::make_unique<InternalData>(euler_dof_handler->get_fe(), fe_mask);
660 auto & data =
dynamic_cast<InternalData &
>(*data_ptr);
663 this->compute_face_data(update_flags, q, quadrature.
size(), data);
672 namespace MappingFEFieldImplementation
682 template <
int dim,
int spacedim,
typename VectorType>
684 maybe_compute_q_points(
685 const typename ::QProjector<dim>::DataSetDescriptor data_set,
686 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
690 const std::vector<unsigned int> & fe_to_real,
697 for (
unsigned int point = 0; point < quadrature_points.size();
701 const double * shape = &data.shape(point + data_set, 0);
703 for (
unsigned int k = 0; k < data.n_shape_functions; ++k)
705 const unsigned int comp_k =
708 result[fe_to_real[comp_k]] +=
709 data.local_dof_values[k] * shape[k];
712 quadrature_points[point] = result;
724 template <
int dim,
int spacedim,
typename VectorType>
726 maybe_update_Jacobians(
727 const typename ::QProjector<dim>::DataSetDescriptor data_set,
728 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
732 const std::vector<unsigned int> & fe_to_real)
739 const unsigned int n_q_points = data.contravariant.size();
743 for (
unsigned int point = 0; point < n_q_points; ++point)
746 &data.derivative(point + data_set, 0);
750 for (
unsigned int k = 0; k < data.n_shape_functions; ++k)
752 const unsigned int comp_k =
755 result[fe_to_real[comp_k]] +=
756 data.local_dof_values[k] * data_derv[k];
760 for (
unsigned int i = 0; i < spacedim; ++i)
762 data.contravariant[point][i] = result[i];
770 for (
unsigned int point = 0; point < data.contravariant.size();
772 data.covariant[point] =
773 (data.contravariant[point]).covariant_form();
779 data.volume_elements.size());
780 for (
unsigned int point = 0; point < data.contravariant.size();
782 data.volume_elements[point] =
783 data.contravariant[point].determinant();
793 template <
int dim,
int spacedim,
typename VectorType>
795 maybe_update_jacobian_grads(
796 const typename ::QProjector<dim>::DataSetDescriptor data_set,
797 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
801 const std::vector<unsigned int> & fe_to_real,
807 const unsigned int n_q_points = jacobian_grads.size();
809 for (
unsigned int point = 0; point < n_q_points; ++point)
812 &data.second_derivative(point + data_set, 0);
816 for (
unsigned int k = 0; k < data.n_shape_functions; ++k)
818 const unsigned int comp_k =
821 for (
unsigned int j = 0; j < dim; ++j)
822 for (
unsigned int l = 0; l < dim; ++l)
823 result[fe_to_real[comp_k]][j][l] +=
824 (
second[k][j][l] * data.local_dof_values[k]);
829 for (
unsigned int i = 0; i < spacedim; ++i)
830 for (
unsigned int j = 0; j < dim; ++j)
831 for (
unsigned int l = 0; l < dim; ++l)
832 jacobian_grads[point][i][j][l] = result[i][j][l];
843 template <
int dim,
int spacedim,
typename VectorType>
845 maybe_update_jacobian_pushed_forward_grads(
846 const typename ::QProjector<dim>::DataSetDescriptor data_set,
847 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
851 const std::vector<unsigned int> & fe_to_real,
857 const unsigned int n_q_points =
858 jacobian_pushed_forward_grads.size();
860 double tmp[spacedim][spacedim][spacedim];
861 for (
unsigned int point = 0; point < n_q_points; ++point)
864 &data.second_derivative(point + data_set, 0);
868 for (
unsigned int k = 0; k < data.n_shape_functions; ++k)
870 const unsigned int comp_k =
873 for (
unsigned int j = 0; j < dim; ++j)
874 for (
unsigned int l = 0; l < dim; ++l)
875 result[fe_to_real[comp_k]][j][l] +=
876 (
second[k][j][l] * data.local_dof_values[k]);
880 for (
unsigned int i = 0; i < spacedim; ++i)
881 for (
unsigned int j = 0; j < spacedim; ++j)
882 for (
unsigned int l = 0; l < dim; ++l)
885 result[i][0][l] * data.covariant[point][j][0];
886 for (
unsigned int jr = 1; jr < dim; ++jr)
889 result[i][jr][l] * data.covariant[point][j][jr];
894 for (
unsigned int i = 0; i < spacedim; ++i)
895 for (
unsigned int j = 0; j < spacedim; ++j)
896 for (
unsigned int l = 0; l < spacedim; ++l)
898 jacobian_pushed_forward_grads[point][i][j][l] =
899 tmp[i][j][0] * data.covariant[point][l][0];
900 for (
unsigned int lr = 1; lr < dim; ++lr)
902 jacobian_pushed_forward_grads[point][i][j][l] +=
903 tmp[i][j][lr] * data.covariant[point][l][lr];
916 template <
int dim,
int spacedim,
typename VectorType>
918 maybe_update_jacobian_2nd_derivatives(
919 const typename ::QProjector<dim>::DataSetDescriptor data_set,
920 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
924 const std::vector<unsigned int> & fe_to_real,
930 const unsigned int n_q_points = jacobian_2nd_derivatives.size();
932 for (
unsigned int point = 0; point < n_q_points; ++point)
935 &data.third_derivative(point + data_set, 0);
939 for (
unsigned int k = 0; k < data.n_shape_functions; ++k)
941 const unsigned int comp_k =
944 for (
unsigned int j = 0; j < dim; ++j)
945 for (
unsigned int l = 0; l < dim; ++l)
946 for (
unsigned int m = 0; m < dim; ++m)
947 result[fe_to_real[comp_k]][j][l][m] +=
948 (third[k][j][l][m] * data.local_dof_values[k]);
953 for (
unsigned int i = 0; i < spacedim; ++i)
954 for (
unsigned int j = 0; j < dim; ++j)
955 for (
unsigned int l = 0; l < dim; ++l)
956 for (
unsigned int m = 0; m < dim; ++m)
957 jacobian_2nd_derivatives[point][i][j][l][m] =
970 template <
int dim,
int spacedim,
typename VectorType>
972 maybe_update_jacobian_pushed_forward_2nd_derivatives(
973 const typename ::QProjector<dim>::DataSetDescriptor data_set,
974 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
978 const std::vector<unsigned int> & fe_to_real,
980 &jacobian_pushed_forward_2nd_derivatives)
985 const unsigned int n_q_points =
986 jacobian_pushed_forward_2nd_derivatives.size();
988 double tmp[spacedim][spacedim][spacedim][spacedim];
989 for (
unsigned int point = 0; point < n_q_points; ++point)
992 &data.third_derivative(point + data_set, 0);
996 for (
unsigned int k = 0; k < data.n_shape_functions; ++k)
998 const unsigned int comp_k =
1000 if (fe_mask[comp_k])
1001 for (
unsigned int j = 0; j < dim; ++j)
1002 for (
unsigned int l = 0; l < dim; ++l)
1003 for (
unsigned int m = 0; m < dim; ++m)
1004 result[fe_to_real[comp_k]][j][l][m] +=
1005 (third[k][j][l][m] * data.local_dof_values[k]);
1009 for (
unsigned int i = 0; i < spacedim; ++i)
1010 for (
unsigned int j = 0; j < spacedim; ++j)
1011 for (
unsigned int l = 0; l < dim; ++l)
1012 for (
unsigned int m = 0; m < dim; ++m)
1014 jacobian_pushed_forward_2nd_derivatives
1015 [point][i][j][l][m] =
1016 result[i][0][l][m] * data.covariant[point][j][0];
1017 for (
unsigned int jr = 1; jr < dim; ++jr)
1018 jacobian_pushed_forward_2nd_derivatives[point][i][j]
1020 result[i][jr][l][m] *
1021 data.covariant[point][j][jr];
1025 for (
unsigned int i = 0; i < spacedim; ++i)
1026 for (
unsigned int j = 0; j < spacedim; ++j)
1027 for (
unsigned int l = 0; l < spacedim; ++l)
1028 for (
unsigned int m = 0; m < dim; ++m)
1031 jacobian_pushed_forward_2nd_derivatives[point][i][j]
1033 data.covariant[point][l][0];
1034 for (
unsigned int lr = 1; lr < dim; ++lr)
1036 jacobian_pushed_forward_2nd_derivatives[point][i]
1039 data.covariant[point][l][lr];
1043 for (
unsigned int i = 0; i < spacedim; ++i)
1044 for (
unsigned int j = 0; j < spacedim; ++j)
1045 for (
unsigned int l = 0; l < spacedim; ++l)
1046 for (
unsigned int m = 0; m < spacedim; ++m)
1048 jacobian_pushed_forward_2nd_derivatives
1049 [point][i][j][l][m] =
1050 tmp[i][j][l][0] * data.covariant[point][m][0];
1051 for (
unsigned int mr = 1; mr < dim; ++mr)
1052 jacobian_pushed_forward_2nd_derivatives[point][i][j]
1054 tmp[i][j][l][mr] * data.covariant[point][m][mr];
1066 template <
int dim,
int spacedim,
typename VectorType>
1068 maybe_update_jacobian_3rd_derivatives(
1069 const typename ::QProjector<dim>::DataSetDescriptor data_set,
1070 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
1071 InternalData & data,
1074 const std::vector<unsigned int> & fe_to_real,
1077 const UpdateFlags update_flags = data.update_each;
1080 const unsigned int n_q_points = jacobian_3rd_derivatives.size();
1082 for (
unsigned int point = 0; point < n_q_points; ++point)
1085 &data.fourth_derivative(point + data_set, 0);
1089 for (
unsigned int k = 0; k < data.n_shape_functions; ++k)
1091 const unsigned int comp_k =
1093 if (fe_mask[comp_k])
1094 for (
unsigned int j = 0; j < dim; ++j)
1095 for (
unsigned int l = 0; l < dim; ++l)
1096 for (
unsigned int m = 0; m < dim; ++m)
1097 for (
unsigned int n = 0; n < dim; ++n)
1098 result[fe_to_real[comp_k]][j][l][m][n] +=
1099 (fourth[k][j][l][m][n] *
1100 data.local_dof_values[k]);
1106 for (
unsigned int i = 0; i < spacedim; ++i)
1107 for (
unsigned int j = 0; j < dim; ++j)
1108 for (
unsigned int l = 0; l < dim; ++l)
1109 for (
unsigned int m = 0; m < dim; ++m)
1110 for (
unsigned int n = 0; n < dim; ++n)
1111 jacobian_3rd_derivatives[point][i][j][l][m][n] =
1112 result[i][j][l][m][n];
1124 template <
int dim,
int spacedim,
typename VectorType>
1126 maybe_update_jacobian_pushed_forward_3rd_derivatives(
1127 const typename ::QProjector<dim>::DataSetDescriptor data_set,
1128 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
1129 InternalData & data,
1132 const std::vector<unsigned int> & fe_to_real,
1134 &jacobian_pushed_forward_3rd_derivatives)
1136 const UpdateFlags update_flags = data.update_each;
1139 const unsigned int n_q_points =
1140 jacobian_pushed_forward_3rd_derivatives.size();
1142 double tmp[spacedim][spacedim][spacedim][spacedim][spacedim];
1143 for (
unsigned int point = 0; point < n_q_points; ++point)
1146 &data.fourth_derivative(point + data_set, 0);
1150 for (
unsigned int k = 0; k < data.n_shape_functions; ++k)
1152 const unsigned int comp_k =
1154 if (fe_mask[comp_k])
1155 for (
unsigned int j = 0; j < dim; ++j)
1156 for (
unsigned int l = 0; l < dim; ++l)
1157 for (
unsigned int m = 0; m < dim; ++m)
1158 for (
unsigned int n = 0; n < dim; ++n)
1159 result[fe_to_real[comp_k]][j][l][m][n] +=
1160 (fourth[k][j][l][m][n] *
1161 data.local_dof_values[k]);
1165 for (
unsigned int i = 0; i < spacedim; ++i)
1166 for (
unsigned int j = 0; j < spacedim; ++j)
1167 for (
unsigned int l = 0; l < dim; ++l)
1168 for (
unsigned int m = 0; m < dim; ++m)
1169 for (
unsigned int n = 0; n < dim; ++n)
1171 tmp[i][j][l][m][n] = result[i][0][l][m][n] *
1172 data.covariant[point][j][0];
1173 for (
unsigned int jr = 1; jr < dim; ++jr)
1174 tmp[i][j][l][m][n] +=
1175 result[i][jr][l][m][n] *
1176 data.covariant[point][j][jr];
1180 for (
unsigned int i = 0; i < spacedim; ++i)
1181 for (
unsigned int j = 0; j < spacedim; ++j)
1182 for (
unsigned int l = 0; l < spacedim; ++l)
1183 for (
unsigned int m = 0; m < dim; ++m)
1184 for (
unsigned int n = 0; n < dim; ++n)
1186 jacobian_pushed_forward_3rd_derivatives
1187 [point][i][j][l][m][n] =
1188 tmp[i][j][0][m][n] *
1189 data.covariant[point][l][0];
1190 for (
unsigned int lr = 1; lr < dim; ++lr)
1191 jacobian_pushed_forward_3rd_derivatives[point][i]
1194 tmp[i][j][lr][m][n] *
1195 data.covariant[point][l][lr];
1199 for (
unsigned int i = 0; i < spacedim; ++i)
1200 for (
unsigned int j = 0; j < spacedim; ++j)
1201 for (
unsigned int l = 0; l < spacedim; ++l)
1202 for (
unsigned int m = 0; m < spacedim; ++m)
1203 for (
unsigned int n = 0; n < dim; ++n)
1205 tmp[i][j][l][m][n] =
1206 jacobian_pushed_forward_3rd_derivatives[point][i]
1209 data.covariant[point][m][0];
1210 for (
unsigned int mr = 1; mr < dim; ++mr)
1211 tmp[i][j][l][m][n] +=
1212 jacobian_pushed_forward_3rd_derivatives[point]
1215 data.covariant[point][m][mr];
1219 for (
unsigned int i = 0; i < spacedim; ++i)
1220 for (
unsigned int j = 0; j < spacedim; ++j)
1221 for (
unsigned int l = 0; l < spacedim; ++l)
1222 for (
unsigned int m = 0; m < spacedim; ++m)
1223 for (
unsigned int n = 0; n < spacedim; ++n)
1225 jacobian_pushed_forward_3rd_derivatives
1226 [point][i][j][l][m][n] =
1227 tmp[i][j][l][m][0] *
1228 data.covariant[point][n][0];
1229 for (
unsigned int nr = 1; nr < dim; ++nr)
1230 jacobian_pushed_forward_3rd_derivatives[point][i]
1233 tmp[i][j][l][m][nr] *
1234 data.covariant[point][n][nr];
1250 template <
int dim,
int spacedim,
typename VectorType>
1252 maybe_compute_face_data(
1253 const ::Mapping<dim, spacedim> &mapping,
1254 const typename ::Triangulation<dim, spacedim>::cell_iterator
1256 const unsigned int face_no,
1257 const unsigned int subface_no,
1259 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
1264 const UpdateFlags update_flags = data.update_each;
1268 const unsigned int n_q_points = output_data.
boundary_forms.size();
1277 for (
unsigned int d = 0; d != dim - 1; ++d)
1279 Assert(face_no + cell->n_faces() * d <
1280 data.unit_tangentials.size(),
1283 data.aux[d].size() <=
1284 data.unit_tangentials[face_no + cell->n_faces() * d].size(),
1289 data.unit_tangentials[face_no + cell->n_faces() * d]),
1297 if (dim == spacedim)
1299 for (
unsigned int i = 0; i < n_q_points; ++i)
1308 (face_no == 0 ? -1 : +1);
1332 for (
unsigned int point = 0; point < n_q_points; ++point)
1338 data.contravariant[point].transpose()[0];
1340 (face_no == 0 ? -1. : +1.) *
1351 cell_normal /= cell_normal.
norm();
1369 data.quadrature_weights[i + data_set];
1374 const double area_ratio =
1376 cell->subface_case(face_no), subface_no);
1388 for (
unsigned int point = 0; point < n_q_points; ++point)
1389 output_data.
jacobians[point] = data.contravariant[point];
1392 for (
unsigned int point = 0; point < n_q_points; ++point)
1394 data.covariant[point].transpose();
1404 template <
int dim,
int spacedim,
typename VectorType>
1406 do_fill_fe_face_values(
1407 const ::Mapping<dim, spacedim> &mapping,
1408 const typename ::Triangulation<dim, spacedim>::cell_iterator
1410 const unsigned int face_no,
1411 const unsigned int subface_no,
1412 const typename ::QProjector<dim>::DataSetDescriptor data_set,
1413 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
1414 InternalData & data,
1417 const std::vector<unsigned int> & fe_to_real,
1421 maybe_compute_q_points<dim, spacedim, VectorType>(
1429 maybe_update_Jacobians<dim, spacedim, VectorType>(
1430 data_set, data, fe, fe_mask, fe_to_real);
1432 maybe_update_jacobian_grads<dim, spacedim, VectorType>(
1433 data_set, data, fe, fe_mask, fe_to_real, output_data.
jacobian_grads);
1435 maybe_update_jacobian_pushed_forward_grads<dim, spacedim, VectorType>(
1443 maybe_update_jacobian_2nd_derivatives<dim, spacedim, VectorType>(
1451 maybe_update_jacobian_pushed_forward_2nd_derivatives<dim,
1461 maybe_update_jacobian_3rd_derivatives<dim, spacedim, VectorType>(
1469 maybe_update_jacobian_pushed_forward_3rd_derivatives<dim,
1479 maybe_compute_face_data<dim, spacedim, VectorType>(
1480 mapping, cell, face_no, subface_no, data_set, data, output_data);
1489template <
int dim,
int spacedim,
typename VectorType>
1501 Assert(
dynamic_cast<const InternalData *
>(&internal_data) !=
nullptr,
1503 const InternalData &data =
static_cast<const InternalData &
>(internal_data);
1505 const unsigned int n_q_points = quadrature.
size();
1507 update_internal_dofs(cell, data);
1509 internal::MappingFEFieldImplementation::
1510 maybe_compute_q_points<dim, spacedim, VectorType>(
1513 euler_dof_handler->get_fe(),
1518 internal::MappingFEFieldImplementation::
1519 maybe_update_Jacobians<dim, spacedim, VectorType>(
1522 euler_dof_handler->get_fe(),
1526 const UpdateFlags update_flags = data.update_each;
1527 const std::vector<double> &weights = quadrature.
get_weights();
1542 for (
unsigned int point = 0; point < n_q_points; ++point)
1544 if (dim == spacedim)
1546 const double det = data.contravariant[point].determinant();
1553 Assert(det > 1e-12 * Utilities::fixed_power<dim>(
1554 cell->diameter() /
std::sqrt(
double(dim))),
1556 cell->center(), det, point)));
1557 output_data.
JxW_values[point] = weights[point] * det;
1565 for (
unsigned int i = 0; i < spacedim; ++i)
1566 for (
unsigned int j = 0; j < dim; ++j)
1567 DX_t[j][i] = data.contravariant[point][i][j];
1570 for (
unsigned int i = 0; i < dim; ++i)
1571 for (
unsigned int j = 0; j < dim; ++j)
1572 G[i][j] = DX_t[i] * DX_t[j];
1579 Assert(spacedim - dim == 1,
1580 ExcMessage(
"There is no cell normal in codim 2."));
1598 if (cell->direction_flag() ==
false)
1609 for (
unsigned int point = 0; point < n_q_points; ++point)
1610 output_data.
jacobians[point] = data.contravariant[point];
1617 for (
unsigned int point = 0; point < n_q_points; ++point)
1619 data.covariant[point].transpose();
1623 internal::MappingFEFieldImplementation::
1624 maybe_update_jacobian_grads<dim, spacedim, VectorType>(
1627 euler_dof_handler->get_fe(),
1634 internal::MappingFEFieldImplementation::
1635 maybe_update_jacobian_pushed_forward_grads<dim, spacedim, VectorType>(
1638 euler_dof_handler->get_fe(),
1644 internal::MappingFEFieldImplementation::
1645 maybe_update_jacobian_2nd_derivatives<dim, spacedim, VectorType>(
1648 euler_dof_handler->get_fe(),
1654 internal::MappingFEFieldImplementation::
1655 maybe_update_jacobian_pushed_forward_2nd_derivatives<dim,
1660 euler_dof_handler->get_fe(),
1666 internal::MappingFEFieldImplementation::
1667 maybe_update_jacobian_3rd_derivatives<dim, spacedim, VectorType>(
1670 euler_dof_handler->get_fe(),
1677 internal::MappingFEFieldImplementation::
1678 maybe_update_jacobian_pushed_forward_3rd_derivatives<dim,
1683 euler_dof_handler->get_fe(),
1693template <
int dim,
int spacedim,
typename VectorType>
1697 const unsigned int face_no,
1707 Assert(
dynamic_cast<const InternalData *
>(&internal_data) !=
nullptr,
1709 const InternalData &data =
static_cast<const InternalData &
>(internal_data);
1711 update_internal_dofs(cell, data);
1713 internal::MappingFEFieldImplementation::
1714 do_fill_fe_face_values<dim, spacedim, VectorType>(
1721 cell->face_orientation(face_no),
1722 cell->face_flip(face_no),
1723 cell->face_rotation(face_no),
1724 quadrature[0].
size()),
1726 euler_dof_handler->get_fe(),
1733template <
int dim,
int spacedim,
typename VectorType>
1737 const unsigned int face_no,
1738 const unsigned int subface_no,
1746 Assert(
dynamic_cast<const InternalData *
>(&internal_data) !=
nullptr,
1748 const InternalData &data =
static_cast<const InternalData &
>(internal_data);
1750 update_internal_dofs(cell, data);
1752 internal::MappingFEFieldImplementation::do_fill_fe_face_values<dim,
1762 cell->face_orientation(face_no),
1763 cell->face_flip(face_no),
1764 cell->face_rotation(face_no),
1766 cell->subface_case(face_no)),
1768 euler_dof_handler->get_fe(),
1777 namespace MappingFEFieldImplementation
1781 template <
int dim,
int spacedim,
int rank,
typename VectorType>
1793 MappingFEField<dim, spacedim, VectorType, void>::InternalData *
>(
1794 &mapping_data) !=
nullptr),
1796 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
1797 InternalData &data =
static_cast<
1799 MappingFEField<dim, spacedim, VectorType, void>::InternalData &
>(
1802 switch (mapping_kind)
1809 "update_contravariant_transformation"));
1811 for (
unsigned int i = 0; i < output.size(); ++i)
1823 "update_contravariant_transformation"));
1827 "update_volume_elements"));
1829 for (
unsigned int i = 0; i < output.size(); ++i)
1833 output[i] /= data.volume_elements[i];
1847 "update_contravariant_transformation"));
1849 for (
unsigned int i = 0; i < output.size(); ++i)
1861 template <
int dim,
int spacedim,
int rank,
typename VectorType>
1873 MappingFEField<dim, spacedim, VectorType, void>::InternalData *
>(
1874 &mapping_data) !=
nullptr),
1876 const typename ::MappingFEField<dim, spacedim, VectorType, void>::
1877 InternalData &data =
static_cast<
1879 MappingFEField<dim, spacedim, VectorType, void>::InternalData &
>(
1882 switch (mapping_kind)
1889 "update_contravariant_transformation"));
1891 for (
unsigned int i = 0; i < output.size(); ++i)
1906template <
int dim,
int spacedim,
typename VectorType>
1916 internal::MappingFEFieldImplementation::
1917 transform_fields<dim, spacedim, 1, VectorType>(input,
1925template <
int dim,
int spacedim,
typename VectorType>
1935 internal::MappingFEFieldImplementation::
1936 transform_differential_forms<dim, spacedim, 1, VectorType>(input,
1944template <
int dim,
int spacedim,
typename VectorType>
1962template <
int dim,
int spacedim,
typename VectorType>
1971 Assert(
dynamic_cast<const InternalData *
>(&mapping_data) !=
nullptr,
1973 const InternalData &data =
static_cast<const InternalData &
>(mapping_data);
1975 switch (mapping_kind)
1981 "update_covariant_transformation"));
1983 for (
unsigned int q = 0; q < output.size(); ++q)
1984 for (
unsigned int i = 0; i < spacedim; ++i)
1985 for (
unsigned int j = 0; j < spacedim; ++j)
1986 for (
unsigned int k = 0; k < spacedim; ++k)
1988 output[q][i][j][k] = data.covariant[q][j][0] *
1989 data.covariant[q][k][0] *
1991 for (
unsigned int J = 0; J < dim; ++J)
1993 const unsigned int K0 = (0 == J) ? 1 : 0;
1994 for (
unsigned int K = K0; K < dim; ++K)
1995 output[q][i][j][k] += data.covariant[q][j][J] *
1996 data.covariant[q][k][K] *
2010template <
int dim,
int spacedim,
typename VectorType>
2028template <
int dim,
int spacedim,
typename VectorType>
2038 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> mdata(
2040 Assert(
dynamic_cast<InternalData *
>(mdata.get()) !=
nullptr,
2043 update_internal_dofs(cell,
dynamic_cast<InternalData &
>(*mdata));
2045 return do_transform_unit_to_real_cell(
dynamic_cast<InternalData &
>(*mdata));
2049template <
int dim,
int spacedim,
typename VectorType>
2052 const InternalData &data)
const
2056 for (
unsigned int i = 0; i < data.n_shape_functions; ++i)
2058 unsigned int comp_i =
2059 euler_dof_handler->get_fe().system_to_component_index(i).first;
2060 if (fe_mask[comp_i])
2061 p_real[fe_to_real[comp_i]] +=
2062 data.local_dof_values[i] * data.shape(0, i);
2070template <
int dim,
int spacedim,
typename VectorType>
2089 for (
unsigned int d = 0; d < dim; ++d)
2090 initial_p_unit[d] = 0.5;
2104 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> mdata(
2105 get_data(update_flags, point_quadrature));
2106 Assert(
dynamic_cast<InternalData *
>(mdata.get()) !=
nullptr,
2109 update_internal_dofs(cell,
dynamic_cast<InternalData &
>(*mdata));
2111 return do_transform_real_to_unit_cell(cell,
2114 dynamic_cast<InternalData &
>(*mdata));
2118template <
int dim,
int spacedim,
typename VectorType>
2124 InternalData & mdata)
const
2126 const unsigned int n_shapes = mdata.shape_values.size();
2143 compute_shapes_virtual(std::vector<
Point<dim>>(1, p_unit), mdata);
2146 const double eps = 1.e-12 * cell->diameter();
2147 const unsigned int newton_iteration_limit = 20;
2148 unsigned int newton_iteration = 0;
2154 for (
unsigned int k = 0; k < mdata.n_shape_functions; ++k)
2157 const unsigned int comp_k =
2158 euler_dof_handler->get_fe().system_to_component_index(k).first;
2159 if (fe_mask[comp_k])
2160 for (
unsigned int j = 0; j < dim; ++j)
2161 DF[j][fe_to_real[comp_k]] +=
2162 mdata.local_dof_values[k] * grad_k[j];
2164 for (
unsigned int j = 0; j < dim; ++j)
2166 f[j] = DF[j] * p_minus_F;
2167 for (
unsigned int l = 0; l < dim; ++l)
2168 df[j][l] = -DF[j] * DF[l];
2174 double step_length = 1;
2187 for (
unsigned int i = 0; i < dim; ++i)
2188 p_unit_trial[i] -= step_length * delta[i];
2191 compute_shapes_virtual(std::vector<
Point<dim>>(1, p_unit_trial),
2198 if (f_trial.
norm() < p_minus_F.
norm())
2200 p_real = p_real_trial;
2201 p_unit = p_unit_trial;
2202 p_minus_F = f_trial;
2205 else if (step_length > 0.05)
2212 if (newton_iteration > newton_iteration_limit)
2229template <
int dim,
int spacedim,
typename VectorType>
2233 return euler_dof_handler->get_fe().degree;
2238template <
int dim,
int spacedim,
typename VectorType>
2242 return this->fe_mask;
2246template <
int dim,
int spacedim,
typename VectorType>
2247std::unique_ptr<Mapping<dim, spacedim>>
2250 return std::make_unique<MappingFEField<dim, spacedim, VectorType, void>>(
2255template <
int dim,
int spacedim,
typename VectorType>
2262 Assert(euler_dof_handler !=
nullptr,
2267 Assert(uses_level_dofs || dof_cell->is_active() ==
true, ExcInactiveCell());
2268 if (uses_level_dofs)
2272 euler_dof_handler->n_dofs(cell->level()));
2275 AssertDimension(euler_vector[0]->size(), euler_dof_handler->n_dofs());
2277 if (uses_level_dofs)
2278 dof_cell->get_mg_dof_indices(data.local_dof_indices);
2280 dof_cell->get_dof_indices(data.local_dof_indices);
2282 const VectorType &vector =
2283 uses_level_dofs ? *euler_vector[cell->level()] : *euler_vector[0];
2285 for (
unsigned int i = 0; i < data.local_dof_values.size(); ++i)
2286 data.local_dof_values[i] =
2288 data.local_dof_indices[i]);
2292#define SPLIT_INSTANTIATIONS_COUNT 2
2293#ifndef SPLIT_INSTANTIATIONS_INDEX
2294# define SPLIT_INSTANTIATIONS_INDEX 0
2296#include "mapping_fe_field.inst"
ArrayView< typename std::remove_reference< typename std::iterator_traits< Iterator >::reference >::type, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
const Triangulation< dim, spacedim > & get_triangulation() const
bool has_level_dofs() const
std::pair< unsigned int, unsigned int > system_to_component_index(const unsigned int index) const
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel, Args &&...args)
unsigned int max_level() const
unsigned int min_level() const
Abstract base class for mapping classes.
virtual Point< dim > transform_real_to_unit_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< spacedim > &p) const =0
static DataSetDescriptor cell()
static DataSetDescriptor subface(const unsigned int face_no, const unsigned int subface_no, const bool face_orientation, const bool face_flip, const bool face_rotation, const unsigned int n_quadrature_points, const internal::SubfaceCase< dim > ref_case=internal::SubfaceCase< dim >::case_isotropic)
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
constexpr numbers::NumberTraits< Number >::real_type norm_square() const
virtual unsigned int n_global_levels() const
unsigned int size() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
@ 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_values
Shape function values.
@ 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
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)
typename ActiveSelector::cell_iterator cell_iterator
@ mapping_covariant_gradient
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
std::string to_string(const number 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)
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)
static Point< dim, Number > project_to_unit_cell(const Point< dim, Number > &p)
static VectorType::value_type get(const VectorType &V, const types::global_dof_index i)
constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &)
constexpr SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &)
constexpr Tensor< 1, dim, Number > cross_product_2d(const Tensor< 1, dim, Number > &src)
constexpr Tensor< 1, dim, typename ProductType< Number1, Number2 >::type > cross_product_3d(const Tensor< 1, dim, Number1 > &src1, const Tensor< 1, dim, Number2 > &src2)