]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add MappingCartesian::maybe_update_inverse_jacobians()
authorSimon Sticko <simon@sticko.se>
Tue, 16 Nov 2021 13:21:36 +0000 (14:21 +0100)
committerSimon Sticko <simon@sticko.se>
Tue, 16 Nov 2021 13:57:04 +0000 (14:57 +0100)
To remove some duplication in the class.

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

index 525f0906d84d37b46984a0a21eb46227228f5710..d62039f4137f9b8b1b55aef035f297edd1d4b066 100644 (file)
@@ -374,6 +374,18 @@ private:
     const CellSimilarity::Similarity cell_similarity,
     internal::FEValuesImplementation::MappingRelatedData<dim, spacedim>
       &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<dim, spacedim>
+      &output_data) const;
 };
 
 /*@}*/
index ab69201cc6b94bfd951868b602d2caf2a672eca8..f5b44264e5ad3f00b50f343619c2ddcccfc65d88 100644 (file)
@@ -385,6 +385,28 @@ MappingCartesian<dim, spacedim>::maybe_update_jacobian_derivatives(
 
 
 
+template <int dim, int spacedim>
+void
+MappingCartesian<dim, spacedim>::maybe_update_inverse_jacobians(
+  const InternalData &             data,
+  const CellSimilarity::Similarity cell_similarity,
+  internal::FEValuesImplementation::MappingRelatedData<dim, spacedim>
+    &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 <int dim, int spacedim>
 CellSimilarity::Similarity
 MappingCartesian<dim, spacedim>::fill_fe_values(
@@ -433,17 +455,7 @@ MappingCartesian<dim, spacedim>::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<dim, spacedim>::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<dim, spacedim>::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<dim, spacedim>::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);
 }
 
 

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.