From 6338473b056c03f4f7ce6162c5f086269d339efe Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Sun, 6 Feb 2022 07:01:38 +0100 Subject: [PATCH] Fix assert message for empty vector --- include/deal.II/lac/la_parallel_vector.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/deal.II/lac/la_parallel_vector.h b/include/deal.II/lac/la_parallel_vector.h index 15988bdc09..a8be748565 100644 --- a/include/deal.II/lac/la_parallel_vector.h +++ b/include/deal.II/lac/la_parallel_vector.h @@ -1640,7 +1640,9 @@ namespace LinearAlgebra partitioner->ghost_indices().is_element(global_index), ExcAccessToNonLocalElement(global_index, partitioner->local_range().first, - partitioner->local_range().second - 1, + partitioner->local_range().second == 0 ? + 0 : + (partitioner->local_range().second - 1), partitioner->ghost_indices().n_elements())); // do not allow reading a vector which is not in ghost mode Assert(partitioner->in_local_range(global_index) || @@ -1664,7 +1666,9 @@ namespace LinearAlgebra partitioner->ghost_indices().is_element(global_index), ExcAccessToNonLocalElement(global_index, partitioner->local_range().first, - partitioner->local_range().second - 1, + partitioner->local_range().second == 0 ? + 0 : + (partitioner->local_range().second - 1), partitioner->ghost_indices().n_elements())); // we would like to prevent reading ghosts from a vector that does not // have them imported, but this is not possible because we might be in a -- 2.39.5