From: Daniel Arndt Date: Tue, 16 Aug 2016 16:07:51 +0000 (+0200) Subject: Check has_ghosts using owned_elements X-Git-Tag: v8.5.0-rc1~667^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c97c7e5ff002b8f422a1ae678c950d4d4d349d2;p=dealii.git Check has_ghosts using owned_elements --- diff --git a/source/lac/trilinos_vector.cc b/source/lac/trilinos_vector.cc index 7c3f6868e3..9ea961c8d1 100644 --- a/source/lac/trilinos_vector.cc +++ b/source/lac/trilinos_vector.cc @@ -230,6 +230,14 @@ namespace TrilinosWrappers owned_elements.compress(); } } +#ifdef DEBUG + const MPI_Comm mpi_communicator + = dynamic_cast(&(vector->Comm()))->Comm(); + const size_type n_elements_global + = Utilities::MPI::sum (owned_elements.n_elements(), mpi_communicator); + + Assert (has_ghosts || n_elements_global == size(), ExcInternalError()); +#endif last_action = Zero; } @@ -250,7 +258,23 @@ namespace TrilinosWrappers has_ghosts = vector->Map().UniqueGIDs()==false; - owned_elements = parallel_partitioner; + // If the IndexSets are overlapping, we don't really know + // which process owns what. So we decide that no process + // owns anything in that case. + if (has_ghosts) + { + owned_elements.clear(); + owned_elements.set_size(parallel_partitioner.size()); + } + else + owned_elements = parallel_partitioner; + +#ifdef DEBUG + const size_type n_elements_global + = Utilities::MPI::sum (owned_elements.n_elements(), communicator); + + Assert (has_ghosts || n_elements_global == size(), ExcInternalError()); +#endif last_action = Zero; } @@ -325,7 +349,14 @@ namespace TrilinosWrappers last_action = Insert; } +#ifdef DEBUG + const MPI_Comm mpi_communicator + = dynamic_cast(&(vector->Comm()))->Comm(); + const size_type n_elements_global + = Utilities::MPI::sum (owned_elements.n_elements(), mpi_communicator); + Assert (has_ghosts || n_elements_global == size(), ExcInternalError()); +#endif } @@ -336,6 +367,7 @@ namespace TrilinosWrappers { nonlocal_vector.reset(); owned_elements.clear(); + owned_elements.set_size(v.size()); // In case we do not allow to have different maps, this call means that // we have to reset the vector. So clear the vector, initialize our map @@ -349,17 +381,16 @@ namespace TrilinosWrappers for (size_type block=0; block global_ids (n_elements, -1); - size_type max_size = 0; for (size_type block=0; block(&(vector->Comm()))->Comm(); + const size_type n_elements_global + = Utilities::MPI::sum (owned_elements.n_elements(), mpi_communicator); + + Assert (has_ghosts || n_elements_global == size(), ExcInternalError()); +#endif } @@ -436,6 +474,12 @@ namespace TrilinosWrappers nonlocal_vector.reset(new Epetra_MultiVector(nonlocal_map, 1)); } } +#ifdef DEBUG + const size_type n_elements_global + = Utilities::MPI::sum (owned_elements.n_elements(), communicator); + + Assert (has_ghosts || n_elements_global == size(), ExcInternalError()); +#endif } @@ -605,9 +649,7 @@ namespace TrilinosWrappers Vector::reinit (const size_type n, const bool /*omit_zeroing_entries*/) { - owned_elements.clear(); - owned_elements.set_size(n); - owned_elements.add_range(0, n); + owned_elements = complete_index_set(n); Epetra_LocalMap map ((TrilinosWrappers::types::int_type)n, 0, Utilities::Trilinos::comm_self()); vector.reset (new Epetra_FEVector (map)); @@ -625,8 +667,7 @@ namespace TrilinosWrappers input_map.IndexBase(), input_map.Comm()); vector.reset (new Epetra_FEVector(map)); - owned_elements.set_size(n_global_elements(input_map)); - owned_elements.add_range(0, n_global_elements(input_map)); + owned_elements = complete_index_set(n_global_elements(input_map)); last_action = Zero; } diff --git a/source/lac/trilinos_vector_base.cc b/source/lac/trilinos_vector_base.cc index 1d7ebe5899..7b69d1c7f1 100644 --- a/source/lac/trilinos_vector_base.cc +++ b/source/lac/trilinos_vector_base.cc @@ -102,8 +102,7 @@ namespace TrilinosWrappers has_ghosts (v.has_ghosts), vector(new Epetra_FEVector(*v.vector)) { - owned_elements.set_size(v.size()); - owned_elements.add_range(0,v.size()); + owned_elements = complete_index_set(v.size()); }