From ecd51eff4a606cebb7207fb7aa5e65e90e53eb62 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sun, 11 Sep 2016 14:37:15 +0200 Subject: [PATCH] All tests passing --- include/deal.II/base/index_set.h | 13 +++--- source/base/index_set.cc | 42 ++++++++++--------- tests/trilinos/precondition_muelu_q_iso_q1.cc | 4 +- ...os.geq.11.14.with_64bit_indices=off.output | 8 ++-- 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/include/deal.II/base/index_set.h b/include/deal.II/base/index_set.h index 2ec7a30270..34400387a1 100644 --- a/include/deal.II/base/index_set.h +++ b/include/deal.II/base/index_set.h @@ -219,13 +219,14 @@ public: /** * Return whether the IndexSets are ascending with respect to MPI process - * number, i.e., each index is contained in exactly one IndexSet, - * the first indices are contained in the IndexSet of the first MPI process, - * the second indices are contained in the IndexSet of the second MPI process - * and so on. - * In case there is only one MPI process, this is always true. + * number and 1:1, i.e., each index is contained in exactly one IndexSet + * (among those stored on the different processes), each process stores + * contiguous subset of indices, and the index set on process $p+1$ starts + * at the index one larger than the last one stored on process $p$. + * In case there is only one MPI process, this just means that the IndexSet + * is complete. */ - bool is_globally_ascending() const; + bool is_ascending_and_one_to_one(const MPI_Comm &communicator) const; /** * Return the number of elements stored in this index set. diff --git a/source/base/index_set.cc b/source/base/index_set.cc index 24d5c8ca93..b174c0a33c 100644 --- a/source/base/index_set.cc +++ b/source/base/index_set.cc @@ -512,11 +512,11 @@ IndexSet::make_trilinos_map (const MPI_Comm &communicator, } #endif - // Find out if the IndexSet is ascending. - // Overlapping IndexSets are never ascending. - const bool ascending = overlapping ? false : is_globally_ascending(); + // Find out if the IndexSet is ascending and 1:1. This correspinds to a + // linear EpetraMap. Overlapping IndexSets are never 1:1. + const bool linear = overlapping ? false : is_ascending_and_one_to_one(communicator); - if (ascending) + if (linear) return Epetra_Map (TrilinosWrappers::types::int_type(size()), TrilinosWrappers::types::int_type(n_elements()), 0, @@ -551,36 +551,38 @@ IndexSet::make_trilinos_map (const MPI_Comm &communicator, bool -IndexSet::is_globally_ascending () const +IndexSet::is_ascending_and_one_to_one (const MPI_Comm &communicator) const { - // If there is only one process, the IndexSet is always ascending. - const unsigned int n_ranks = Utilities::MPI::n_mpi_processes(communicator); - if (n_ranks==1) - return true; - // / Non-contiguous IndexSets can't be linear. + // If the sum of local elements does not add up to the total size, + // the IndexSet can't be complete. + const size_type n_global_elements + = Utilities::MPI::sum (n_elements(), communicator); + if (n_global_elements != size()) + return false; + + // Non-contiguous IndexSets can't be linear. const bool all_contiguous = (Utilities::MPI::min (is_contiguous() ? 1 : 0, communicator) == 1); if (!all_contiguous) return false; bool is_globally_ascending = true; // we know that there is only one interval - types::global_dof_index local_dofs[2]; - local_dofs[0] = (n_elements()>0) ? *(begin_intervals()->begin()) - : numbers::invalid_dof_index ; - local_dofs[1] = (n_elements()>0) ? begin_intervals()->last() - : numbers::invalid_dof_index; + types::global_dof_index first_local_dof + = (n_elements()>0) ? *(begin_intervals()->begin()) + : numbers::invalid_dof_index ; const unsigned int my_rank = Utilities::MPI::this_mpi_process(communicator); + const unsigned int n_ranks = Utilities::MPI::n_mpi_processes(communicator); // first gather all information on process 0 - const unsigned int gather_size = (my_rank==0)?2*n_ranks:1; + const unsigned int gather_size = (my_rank==0)?n_ranks:1; std::vector global_dofs(gather_size); - MPI_Gather(local_dofs, 2, DEAL_II_DOF_INDEX_MPI_TYPE, - &(global_dofs[0]), 2, DEAL_II_DOF_INDEX_MPI_TYPE, 0, + MPI_Gather(&first_local_dof, 1, DEAL_II_DOF_INDEX_MPI_TYPE, + &(global_dofs[0]), 1, DEAL_II_DOF_INDEX_MPI_TYPE, 0, communicator); if (my_rank == 0) { - // find out if the received std::vector is linear + // find out if the received std::vector is ascending types::global_dof_index old_dof = global_dofs[0], new_dof = 0; types::global_dof_index index = 0; while (global_dofs[index] == numbers::invalid_dof_index) @@ -591,7 +593,7 @@ IndexSet::is_globally_ascending () const new_dof = global_dofs[index]; if (new_dof == numbers::invalid_dof_index) new_dof = old_dof; - else if (new_dof::solve () check_solver_within_range( solver.solve (system_matrix, solution, system_rhs, preconditioner), - solver_control.last_step(), 25, 34); + solver_control.last_step(), 20, 34); } deallog.pop(); @@ -290,7 +290,7 @@ void Step4::solve () check_solver_within_range( solver.solve (system_matrix, solution, system_rhs, preconditioner), - solver_control.last_step(), 24, 40); + solver_control.last_step(), 20, 40); } deallog.pop(); deallog << std::endl; diff --git a/tests/trilinos/precondition_muelu_q_iso_q1.with_trilinos.geq.11.14.with_64bit_indices=off.output b/tests/trilinos/precondition_muelu_q_iso_q1.with_trilinos.geq.11.14.with_64bit_indices=off.output index ac0864f637..1e03d7a759 100644 --- a/tests/trilinos/precondition_muelu_q_iso_q1.with_trilinos.geq.11.14.with_64bit_indices=off.output +++ b/tests/trilinos/precondition_muelu_q_iso_q1.with_trilinos.geq.11.14.with_64bit_indices=off.output @@ -1,7 +1,7 @@ -DEAL:02401:MueLu_Q::Solver stopped within 25 - 34 iterations -DEAL:02401:MueLu_Q_iso_Q1::Solver stopped within 24 - 40 iterations +DEAL:02401:MueLu_Q::Solver stopped within 20 - 34 iterations +DEAL:02401:MueLu_Q_iso_Q1::Solver stopped within 20 - 40 iterations DEAL:02401:: -DEAL:09409:MueLu_Q::Solver stopped within 25 - 34 iterations -DEAL:09409:MueLu_Q_iso_Q1::Solver stopped within 24 - 40 iterations +DEAL:09409:MueLu_Q::Solver stopped within 20 - 34 iterations +DEAL:09409:MueLu_Q_iso_Q1::Solver stopped within 20 - 40 iterations DEAL:09409:: -- 2.39.5