From 347390bc75d4324f455ea9a40853dd9cf5ae0809 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 29 Aug 2016 16:58:24 +0200 Subject: [PATCH] In case we can't deduce locally_owned_elements, set the size of owned_elements to zero --- include/deal.II/lac/trilinos_vector.h | 4 +++ source/lac/trilinos_vector.cc | 48 ++++++++++++++++----------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/include/deal.II/lac/trilinos_vector.h b/include/deal.II/lac/trilinos_vector.h index e2225accc1..6cb27c126b 100644 --- a/include/deal.II/lac/trilinos_vector.h +++ b/include/deal.II/lac/trilinos_vector.h @@ -511,6 +511,10 @@ namespace TrilinosWrappers * or may not have ghost elements. See the general documentation of this * class for more information. * + * In case the provided IndexSet forms an overlapping partitioning, + * it it not clear which elements are owned by which process and + * locally_owned_elements will return an IndexSet of size zero. + * * @see * @ref GlossGhostedVector "vectors with ghost elements" */ diff --git a/source/lac/trilinos_vector.cc b/source/lac/trilinos_vector.cc index cfae13069a..836f8c2b20 100644 --- a/source/lac/trilinos_vector.cc +++ b/source/lac/trilinos_vector.cc @@ -208,28 +208,35 @@ namespace TrilinosWrappers has_ghosts = vector->Map().UniqueGIDs()==false; - { - owned_elements.clear(); - owned_elements.set_size(size()); + // 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. In particular asking for + // the locally owned elements is not allowed. + owned_elements.clear(); + if (has_ghosts) + owned_elements.set_size(0); + else + { + owned_elements.set_size(size()); - // easy case: local range is contiguous - if (vector->Map().LinearMap()) - { - const std::pair x = local_range(); - owned_elements.add_range (x.first, x.second); - } - else if (vector->Map().NumMyElements() > 0) - { - const size_type n_indices = vector->Map().NumMyElements(); + // easy case: local range is contiguous + if (vector->Map().LinearMap()) + { + const std::pair x = local_range(); + owned_elements.add_range (x.first, x.second); + } + else if (vector->Map().NumMyElements() > 0) + { + const size_type n_indices = vector->Map().NumMyElements(); #ifndef DEAL_II_WITH_64BIT_INDICES - unsigned int *vector_indices = (unsigned int *)vector->Map().MyGlobalElements(); + unsigned int *vector_indices = (unsigned int *)vector->Map().MyGlobalElements(); #else - size_type *vector_indices = (size_type *)vector->Map().MyGlobalElements64(); + size_type *vector_indices = (size_type *)vector->Map().MyGlobalElements64(); #endif - owned_elements.add_indices(vector_indices, vector_indices+n_indices); - owned_elements.compress(); - } - } + owned_elements.add_indices(vector_indices, vector_indices+n_indices); + owned_elements.compress(); + } + } #ifdef DEBUG const MPI_Comm mpi_communicator = dynamic_cast(&(vector->Comm()))->Comm(); @@ -260,11 +267,12 @@ namespace TrilinosWrappers // 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. + // owns anything in that case. In particular asking for + // the locally owned elements is not allowed. if (has_ghosts) { owned_elements.clear(); - owned_elements.set_size(parallel_partitioner.size()); + owned_elements.set_size(0); } else owned_elements = parallel_partitioner; -- 2.39.5