From 9373eb51c6dbaf8a5a540e1687e4d892f1c89aa0 Mon Sep 17 00:00:00 2001 From: Marco Feder Date: Tue, 23 Jul 2024 15:26:48 +0000 Subject: [PATCH] Avoid one more loop --- include/agglomeration_handler.h | 3 +-- source/agglomeration_handler.cc | 33 +++++++++++++-------------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/include/agglomeration_handler.h b/include/agglomeration_handler.h index 30204d23..d07e99a6 100644 --- a/include/agglomeration_handler.h +++ b/include/agglomeration_handler.h @@ -305,8 +305,7 @@ class AgglomerationHandler : public Subscriptor create_agglomeration_sparsity_pattern( SparsityPatternType &sparsity_pattern, const AffineConstraints &constraints = AffineConstraints(), - const bool keep_constrained_dofs = true, - const types::subdomain_id subdomain_id = numbers::invalid_subdomain_id); + const bool keep_constrained_dofs = true); /** * Store internally that the given cells are agglomerated. The convenction we diff --git a/source/agglomeration_handler.cc b/source/agglomeration_handler.cc index 5b9bdf76..7dc5205d 100644 --- a/source/agglomeration_handler.cc +++ b/source/agglomeration_handler.cc @@ -662,8 +662,7 @@ void AgglomerationHandler::create_agglomeration_sparsity_pattern( SparsityPatternType &dsp, const AffineConstraints &constraints, - const bool keep_constrained_dofs, - const types::subdomain_id subdomain_id) + const bool keep_constrained_dofs) { Assert(n_agglomerations > 0, ExcMessage("The agglomeration has not been set up correctly.")); @@ -685,11 +684,6 @@ AgglomerationHandler::create_agglomeration_sparsity_pattern( else DEAL_II_ASSERT_UNREACHABLE(); - // Create the sparsity pattern corresponding only to volumetric terms. The - // fluxes needed by DG methods will be filled later. - DoFTools::make_sparsity_pattern( - agglo_dh, dsp, constraints, keep_constrained_dofs, subdomain_id); - const unsigned int dofs_per_cell = agglo_dh.get_fe(0).n_dofs_per_cell(); std::vector current_dof_indices(dofs_per_cell); @@ -703,7 +697,12 @@ AgglomerationHandler::create_agglomeration_sparsity_pattern( { const unsigned int n_current_faces = polytope->n_faces(); polytope->get_dof_indices(current_dof_indices); - const CellId current_poly_id = polytope->id(); + // volumetric terms + constraints.add_entries_local_to_global(current_dof_indices, + dsp, + keep_constrained_dofs); + // fill flux terms + const CellId ¤t_poly_id = polytope->id(); for (unsigned int f = 0; f < n_current_faces; ++f) { const auto &neigh_polytope = polytope->neighbor(f); @@ -1330,42 +1329,36 @@ template void AgglomerationHandler<1>::create_agglomeration_sparsity_pattern( DynamicSparsityPattern &sparsity_pattern, const AffineConstraints &constraints, - const bool keep_constrained_dofs, - const types::subdomain_id subdomain_id); + const bool keep_constrained_dofs); template void AgglomerationHandler<1>::create_agglomeration_sparsity_pattern( TrilinosWrappers::SparsityPattern &sparsity_pattern, const AffineConstraints &constraints, - const bool keep_constrained_dofs, - const types::subdomain_id subdomain_id); + const bool keep_constrained_dofs); template class AgglomerationHandler<2>; template void AgglomerationHandler<2>::create_agglomeration_sparsity_pattern( DynamicSparsityPattern &sparsity_pattern, const AffineConstraints &constraints, - const bool keep_constrained_dofs, - const types::subdomain_id subdomain_id); + const bool keep_constrained_dofs); template void AgglomerationHandler<2>::create_agglomeration_sparsity_pattern( TrilinosWrappers::SparsityPattern &sparsity_pattern, const AffineConstraints &constraints, - const bool keep_constrained_dofs, - const types::subdomain_id subdomain_id); + const bool keep_constrained_dofs); template class AgglomerationHandler<3>; template void AgglomerationHandler<3>::create_agglomeration_sparsity_pattern( DynamicSparsityPattern &sparsity_pattern, const AffineConstraints &constraints, - const bool keep_constrained_dofs, - const types::subdomain_id subdomain_id); + const bool keep_constrained_dofs); template void AgglomerationHandler<3>::create_agglomeration_sparsity_pattern( TrilinosWrappers::SparsityPattern &sparsity_pattern, const AffineConstraints &constraints, - const bool keep_constrained_dofs, - const types::subdomain_id subdomain_id); + const bool keep_constrained_dofs);