Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid use of old AffineConstraints functions. #16034

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
Comment on lines -616 to +620
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness (in hindsight), this change was wrong. It is fixed in #16053.


// 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