]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add MappingCartesian::maybe_update_volume_elements() 12956/head
authorSimon Sticko <simon@sticko.se>
Tue, 16 Nov 2021 13:56:32 +0000 (14:56 +0100)
committerSimon Sticko <simon@sticko.se>
Tue, 16 Nov 2021 15:14:40 +0000 (16:14 +0100)
To remove some duplication in the class.

include/deal.II/fe/mapping_cartesian.h
source/fe/mapping_cartesian.cc

index 71e0aa385b140981abf4bf2909c14a1aae1fc1d6..127d570f2525882554641e9373fd55ebcc46cea6 100644 (file)
@@ -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.
index 8963c8465b906ddb2f68f64899bcc7f87791a006..2d29cbc65bd7e635b62381687a41df6038239627 100644 (file)
@@ -385,6 +385,22 @@ MappingCartesian<dim, spacedim>::maybe_update_jacobian_derivatives(
 
 
 
+template <int dim, int spacedim>
+void
+MappingCartesian<dim, spacedim>::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 <int dim, int spacedim>
 void
 MappingCartesian<dim, spacedim>::maybe_update_jacobians(
@@ -556,14 +572,7 @@ MappingCartesian<dim, spacedim>::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<dim, spacedim>::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);

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.