685 namespace MappingFEFieldImplementation
695 template <
int dim,
int spacedim,
typename VectorType>
697 maybe_compute_q_points(
698 const typename ::QProjector<dim>::DataSetDescriptor data_set,
699 const typename ::MappingFEField<dim, spacedim, VectorType>::
703 const std::vector<unsigned int> &fe_to_real,
704 std::vector<Point<spacedim>> &quadrature_points)
710 for (
unsigned int point = 0; point < quadrature_points.size();
714 const double *shape = &
data.shape(point + data_set, 0);
716 for (
unsigned int k = 0; k <
data.n_shape_functions; ++k)
718 const unsigned int comp_k =
719 fe.system_to_component_index(k).first;
721 result[fe_to_real[comp_k]] +=
722 data.local_dof_values[k] * shape[k];
725 quadrature_points[point] = result;
737 template <
int dim,
int spacedim,
typename VectorType>
739 maybe_update_Jacobians(
740 const typename ::QProjector<dim>::DataSetDescriptor data_set,
741 const typename ::MappingFEField<dim, spacedim, VectorType>::
745 const std::vector<unsigned int> &fe_to_real)
752 const unsigned int n_q_points =
data.contravariant.size();
756 for (
unsigned int point = 0; point < n_q_points; ++point)
759 &
data.derivative(point + data_set, 0);
763 for (
unsigned int k = 0; k <
data.n_shape_functions; ++k)
765 const unsigned int comp_k =
766 fe.system_to_component_index(k).first;
768 result[fe_to_real[comp_k]] +=
769 data.local_dof_values[k] * data_derv[k];
773 for (
unsigned int i = 0; i < spacedim; ++i)
775 data.contravariant[point][i] = result[i];
783 for (
unsigned int point = 0; point <
data.contravariant.size();
785 data.covariant[point] =
786 (
data.contravariant[point]).covariant_form();
792 data.volume_elements.size());
793 for (
unsigned int point = 0; point <
data.contravariant.size();
795 data.volume_elements[point] =
796 data.contravariant[point].determinant();
806 template <
int dim,
int spacedim,
typename VectorType>
808 maybe_update_jacobian_grads(
809 const typename ::QProjector<dim>::DataSetDescriptor data_set,
810 const typename ::MappingFEField<dim, spacedim, VectorType>::
814 const std::vector<unsigned int> &fe_to_real,
815 std::vector<DerivativeForm<2, dim, spacedim>> &jacobian_grads)
820 const unsigned int n_q_points = jacobian_grads.size();
822 for (
unsigned int point = 0; point < n_q_points; ++point)
825 &
data.second_derivative(point + data_set, 0);
829 for (
unsigned int k = 0; k <
data.n_shape_functions; ++k)
831 const unsigned int comp_k =
832 fe.system_to_component_index(k).first;
834 for (
unsigned int j = 0; j < dim; ++j)
835 for (
unsigned int l = 0; l < dim; ++l)
836 result[fe_to_real[comp_k]][j][l] +=
842 for (
unsigned int i = 0; i < spacedim; ++i)
843 for (
unsigned int j = 0; j < dim; ++j)
844 for (
unsigned int l = 0; l < dim; ++l)
845 jacobian_grads[point][i][j][l] = result[i][j][l];
856 template <
int dim,
int spacedim,
typename VectorType>
858 maybe_update_jacobian_pushed_forward_grads(
859 const typename ::QProjector<dim>::DataSetDescriptor data_set,
860 const typename ::MappingFEField<dim, spacedim, VectorType>::
864 const std::vector<unsigned int> &fe_to_real,
865 std::vector<Tensor<3, spacedim>> &jacobian_pushed_forward_grads)
870 const unsigned int n_q_points =
871 jacobian_pushed_forward_grads.size();
873 double tmp[spacedim][spacedim][spacedim];
874 for (
unsigned int point = 0; point < n_q_points; ++point)
877 &
data.second_derivative(point + data_set, 0);
881 for (
unsigned int k = 0; k <
data.n_shape_functions; ++k)
883 const unsigned int comp_k =
884 fe.system_to_component_index(k).first;
886 for (
unsigned int j = 0; j < dim; ++j)
887 for (
unsigned int l = 0; l < dim; ++l)
888 result[fe_to_real[comp_k]][j][l] +=
893 for (
unsigned int i = 0; i < spacedim; ++i)
894 for (
unsigned int j = 0; j < spacedim; ++j)
895 for (
unsigned int l = 0; l < dim; ++l)
898 result[i][0][l] *
data.covariant[point][j][0];
899 for (
unsigned int jr = 1; jr < dim; ++jr)
902 result[i][jr][l] *
data.covariant[point][j][jr];
907 for (
unsigned int i = 0; i < spacedim; ++i)
908 for (
unsigned int j = 0; j < spacedim; ++j)
909 for (
unsigned int l = 0; l < spacedim; ++l)
911 jacobian_pushed_forward_grads[point][i][j][l] =
912 tmp[i][j][0] *
data.covariant[point][l][0];
913 for (
unsigned int lr = 1; lr < dim; ++lr)
915 jacobian_pushed_forward_grads[point][i][j][l] +=
916 tmp[i][j][lr] *
data.covariant[point][l][lr];
929 template <
int dim,
int spacedim,
typename VectorType>
931 maybe_update_jacobian_2nd_derivatives(
932 const typename ::QProjector<dim>::DataSetDescriptor data_set,
933 const typename ::MappingFEField<dim, spacedim, VectorType>::
937 const std::vector<unsigned int> &fe_to_real,
938 std::vector<DerivativeForm<3, dim, spacedim>> &jacobian_2nd_derivatives)
943 const unsigned int n_q_points = jacobian_2nd_derivatives.size();
945 for (
unsigned int point = 0; point < n_q_points; ++point)
948 &
data.third_derivative(point + data_set, 0);
952 for (
unsigned int k = 0; k <
data.n_shape_functions; ++k)
954 const unsigned int comp_k =
955 fe.system_to_component_index(k).first;
957 for (
unsigned int j = 0; j < dim; ++j)
958 for (
unsigned int l = 0; l < dim; ++l)
959 for (
unsigned int m = 0; m < dim; ++m)
960 result[fe_to_real[comp_k]][j][l][m] +=
961 (third[k][j][l][m] *
data.local_dof_values[k]);
966 for (
unsigned int i = 0; i < spacedim; ++i)
967 for (
unsigned int j = 0; j < dim; ++j)
968 for (
unsigned int l = 0; l < dim; ++l)
969 for (
unsigned int m = 0; m < dim; ++m)
970 jacobian_2nd_derivatives[point][i][j][l][m] =
983 template <
int dim,
int spacedim,
typename VectorType>
985 maybe_update_jacobian_pushed_forward_2nd_derivatives(
986 const typename ::QProjector<dim>::DataSetDescriptor data_set,
987 const typename ::MappingFEField<dim, spacedim, VectorType>::
991 const std::vector<unsigned int> &fe_to_real,
992 std::vector<Tensor<4, spacedim>>
993 &jacobian_pushed_forward_2nd_derivatives)
998 const unsigned int n_q_points =
999 jacobian_pushed_forward_2nd_derivatives.size();
1001 double tmp[spacedim][spacedim][spacedim][spacedim];
1002 for (
unsigned int point = 0; point < n_q_points; ++point)
1005 &
data.third_derivative(point + data_set, 0);
1009 for (
unsigned int k = 0; k <
data.n_shape_functions; ++k)
1011 const unsigned int comp_k =
1012 fe.system_to_component_index(k).first;
1013 if (fe_mask[comp_k])
1014 for (
unsigned int j = 0; j < dim; ++j)
1015 for (
unsigned int l = 0; l < dim; ++l)
1016 for (
unsigned int m = 0; m < dim; ++m)
1017 result[fe_to_real[comp_k]][j][l][m] +=
1018 (third[k][j][l][m] *
data.local_dof_values[k]);
1022 for (
unsigned int i = 0; i < spacedim; ++i)
1023 for (
unsigned int j = 0; j < spacedim; ++j)
1024 for (
unsigned int l = 0; l < dim; ++l)
1025 for (
unsigned int m = 0; m < dim; ++m)
1027 jacobian_pushed_forward_2nd_derivatives
1028 [point][i][j][l][m] =
1029 result[i][0][l][m] *
data.covariant[point][j][0];
1030 for (
unsigned int jr = 1; jr < dim; ++jr)
1031 jacobian_pushed_forward_2nd_derivatives[point][i][j]
1033 result[i][jr][l][m] *
1034 data.covariant[point][j][jr];
1038 for (
unsigned int i = 0; i < spacedim; ++i)
1039 for (
unsigned int j = 0; j < spacedim; ++j)
1040 for (
unsigned int l = 0; l < spacedim; ++l)
1041 for (
unsigned int m = 0; m < dim; ++m)
1044 jacobian_pushed_forward_2nd_derivatives[point][i][j]
1046 data.covariant[point][l][0];
1047 for (
unsigned int lr = 1; lr < dim; ++lr)
1049 jacobian_pushed_forward_2nd_derivatives[point][i]
1052 data.covariant[point][l][lr];
1056 for (
unsigned int i = 0; i < spacedim; ++i)
1057 for (
unsigned int j = 0; j < spacedim; ++j)
1058 for (
unsigned int l = 0; l < spacedim; ++l)
1059 for (
unsigned int m = 0; m < spacedim; ++m)
1061 jacobian_pushed_forward_2nd_derivatives
1062 [point][i][j][l][m] =
1063 tmp[i][j][l][0] *
data.covariant[point][m][0];
1064 for (
unsigned int mr = 1; mr < dim; ++mr)
1065 jacobian_pushed_forward_2nd_derivatives[point][i][j]
1067 tmp[i][j][l][mr] *
data.covariant[point][m][mr];
1079 template <
int dim,
int spacedim,
typename VectorType>
1081 maybe_update_jacobian_3rd_derivatives(
1082 const typename ::QProjector<dim>::DataSetDescriptor data_set,
1083 const typename ::MappingFEField<dim, spacedim, VectorType>::
1087 const std::vector<unsigned int> &fe_to_real,
1088 std::vector<DerivativeForm<4, dim, spacedim>> &jacobian_3rd_derivatives)
1093 const unsigned int n_q_points = jacobian_3rd_derivatives.size();
1095 for (
unsigned int point = 0; point < n_q_points; ++point)
1098 &
data.fourth_derivative(point + data_set, 0);
1102 for (
unsigned int k = 0; k <
data.n_shape_functions; ++k)
1104 const unsigned int comp_k =
1105 fe.system_to_component_index(k).first;
1106 if (fe_mask[comp_k])
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 result[fe_to_real[comp_k]][j][l][m][n] +=
1112 (fourth[k][j][l][m][n] *
1113 data.local_dof_values[k]);
1119 for (
unsigned int i = 0; i < spacedim; ++i)
1120 for (
unsigned int j = 0; j < dim; ++j)
1121 for (
unsigned int l = 0; l < dim; ++l)
1122 for (
unsigned int m = 0; m < dim; ++m)
1123 for (
unsigned int n = 0; n < dim; ++n)
1124 jacobian_3rd_derivatives[point][i][j][l][m][n] =
1125 result[i][j][l][m][n];
1137 template <
int dim,
int spacedim,
typename VectorType>
1139 maybe_update_jacobian_pushed_forward_3rd_derivatives(
1140 const typename ::QProjector<dim>::DataSetDescriptor data_set,
1141 const typename ::MappingFEField<dim, spacedim, VectorType>::
1145 const std::vector<unsigned int> &fe_to_real,
1146 std::vector<Tensor<5, spacedim>>
1147 &jacobian_pushed_forward_3rd_derivatives)
1152 const unsigned int n_q_points =
1153 jacobian_pushed_forward_3rd_derivatives.size();
1155 double tmp[spacedim][spacedim][spacedim][spacedim][spacedim];
1156 for (
unsigned int point = 0; point < n_q_points; ++point)
1159 &
data.fourth_derivative(point + data_set, 0);
1163 for (
unsigned int k = 0; k <
data.n_shape_functions; ++k)
1165 const unsigned int comp_k =
1166 fe.system_to_component_index(k).first;
1167 if (fe_mask[comp_k])
1168 for (
unsigned int j = 0; j < dim; ++j)
1169 for (
unsigned int l = 0; l < dim; ++l)
1170 for (
unsigned int m = 0; m < dim; ++m)
1171 for (
unsigned int n = 0; n < dim; ++n)
1172 result[fe_to_real[comp_k]][j][l][m][n] +=
1173 (fourth[k][j][l][m][n] *
1174 data.local_dof_values[k]);
1178 for (
unsigned int i = 0; i < spacedim; ++i)
1179 for (
unsigned int j = 0; j < spacedim; ++j)
1180 for (
unsigned int l = 0; l < dim; ++l)
1181 for (
unsigned int m = 0; m < dim; ++m)
1182 for (
unsigned int n = 0; n < dim; ++n)
1184 tmp[i][j][l][m][n] = result[i][0][l][m][n] *
1185 data.covariant[point][j][0];
1186 for (
unsigned int jr = 1; jr < dim; ++jr)
1187 tmp[i][j][l][m][n] +=
1188 result[i][jr][l][m][n] *
1189 data.covariant[point][j][jr];
1193 for (
unsigned int i = 0; i < spacedim; ++i)
1194 for (
unsigned int j = 0; j < spacedim; ++j)
1195 for (
unsigned int l = 0; l < spacedim; ++l)
1196 for (
unsigned int m = 0; m < dim; ++m)
1197 for (
unsigned int n = 0; n < dim; ++n)
1199 jacobian_pushed_forward_3rd_derivatives
1200 [point][i][j][l][m][n] =
1201 tmp[i][j][0][m][n] *
1202 data.covariant[point][l][0];
1203 for (
unsigned int lr = 1; lr < dim; ++lr)
1204 jacobian_pushed_forward_3rd_derivatives[point][i]
1207 tmp[i][j][lr][m][n] *
1208 data.covariant[point][l][lr];
1212 for (
unsigned int i = 0; i < spacedim; ++i)
1213 for (
unsigned int j = 0; j < spacedim; ++j)
1214 for (
unsigned int l = 0; l < spacedim; ++l)
1215 for (
unsigned int m = 0; m < spacedim; ++m)
1216 for (
unsigned int n = 0; n < dim; ++n)
1218 tmp[i][j][l][m][n] =
1219 jacobian_pushed_forward_3rd_derivatives[point][i]
1222 data.covariant[point][m][0];
1223 for (
unsigned int mr = 1; mr < dim; ++mr)
1224 tmp[i][j][l][m][n] +=
1225 jacobian_pushed_forward_3rd_derivatives[point]
1228 data.covariant[point][m][mr];
1232 for (
unsigned int i = 0; i < spacedim; ++i)
1233 for (
unsigned int j = 0; j < spacedim; ++j)
1234 for (
unsigned int l = 0; l < spacedim; ++l)
1235 for (
unsigned int m = 0; m < spacedim; ++m)
1236 for (
unsigned int n = 0; n < spacedim; ++n)
1238 jacobian_pushed_forward_3rd_derivatives
1239 [point][i][j][l][m][n] =
1240 tmp[i][j][l][m][0] *
1241 data.covariant[point][n][0];
1242 for (
unsigned int nr = 1; nr < dim; ++nr)
1243 jacobian_pushed_forward_3rd_derivatives[point][i]
1246 tmp[i][j][l][m][nr] *
1247 data.covariant[point][n][nr];
1263 template <
int dim,
int spacedim,
typename VectorType>
1265 maybe_compute_face_data(
1266 const ::Mapping<dim, spacedim> &mapping,
1267 const typename ::Triangulation<dim, spacedim>::cell_iterator
1269 const unsigned int face_no,
1270 const unsigned int subface_no,
1272 const typename ::MappingFEField<dim, spacedim, VectorType>::
1281 const unsigned int n_q_points = output_data.boundary_forms.size();
1290 for (
unsigned int d = 0; d != dim - 1; ++d)
1292 Assert(face_no + cell->n_faces() * d <
1293 data.unit_tangentials.size(),
1296 data.aux[d].size() <=
1297 data.unit_tangentials[face_no + cell->n_faces() * d].size(),
1302 data.unit_tangentials[face_no + cell->n_faces() * d]),
1310 if (dim == spacedim)
1312 for (
unsigned int i = 0; i < n_q_points; ++i)
1320 output_data.boundary_forms[i][0] =
1321 (face_no == 0 ? -1 : +1);
1324 output_data.boundary_forms[i] =
1325 cross_product_2d(
data.aux[0][i]);
1328 output_data.boundary_forms[i] =
1329 cross_product_3d(
data.aux[0][i],
data.aux[1][i]);
1345 for (
unsigned int point = 0; point < n_q_points; ++point)
1350 output_data.boundary_forms[point] =
1351 data.contravariant[point].transpose()[0];
1352 output_data.boundary_forms[point] /=
1353 (face_no == 0 ? -1. : +1.) *
1354 output_data.boundary_forms[point].norm();
1363 cross_product_3d(DX_t[0], DX_t[1]);
1364 cell_normal /= cell_normal.
norm();
1368 output_data.boundary_forms[point] =
1369 cross_product_3d(
data.aux[0][point], cell_normal);
1375 for (
unsigned int i = 0; i < output_data.boundary_forms.size();
1380 output_data.JxW_values[i] =
1381 output_data.boundary_forms[i].norm() *
1382 data.quadrature_weights[i + data_set];
1387 const double area_ratio =
1389 cell->subface_case(face_no), subface_no);
1390 output_data.JxW_values[i] *= area_ratio;
1395 output_data.normal_vectors[i] =
1397 output_data.boundary_forms[i].norm());
1408 template <
int dim,
int spacedim,
typename VectorType>
1410 do_fill_fe_face_values(
1411 const ::Mapping<dim, spacedim> &mapping,
1412 const typename ::Triangulation<dim, spacedim>::cell_iterator
1414 const unsigned int face_no,
1415 const unsigned int subface_no,
1416 const typename ::QProjector<dim>::DataSetDescriptor data_set,
1417 const typename ::MappingFEField<dim, spacedim, VectorType>::
1421 const std::vector<unsigned int> &fe_to_real,
1425 maybe_compute_q_points<dim, spacedim, VectorType>(
1431 output_data.quadrature_points);
1433 maybe_update_Jacobians<dim, spacedim, VectorType>(
1434 data_set,
data, fe, fe_mask, fe_to_real);
1437 const unsigned int n_q_points =
data.contravariant.size();
1440 for (
unsigned int point = 0; point < n_q_points; ++point)
1441 output_data.jacobians[point] =
data.contravariant[point];
1444 for (
unsigned int point = 0; point < n_q_points; ++point)
1445 output_data.inverse_jacobians[point] =
1446 data.covariant[point].transpose();
1448 maybe_update_jacobian_grads<dim, spacedim, VectorType>(
1449 data_set,
data, fe, fe_mask, fe_to_real, output_data.jacobian_grads);
1451 maybe_update_jacobian_pushed_forward_grads<dim, spacedim, VectorType>(
1457 output_data.jacobian_pushed_forward_grads);
1459 maybe_update_jacobian_2nd_derivatives<dim, spacedim, VectorType>(
1465 output_data.jacobian_2nd_derivatives);
1467 maybe_update_jacobian_pushed_forward_2nd_derivatives<dim,
1475 output_data.jacobian_pushed_forward_2nd_derivatives);
1477 maybe_update_jacobian_3rd_derivatives<dim, spacedim, VectorType>(
1483 output_data.jacobian_3rd_derivatives);
1485 maybe_update_jacobian_pushed_forward_3rd_derivatives<dim,
1493 output_data.jacobian_pushed_forward_3rd_derivatives);
1495 maybe_compute_face_data<dim, spacedim, VectorType>(
1496 mapping, cell, face_no, subface_no, data_set,
data, output_data);