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

Add AffineConstraints::is_closed() #13505

Merged
merged 1 commit into from
Mar 8, 2022
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
16 changes: 16 additions & 0 deletions include/deal.II/lac/affine_constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,22 @@ class AffineConstraints : public Subscriptor
void
close();

/**
* Check if the function close() was called or there are no
* constraints locally, which is normally the case if a dummy
* AffineConstraints was created for the DG case.
*/
bool
is_closed() const;

/**
* Check if the function close() was called or there are no
* constraints globally, which is normally the case if a dummy
* AffineConstraints was created for the DG case.
*/
bool
is_closed(const MPI_Comm &comm) const;
Copy link
Member

Choose a reason for hiding this comment

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

Do you think it would make sense to select a more descriptive name here?

Suggested change
is_closed(const MPI_Comm &comm) const;
is_closed_on_all_processes(const MPI_Comm &comm) const;

(Given that the AffineConstraints class does not have the notion of the parallel distribution built-in.)

Copy link
Member Author

Choose a reason for hiding this comment

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

To be consistent would be is_closed_in_parallel (similar to is_consistent_in_parallel). The reason why I opted against this is that normally one calls or not close() on all processes (the only reason for having the reduction inisde to be able to decide if the index set is empty - since the constructor sets sorted automatically to false). If you think it is more clear, I can rename the function to is_closed_in_parallel.


/**
* Merge the constraints represented by the object given as argument into
* the constraints represented by this object. Both objects may or may not
Expand Down
17 changes: 17 additions & 0 deletions include/deal.II/lac/affine_constraints.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,23 @@ AffineConstraints<number>::close()



template <typename number>
bool
AffineConstraints<number>::is_closed() const
{
return sorted || (n_constraints() == 0);
}



template <typename number>
bool
AffineConstraints<number>::is_closed(const MPI_Comm &comm) const
{
return Utilities::MPI::min(static_cast<unsigned int>(is_closed()), comm) == 1;
}


template <typename number>
void
AffineConstraints<number>::merge(
Expand Down