Skip to content

Commit

Permalink
Avoid unnecessary updates of cell dof index cache in DoFHandlerPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
kronbichler committed Jul 16, 2021
1 parent a8d2d28 commit 9ccd93a
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions source/dofs/dof_handler_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -1679,8 +1677,6 @@ namespace internal

tasks.join_all();
}

update_all_active_cell_dof_indices_caches(dof_handler);
}


Expand Down Expand Up @@ -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,
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
};
Expand All @@ -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)
Expand Down Expand Up @@ -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.
//
Expand Down Expand 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 =
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9ccd93a

Please sign in to comment.