From 9097bd5006bd500ecaccfe615a3d5f340cc02b24 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 18 Apr 2018 13:11:08 -0400 Subject: [PATCH] only work on locally active --- include/deal.II/lac/constraint_matrix.h | 12 +++++++++--- source/lac/constraint_matrix.cc | 6 +++++- tests/mpi/constraints_consistent_01.cc | 5 +++++ tests/mpi/constraints_consistent_01.mpirun=3.output | 6 +++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/deal.II/lac/constraint_matrix.h b/include/deal.II/lac/constraint_matrix.h index a7dd469771..652cfc17f7 100644 --- a/include/deal.II/lac/constraint_matrix.h +++ b/include/deal.II/lac/constraint_matrix.h @@ -1212,18 +1212,24 @@ public: * operation and will return @p true only if all processors are consistent. * * Please supply the owned DoFs per processor as return by - * DoFHandler::locally_owned_dofs_per_processor() as @p locally_owned_dofs. + * DoFHandler::locally_owned_dofs_per_processor() as @p locally_owned_dofs + * and the result of DoFTools::extract_locally_active_dofs() as + * @p locally_active_dofs. The + * former is used to determine ownership of the specific DoF, while the latter + * is used as the set of rows that need to be checked. * * If @p verbose is set to @p true, additional debug information is written * to std::cout. * - * @note This method exchanges all constraint information of locally relevant + * @note This method exchanges all constraint information of locally active * lines and is as such slow for large computations and should probably * only be used in debug mode. * - * @return Whether all ConstraintMatrix objects are consistent. + * @return Whether all ConstraintMatrix objects are consistent. Returns the + * same value on all processors. */ bool is_consistent_in_parallel(const std::vector &locally_owned_dofs, + const IndexSet &locally_active_dofs, const MPI_Comm mpi_communicator, const bool verbose=false) const; diff --git a/source/lac/constraint_matrix.cc b/source/lac/constraint_matrix.cc index 9c1d98e3d9..f4e24359a1 100644 --- a/source/lac/constraint_matrix.cc +++ b/source/lac/constraint_matrix.cc @@ -131,6 +131,7 @@ namespace } bool ConstraintMatrix::is_consistent_in_parallel(const std::vector &locally_owned_dofs, + const IndexSet &locally_active_dofs, const MPI_Comm mpi_communicator, const bool verbose) const { @@ -138,7 +139,10 @@ bool ConstraintMatrix::is_consistent_in_parallel(const std::vector &lo std::map< unsigned int, std::vector > to_send; const unsigned int myid = dealii::Utilities::MPI::this_mpi_process(mpi_communicator); - IndexSet non_owned = this->get_local_lines(); + + // We will send all locally active dofs that are not locally owned for checking. Note + // that we allow constraints to differ on locally_relevant (and not active) DoFs. + IndexSet non_owned = locally_active_dofs; non_owned.subtract_set(locally_owned_dofs[myid]); for (auto it = non_owned.begin(); it != non_owned.end(); ++it) { diff --git a/tests/mpi/constraints_consistent_01.cc b/tests/mpi/constraints_consistent_01.cc index bef1b8d747..478bd62377 100644 --- a/tests/mpi/constraints_consistent_01.cc +++ b/tests/mpi/constraints_consistent_01.cc @@ -47,6 +47,10 @@ void check(parallel::distributed::Triangulation &tria) dof_handler.distribute_dofs (fe); IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs (); + IndexSet locally_active_dofs; + + DoFTools::extract_locally_active_dofs (dof_handler, locally_active_dofs); + IndexSet locally_relevant_dofs; DoFTools::extract_locally_relevant_dofs (dof_handler, locally_relevant_dofs); @@ -77,6 +81,7 @@ void check(parallel::distributed::Triangulation &tria) "consistent? " << constraints.is_consistent_in_parallel(dof_handler.locally_owned_dofs_per_processor(), + locally_active_dofs, MPI_COMM_WORLD, true) << std::endl; diff --git a/tests/mpi/constraints_consistent_01.mpirun=3.output b/tests/mpi/constraints_consistent_01.mpirun=3.output index 8151cee2de..239c8ec3ed 100644 --- a/tests/mpi/constraints_consistent_01.mpirun=3.output +++ b/tests/mpi/constraints_consistent_01.mpirun=3.output @@ -414,7 +414,7 @@ constraints: 91 = 42.0000 94 = 42.0000 95 = 42.0000 -DEAL:0::consistent? 0 +DEAL:0::consistent? 1 DEAL:1::LocallyOwned = {[50,129]} constraints: @@ -464,7 +464,7 @@ constraints: 147 = 42.0000 150 = 42.0000 151 = 42.0000 -DEAL:1::consistent? 0 +DEAL:1::consistent? 1 DEAL:2::LocallyOwned = {[130,161]} @@ -495,6 +495,6 @@ constraints: 157 = 42.0000 158 = 42.0000 159 = 42.0000 -DEAL:2::consistent? 0 +DEAL:2::consistent? 1 DEAL::OK -- 2.39.5