Skip to content

Commit

Permalink
Merge pull request #16034 from bangerth/affine-15
Browse files Browse the repository at this point in the history
Avoid use of old AffineConstraints functions.
  • Loading branch information
kronbichler committed Sep 24, 2023
2 parents d6cf33b + a5f35f6 commit b35d4ea
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
26 changes: 26 additions & 0 deletions include/deal.II/lac/affine_constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,17 @@ class AffineConstraints : public Subscriptor
bool
can_store_line(const size_type line_n) const;

/**
* Return the index set describing which part of the degrees of freedom to
* which this object stores constraints are "locally owned". Typically,
* these would be the
* @ref GlossLocallyOwnedDof "locally owned degrees of freedom".
* This function returns the corresponding index set provided to either
* the constructor or the reinit() function of this class.
*/
const IndexSet &
get_locally_owned_indices() const;

/**
* Return the index set describing locally relevant lines if any are
* present. Note that if no local lines were given, this represents an empty
Expand Down Expand Up @@ -2378,20 +2389,35 @@ AffineConstraints<number>::calculate_line_index(const size_type line_n) const
return local_lines.index_within_set(line_n);
}



template <typename number>
inline bool
AffineConstraints<number>::can_store_line(size_type line_n) const
{
return local_lines.size() == 0 || local_lines.is_element(line_n);
}



template <typename number>
inline const IndexSet &
AffineConstraints<number>::get_locally_owned_indices() const
{
return locally_owned_dofs;
}



template <typename number>
inline const IndexSet &
AffineConstraints<number>::get_local_lines() const
{
return local_lines;
}



template <typename number>
template <typename VectorType>
inline void
Expand Down
12 changes: 8 additions & 4 deletions include/deal.II/multigrid/mg_constrained_dofs.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,15 @@ MGConstrainedDoFs::initialize(
{
if (user_level_dofs)
{
level_constraints[l].reinit(level_relevant_dofs[l]);
level_constraints[l].reinit(dof.locally_owned_mg_dofs(l),
level_relevant_dofs[l]);
}
else
{
const IndexSet relevant_dofs =
DoFTools::extract_locally_relevant_level_dofs(dof, l);
level_constraints[l].reinit(relevant_dofs);
level_constraints[l].reinit(dof.locally_owned_mg_dofs(l),
relevant_dofs);
}

// Loop through relevant cells and faces finding those which are periodic
Expand Down Expand Up @@ -478,7 +480,9 @@ MGConstrainedDoFs::add_user_constraints(
// Get the relevant DoFs from level_constraints if
// the user constraint matrix has not been initialized
if (user_constraints[level].get_local_lines().size() == 0)
user_constraints[level].reinit(level_constraints[level].get_local_lines());
user_constraints[level].reinit(
level_constraints[level].get_locally_owned_indices(),
level_constraints[level].get_local_lines());

user_constraints[level].merge(
constraints_on_level,
Expand Down Expand Up @@ -613,7 +617,7 @@ MGConstrainedDoFs::merge_constraints(AffineConstraints<Number> &constraints,
index_set.add_indices(
this->get_user_constraint_matrix(level).get_local_lines());

constraints.reinit(index_set);
constraints.reinit(constraints.get_locally_owned_indices(), index_set);

// merge constraints
if (add_boundary_indices && this->have_boundary_indices())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ namespace VectorTools
const Mapping<dim, spacedim> &mapping)
{
AffineConstraints<double> no_normal_flux_constraints(
constraints.get_local_lines());
constraints.get_locally_owned_indices(), constraints.get_local_lines());
compute_nonzero_normal_flux_constraints(dof_handler,
first_vector_component,
boundary_ids,
Expand Down
2 changes: 1 addition & 1 deletion source/dofs/dof_renumbering.cc
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ namespace DoFRenumbering
// reordering with constraints is not yet implemented on a level basis
Assert(reorder_level_dofs == false, ExcNotImplemented());

constraints.reinit(locally_relevant_dofs);
constraints.reinit(locally_owned_dofs, locally_relevant_dofs);
DoFTools::make_hanging_node_constraints(dof_handler, constraints);
}
constraints.close();
Expand Down

0 comments on commit b35d4ea

Please sign in to comment.