From ee237d2a4e43d4f367bdacb09c69f2737fc740b4 Mon Sep 17 00:00:00 2001 From: Simon Sticko Date: Tue, 16 Nov 2021 14:56:32 +0100 Subject: [PATCH] Add MappingCartesian::maybe_update_volume_elements() To remove some duplication in the class. --- include/deal.II/fe/mapping_cartesian.h | 7 ++++++ source/fe/mapping_cartesian.cc | 34 ++++++++++++++------------ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/include/deal.II/fe/mapping_cartesian.h b/include/deal.II/fe/mapping_cartesian.h index 71e0aa385b..127d570f25 100644 --- a/include/deal.II/fe/mapping_cartesian.h +++ b/include/deal.II/fe/mapping_cartesian.h @@ -376,6 +376,13 @@ private: &output_data) const; + /** + * Compute the volume elements if the UpdateFlags of the incoming + * InternalData object say that they should be updated. + */ + void + maybe_update_volume_elements(const InternalData &data) const; + /** * Compute the 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 8963c8465b..2d29cbc65b 100644 --- a/source/fe/mapping_cartesian.cc +++ b/source/fe/mapping_cartesian.cc @@ -385,6 +385,22 @@ MappingCartesian::maybe_update_jacobian_derivatives( +template +void +MappingCartesian::maybe_update_volume_elements( + const InternalData &data) const +{ + if (data.update_each & update_volume_elements) + { + double volume = data.cell_extents[0]; + for (unsigned int d = 1; d < dim; ++d) + volume *= data.cell_extents[d]; + data.volume_element = volume; + } +} + + + template void MappingCartesian::maybe_update_jacobians( @@ -556,14 +572,7 @@ MappingCartesian::fill_fe_face_values( for (unsigned int i = 0; i < output_data.boundary_forms.size(); ++i) output_data.boundary_forms[i] = J * output_data.normal_vectors[i]; - if (data.update_each & update_volume_elements) - { - J = data.cell_extents[0]; - for (unsigned int d = 1; d < dim; ++d) - J *= data.cell_extents[d]; - data.volume_element = J; - } - + maybe_update_volume_elements(data); 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); @@ -620,14 +629,7 @@ MappingCartesian::fill_fe_subface_values( for (unsigned int i = 0; i < output_data.boundary_forms.size(); ++i) output_data.boundary_forms[i] = J * output_data.normal_vectors[i]; - if (data.update_each & update_volume_elements) - { - J = data.cell_extents[0]; - for (unsigned int d = 1; d < dim; ++d) - J *= data.cell_extents[d]; - data.volume_element = J; - } - + maybe_update_volume_elements(data); 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); -- 2.39.5