]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid unnecessary updates of cell dof index cache in DoFHandlerPolicy
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 16 Jul 2021 12:12:20 +0000 (14:12 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 16 Jul 2021 12:17:19 +0000 (14:17 +0200)
source/dofs/dof_handler_policy.cc

index f4315a247791247f657c95927f30499395a3756f..538c6c051995cf5a507ecb0ff05a3a878a1a5738 100644 (file)
@@ -1046,8 +1046,6 @@ namespace internal
 
           renumber_dofs(renumbering, IndexSet(0), dof_handler, check_validity);
 
-          update_all_active_cell_dof_indices_caches(dof_handler);
-
           return n_dofs;
         }
 
@@ -1679,8 +1677,6 @@ namespace internal
 
             tasks.join_all();
           }
-
-          update_all_active_cell_dof_indices_caches(dof_handler);
         }
 
 
@@ -1712,7 +1708,6 @@ namespace internal
                 {
                   dof_indices.resize(cell->get_fe().n_dofs_per_cell());
 
-                  // circumvent cache
                   internal::DoFAccessorImplementation::Implementation::
                     get_dof_indices(*cell,
                                     dof_indices,
@@ -1725,8 +1720,6 @@ namespace internal
                   cell->set_dof_indices(dof_indices);
                 }
 
-          update_all_active_cell_dof_indices_caches(dof_handler);
-
           return next_free_dof;
         }
 
@@ -1764,7 +1757,10 @@ namespace internal
                 // previously assigned a number to (i.e. the ones on
                 // the interface)
                 local_dof_indices.resize(cell->get_fe().n_dofs_per_cell());
-                cell->get_dof_indices(local_dof_indices);
+                internal::DoFAccessorImplementation::Implementation::
+                  get_dof_indices(*cell,
+                                  local_dof_indices,
+                                  cell->active_fe_index());
                 for (const auto &local_dof_index : local_dof_indices)
                   if (local_dof_index != numbers::invalid_dof_index)
                     renumbering[local_dof_index] = numbers::invalid_dof_index;
@@ -2397,7 +2393,8 @@ namespace internal
         renumber_dofs(const std::vector<types::global_dof_index> &new_numbers,
                       const IndexSet &                  indices_we_care_about,
                       const DoFHandler<dim, space_dim> &dof_handler,
-                      const bool                        check_validity)
+                      const bool                        check_validity,
+                      const bool                        update_cache = true)
         {
           if (dim == 1)
             Assert(indices_we_care_about == IndexSet(0), ExcNotImplemented());
@@ -2427,9 +2424,8 @@ namespace internal
           });
           tasks.join_all();
 
-          // update the cache used for cell dof indices
-          update_all_active_cell_dof_indices_caches(
-            const_cast<DoFHandler<dim, space_dim> &>(dof_handler));
+          if (update_cache)
+            update_all_active_cell_dof_indices_caches(dof_handler);
         }
 
 
@@ -2787,6 +2783,8 @@ namespace internal
                                             n_initial_dofs,
                                             /*check_validity=*/true);
 
+        update_all_active_cell_dof_indices_caches(*dof_handler);
+
         // return a sequential, complete index set
         return NumberCache(n_dofs);
       }
@@ -2912,7 +2910,10 @@ namespace internal
               const unsigned int        dofs_per_cell =
                 cell->get_fe().n_dofs_per_cell();
               local_dof_indices.resize(dofs_per_cell);
-              cell->get_dof_indices(local_dof_indices);
+              internal::DoFAccessorImplementation::Implementation::
+                get_dof_indices(*cell,
+                                local_dof_indices,
+                                cell->active_fe_index());
 
               // set subdomain ids. if dofs already have their values set then
               // they must be on partition interfaces. In that case assign them
@@ -3631,7 +3632,8 @@ namespace internal
 
             std::vector<dealii::types::global_dof_index> data(
               cell->get_fe().n_dofs_per_cell());
-            cell->get_dof_indices(data);
+            internal::DoFAccessorImplementation::Implementation::
+              get_dof_indices(*cell, data, cell->active_fe_index());
 
             return data;
           };
@@ -3644,8 +3646,8 @@ namespace internal
 
             std::vector<dealii::types::global_dof_index> dof_indices(
               cell->get_fe().n_dofs_per_cell());
-            cell->update_cell_dof_indices_cache();
-            cell->get_dof_indices(dof_indices);
+            internal::DoFAccessorImplementation::Implementation::
+              get_dof_indices(*cell, dof_indices, cell->active_fe_index());
 
             bool complete = true;
             for (unsigned int i = 0; i < dof_indices.size(); ++i)
@@ -3683,11 +3685,6 @@ namespace internal
             std::vector<types::global_dof_index>,
             DoFHandler<dim, spacedim>>(dof_handler, pack, unpack, filter);
 
-          // finally update the cell DoF indices caches to make sure
-          // our internal data structures are consistent
-          update_all_active_cell_dof_indices_caches(dof_handler);
-
-
           // have a barrier so that sends between two calls to this
           // function are not mixed up.
           //
@@ -3842,7 +3839,8 @@ namespace internal
         Implementation::renumber_dofs(renumbering,
                                       IndexSet(0),
                                       *dof_handler,
-                                      /*check_validity=*/false);
+                                      /*check_validity=*/false,
+                                      /*update_cache=*/false);
 
         // now a little bit of housekeeping
         const dealii::types::global_dof_index n_global_dofs =
@@ -3908,6 +3906,8 @@ namespace internal
           triangulation->load_user_flags(user_flags);
         }
 
+        update_all_active_cell_dof_indices_caches(*this->dof_handler);
+
 #  ifdef DEBUG
         // check that we are really done
         {
@@ -4372,7 +4372,8 @@ namespace internal
               Implementation::renumber_dofs(new_numbers,
                                             dof_handler->locally_owned_dofs(),
                                             *dof_handler,
-                                            /*check_validity=*/false);
+                                            /*check_validity=*/false,
+                                            /*update_cache=*/false);
 
             // Communicate newly assigned DoF indices to other processors
             // and get the same information for our own ghost cells.
@@ -4410,6 +4411,7 @@ namespace internal
               communicate_dof_indices_on_marked_cells(*dof_handler);
 
               triangulation->load_user_flags(user_flags);
+              update_all_active_cell_dof_indices_caches(*this->dof_handler);
             }
 
             NumberCache number_cache;

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.