From: Simon Sticko Date: Tue, 16 Nov 2021 13:56:32 +0000 (+0100) Subject: Add MappingCartesian::maybe_update_volume_elements() X-Git-Tag: v9.4.0-rc1~833^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee237d2a4e43d4f367bdacb09c69f2737fc740b4;p=dealii.git Add MappingCartesian::maybe_update_volume_elements() 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 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);