From: Simon Sticko Date: Tue, 16 Nov 2021 13:32:22 +0000 (+0100) Subject: Add MappingCartesian::maybe_update_jacobians() X-Git-Tag: v9.4.0-rc1~833^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53e6b4f8b91b57499308d0369d267115b4cf1002;p=dealii.git Add MappingCartesian::maybe_update_jacobians() To remove some duplication in the class. --- diff --git a/include/deal.II/fe/mapping_cartesian.h b/include/deal.II/fe/mapping_cartesian.h index d62039f413..71e0aa385b 100644 --- a/include/deal.II/fe/mapping_cartesian.h +++ b/include/deal.II/fe/mapping_cartesian.h @@ -376,6 +376,17 @@ private: &output_data) const; + /** + * Compute the Jacobians if the UpdateFlags of the incoming + * InternalData object say that they should be updated. + */ + void + maybe_update_jacobians( + const InternalData & data, + const CellSimilarity::Similarity cell_similarity, + internal::FEValuesImplementation::MappingRelatedData + &output_data) const; + /** * Compute the inverse Jacobians if the UpdateFlags of the incoming * InternalData object say that they should be updated. diff --git a/source/fe/mapping_cartesian.cc b/source/fe/mapping_cartesian.cc index f5b44264e5..8963c8465b 100644 --- a/source/fe/mapping_cartesian.cc +++ b/source/fe/mapping_cartesian.cc @@ -385,6 +385,28 @@ MappingCartesian::maybe_update_jacobian_derivatives( +template +void +MappingCartesian::maybe_update_jacobians( + const InternalData & data, + const CellSimilarity::Similarity cell_similarity, + internal::FEValuesImplementation::MappingRelatedData + &output_data) const +{ + // "compute" Jacobian at the quadrature points, which are all the + // same + if (data.update_each & update_jacobians) + if (cell_similarity != CellSimilarity::translation) + for (unsigned int i = 0; i < output_data.jacobians.size(); ++i) + { + output_data.jacobians[i] = DerivativeForm<1, dim, spacedim>(); + for (unsigned int j = 0; j < dim; ++j) + output_data.jacobians[i][j][j] = data.cell_extents[j]; + } +} + + + template void MappingCartesian::maybe_update_inverse_jacobians( @@ -443,17 +465,9 @@ MappingCartesian::fill_fe_values( for (unsigned int i = 0; i < output_data.JxW_values.size(); ++i) output_data.JxW_values[i] = J * quadrature.weight(i); } - // "compute" Jacobian at the quadrature points, which are all the - // same - if (data.update_each & update_jacobians) - if (cell_similarity != CellSimilarity::translation) - for (unsigned int i = 0; i < output_data.jacobians.size(); ++i) - { - output_data.jacobians[i] = DerivativeForm<1, dim, spacedim>(); - for (unsigned int j = 0; j < dim; ++j) - output_data.jacobians[i][j][j] = data.cell_extents[j]; - } + + maybe_update_jacobians(data, cell_similarity, output_data); maybe_update_jacobian_derivatives(data, cell_similarity, output_data); maybe_update_inverse_jacobians(data, cell_similarity, output_data); @@ -480,7 +494,6 @@ MappingCartesian::fill_mapping_data_for_generic_points( ExcNotImplemented()); output_data.initialize(unit_points.size(), update_flags); - const unsigned int n_points = unit_points.size(); InternalData data; data.update_each = update_flags; @@ -493,16 +506,7 @@ MappingCartesian::fill_mapping_data_for_generic_points( data, output_data.quadrature_points); - for (unsigned int i = 0; i < n_points; ++i) - { - if (update_flags & update_jacobians) - { - output_data.jacobians[i] = DerivativeForm<1, dim, spacedim>(); - for (unsigned int j = 0; j < dim; ++j) - output_data.jacobians[i][j][j] = data.cell_extents[j]; - } - } - + maybe_update_jacobians(data, CellSimilarity::none, output_data); maybe_update_inverse_jacobians(data, CellSimilarity::none, output_data); } @@ -560,14 +564,7 @@ MappingCartesian::fill_fe_face_values( data.volume_element = J; } - if (data.update_each & update_jacobians) - for (unsigned int i = 0; i < output_data.jacobians.size(); ++i) - { - output_data.jacobians[i] = DerivativeForm<1, dim, spacedim>(); - for (unsigned int d = 0; d < dim; ++d) - output_data.jacobians[i][d][d] = data.cell_extents[d]; - } - + maybe_update_jacobians(data, CellSimilarity::none, output_data); maybe_update_jacobian_derivatives(data, CellSimilarity::none, output_data); maybe_update_inverse_jacobians(data, CellSimilarity::none, output_data); } @@ -631,14 +628,7 @@ MappingCartesian::fill_fe_subface_values( data.volume_element = J; } - if (data.update_each & update_jacobians) - for (unsigned int i = 0; i < output_data.jacobians.size(); ++i) - { - output_data.jacobians[i] = DerivativeForm<1, dim, spacedim>(); - for (unsigned int d = 0; d < dim; ++d) - output_data.jacobians[i][d][d] = data.cell_extents[d]; - } - + maybe_update_jacobians(data, CellSimilarity::none, output_data); maybe_update_jacobian_derivatives(data, CellSimilarity::none, output_data); maybe_update_inverse_jacobians(data, CellSimilarity::none, output_data); }