]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Reuse MappingInfo 15358/head
authorMaximilian Bergbauer <maximilian.bergbauer@tum.de>
Wed, 7 Jun 2023 09:25:27 +0000 (11:25 +0200)
committerMaximilian Bergbauer <maximilian.bergbauer@tum.de>
Wed, 14 Jun 2023 11:57:52 +0000 (13:57 +0200)
include/deal.II/non_matching/mapping_info.h
tests/non_matching/mapping_info_03.cc

index 85c7c512bdcc4322cd013367cec2b8ec86b0a420..aed1d2a12d7c1db2285125aa8ede0e03c8988a1c 100644 (file)
@@ -434,6 +434,12 @@ namespace NonMatching
     unsigned int
     compute_n_q_points(const unsigned int n_q_points_unvectorized);
 
+    /**
+     * Clears fields to make the object reusable.
+     */
+    void
+    clear();
+
     /**
      * Resize the unit_point data field.
      */
@@ -673,6 +679,17 @@ namespace NonMatching
 
 
 
+  template <int dim, int spacedim, typename Number>
+  void
+  MappingInfo<dim, spacedim, Number>::clear()
+  {
+    n_q_points_unvectorized.clear();
+    unit_points_index.clear();
+    data_index_offsets.clear();
+  }
+
+
+
   template <int dim, int spacedim, typename Number>
   void
   MappingInfo<dim, spacedim, Number>::reinit(
@@ -778,6 +795,8 @@ namespace NonMatching
     const std::vector<Quadrature<dim>> &quadrature_vector,
     const unsigned int                  n_unfiltered_cells)
   {
+    clear();
+
     do_cell_index_compression =
       n_unfiltered_cells != numbers::invalid_unsigned_int;
 
@@ -873,6 +892,8 @@ namespace NonMatching
     const std::vector<ImmersedSurfaceQuadrature<dim>> &quadrature_vector,
     const unsigned int                                 n_unfiltered_cells)
   {
+    clear();
+
     Assert(
       additional_data.use_global_weights == false,
       ExcMessage(
@@ -976,6 +997,8 @@ namespace NonMatching
     const std::vector<std::vector<Quadrature<dim - 1>>> &quadrature_vector,
     const unsigned int                                   n_unfiltered_cells)
   {
+    clear();
+
     do_cell_index_compression =
       n_unfiltered_cells != numbers::invalid_unsigned_int;
 
index cda12083aa99420fa7d87e11de3a52e1dcc908f9..795bad9a17b32266d221772cfb479ca6a778bbdd 100644 (file)
@@ -43,15 +43,14 @@ test()
   FE_Q<dim>     fe(degree);
   MappingQ<dim> mapping(degree);
 
+  NonMatching::MappingInfo<dim>::AdditionalData additional_data;
+  additional_data.use_global_weights = true;
+  NonMatching::MappingInfo<dim> mapping_info(mapping,
+                                             update_JxW_values,
+                                             additional_data);
 
   deallog << "Check JxW faces..." << std::endl;
   {
-    NonMatching::MappingInfo<dim>::AdditionalData additional_data;
-    additional_data.use_global_weights = true;
-    NonMatching::MappingInfo<dim> mapping_info(mapping,
-                                               update_JxW_values,
-                                               additional_data);
-
     // 1) build vector of quadratures
     std::vector<std::vector<Quadrature<dim - 1>>> quad_vec;
     // prescribe JxW (there is no meaning in the actual values, they just have
@@ -96,13 +95,6 @@ test()
 
   deallog << "\n\nCheck JxW cells..." << std::endl;
   {
-    NonMatching::MappingInfo<dim>::AdditionalData additional_data;
-    additional_data.use_global_weights = true;
-    NonMatching::MappingInfo<dim> mapping_info(mapping,
-                                               update_JxW_values,
-                                               additional_data);
-
-
     // 1) build vector of quadratures
     std::vector<Quadrature<dim>> quad_vec;
     // prescribe JxW (there is no meaning in the actual values, they just have

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.