]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use faster process_dof_indices in one more place 12576/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sat, 17 Jul 2021 10:16:28 +0000 (12:16 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Sat, 17 Jul 2021 10:23:26 +0000 (12:23 +0200)
source/dofs/dof_handler_policy.cc

index b3be8df8334aca4e842d519fa69dc422f7d3abbe..6c511e1f661e0a240aa12cd10b3441d0894ce249 100644 (file)
@@ -3675,22 +3675,28 @@ namespace internal
 
             Assert(cell->is_ghost(), ExcInternalError());
 
-            std::vector<dealii::types::global_dof_index> dof_indices(
-              cell->get_fe().n_dofs_per_cell());
-            internal::DoFAccessorImplementation::Implementation::
-              get_dof_indices(*cell, dof_indices, cell->active_fe_index());
-
+            // Use a combined read/set function on the entities of the dof
+            // indices to speed things up against get_dof_indices +
+            // set_dof_indices
             bool complete = true;
-            for (unsigned int i = 0; i < dof_indices.size(); ++i)
-              if (dofs[i] != numbers::invalid_dof_index)
-                {
-                  Assert((dof_indices[i] == (numbers::invalid_dof_index)) ||
-                           (dof_indices[i] == dofs[i]),
-                         ExcInternalError());
-                  dof_indices[i] = dofs[i];
-                }
-              else
-                complete = false;
+            DoFAccessorImplementation::Implementation::process_dof_indices(
+              *cell,
+              dofs,
+              cell->active_fe_index(),
+              DoFAccessorImplementation::Implementation::
+                DoFIndexProcessor<dim, spacedim, false>(),
+              [&complete](auto &stored_index, auto &received_index) {
+                if (received_index != numbers::invalid_unsigned_int)
+                  {
+                    Assert((stored_index == (numbers::invalid_dof_index)) ||
+                             (stored_index == received_index),
+                           ExcInternalError());
+                    stored_index = received_index;
+                  }
+                else
+                  complete = false;
+              },
+              false);
 
             if (!complete)
               const_cast<
@@ -3702,10 +3708,6 @@ namespace internal
                 typename DoFHandler<dim, spacedim>::active_cell_iterator &>(
                 cell)
                 ->clear_user_flag();
-
-            const_cast<
-              typename DoFHandler<dim, spacedim>::active_cell_iterator &>(cell)
-              ->set_dof_indices(dof_indices);
           };
 
           const auto filter = [](const auto &cell) {

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.