From 9ccd93a2319b5b48553d7a5d2e73834162c5b36a Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Fri, 16 Jul 2021 14:12:20 +0200 Subject: [PATCH] Avoid unnecessary updates of cell dof index cache in DoFHandlerPolicy --- source/dofs/dof_handler_policy.cc | 48 ++++++++++++++++--------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index f4315a2477..538c6c0519 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -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 &new_numbers, const IndexSet & indices_we_care_about, const DoFHandler &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 &>(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 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 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, DoFHandler>(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; -- 2.39.5