From 2a1ac5bff88cd06ac4444a6281ecc99a201eb39b Mon Sep 17 00:00:00 2001 From: Simon Sticko Date: Tue, 16 Nov 2021 14:21:36 +0100 Subject: [PATCH] Add MappingCartesian::maybe_update_inverse_jacobians() To remove some duplication in the class. --- include/deal.II/fe/mapping_cartesian.h | 12 +++++ source/fe/mapping_cartesian.cc | 61 ++++++++++++-------------- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/include/deal.II/fe/mapping_cartesian.h b/include/deal.II/fe/mapping_cartesian.h index 525f0906d8..d62039f413 100644 --- a/include/deal.II/fe/mapping_cartesian.h +++ b/include/deal.II/fe/mapping_cartesian.h @@ -374,6 +374,18 @@ private: 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. + */ + void + maybe_update_inverse_jacobians( + const InternalData & data, + const CellSimilarity::Similarity cell_similarity, + internal::FEValuesImplementation::MappingRelatedData + &output_data) const; }; /*@}*/ diff --git a/source/fe/mapping_cartesian.cc b/source/fe/mapping_cartesian.cc index ab69201cc6..f5b44264e5 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_inverse_jacobians( + const InternalData & data, + const CellSimilarity::Similarity cell_similarity, + internal::FEValuesImplementation::MappingRelatedData + &output_data) const +{ + // "compute" inverse Jacobian at the quadrature points, which are + // all the same + if (data.update_each & update_inverse_jacobians) + if (cell_similarity != CellSimilarity::translation) + for (unsigned int i = 0; i < output_data.inverse_jacobians.size(); ++i) + { + output_data.inverse_jacobians[i] = Tensor<2, dim>(); + for (unsigned int j = 0; j < dim; ++j) + output_data.inverse_jacobians[i][j][j] = 1. / data.cell_extents[j]; + } +} + + + template CellSimilarity::Similarity MappingCartesian::fill_fe_values( @@ -433,17 +455,7 @@ MappingCartesian::fill_fe_values( } maybe_update_jacobian_derivatives(data, cell_similarity, output_data); - - // "compute" inverse Jacobian at the quadrature points, which are - // all the same - if (data.update_each & update_inverse_jacobians) - if (cell_similarity != CellSimilarity::translation) - for (unsigned int i = 0; i < output_data.inverse_jacobians.size(); ++i) - { - output_data.inverse_jacobians[i] = Tensor<2, dim>(); - for (unsigned int j = 0; j < dim; ++j) - output_data.inverse_jacobians[i][j][j] = 1. / data.cell_extents[j]; - } + maybe_update_inverse_jacobians(data, cell_similarity, output_data); return cell_similarity; } @@ -489,14 +501,9 @@ MappingCartesian::fill_mapping_data_for_generic_points( for (unsigned int j = 0; j < dim; ++j) output_data.jacobians[i][j][j] = data.cell_extents[j]; } - - if (update_flags & update_inverse_jacobians) - { - output_data.inverse_jacobians[i] = DerivativeForm<1, dim, spacedim>(); - for (unsigned int j = 0; j < dim; ++j) - output_data.inverse_jacobians[i][j][j] = 1. / data.cell_extents[j]; - } } + + maybe_update_inverse_jacobians(data, CellSimilarity::none, output_data); } @@ -562,14 +569,7 @@ MappingCartesian::fill_fe_face_values( } maybe_update_jacobian_derivatives(data, CellSimilarity::none, output_data); - - if (data.update_each & update_inverse_jacobians) - for (unsigned int i = 0; i < output_data.inverse_jacobians.size(); ++i) - { - output_data.inverse_jacobians[i] = DerivativeForm<1, dim, spacedim>(); - for (unsigned int d = 0; d < dim; ++d) - output_data.inverse_jacobians[i][d][d] = 1. / data.cell_extents[d]; - } + maybe_update_inverse_jacobians(data, CellSimilarity::none, output_data); } @@ -640,14 +640,7 @@ MappingCartesian::fill_fe_subface_values( } maybe_update_jacobian_derivatives(data, CellSimilarity::none, output_data); - - if (data.update_each & update_inverse_jacobians) - for (unsigned int i = 0; i < output_data.inverse_jacobians.size(); ++i) - { - output_data.inverse_jacobians[i] = DerivativeForm<1, spacedim, dim>(); - for (unsigned int d = 0; d < dim; ++d) - output_data.inverse_jacobians[i][d][d] = 1. / data.cell_extents[d]; - } + maybe_update_inverse_jacobians(data, CellSimilarity::none, output_data); } -- 2.39.5