From 431277112374890ba437db792a299de179350b97 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sun, 11 Sep 2016 20:48:44 +0200 Subject: [PATCH] Assert that locally_owned_elements are always linear for initializing PETSc objects --- include/deal.II/lac/petsc_parallel_block_sparse_matrix.h | 4 ++-- include/deal.II/lac/petsc_parallel_sparse_matrix.h | 2 +- include/deal.II/lac/petsc_parallel_vector.h | 9 +++++---- source/lac/petsc_parallel_sparse_matrix.cc | 1 + source/lac/petsc_parallel_vector.cc | 8 ++++---- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/deal.II/lac/petsc_parallel_block_sparse_matrix.h b/include/deal.II/lac/petsc_parallel_block_sparse_matrix.h index fb5fb17786..7113685268 100644 --- a/include/deal.II/lac/petsc_parallel_block_sparse_matrix.h +++ b/include/deal.II/lac/petsc_parallel_block_sparse_matrix.h @@ -149,8 +149,8 @@ namespace PETScWrappers * the BlockSparsityPattern of the Simple type can efficiently store * large sparsity patterns in parallel, so this is the only supported * argument. The IndexSets describe the locally owned range of DoFs for - * each block. Note that each IndexSet needs to be contiguous. For a - * symmetric structure hand in the same vector for the first two + * each block. Note that the IndexSets needs to be ascending and 1:1. + * For a symmetric structure hand in the same vector for the first two * arguments. */ void reinit(const std::vector &rows, diff --git a/include/deal.II/lac/petsc_parallel_sparse_matrix.h b/include/deal.II/lac/petsc_parallel_sparse_matrix.h index ba8574f01c..73c7bd8e81 100644 --- a/include/deal.II/lac/petsc_parallel_sparse_matrix.h +++ b/include/deal.II/lac/petsc_parallel_sparse_matrix.h @@ -317,7 +317,7 @@ namespace PETScWrappers * Create a matrix where the size() of the IndexSets determine the * global number of rows and columns and the entries of the IndexSet * give the rows and columns for the calling processor. Note that only - * contiguous IndexSets are supported. + * ascending, 1:1 IndexSets are supported. */ template void reinit (const IndexSet &local_rows, diff --git a/include/deal.II/lac/petsc_parallel_vector.h b/include/deal.II/lac/petsc_parallel_vector.h index a69df027fb..c8ca0e6280 100644 --- a/include/deal.II/lac/petsc_parallel_vector.h +++ b/include/deal.II/lac/petsc_parallel_vector.h @@ -230,10 +230,11 @@ namespace PETScWrappers const size_type local_size); /** - * Construct a new parallel ghosted PETSc vector from an IndexSet. Note - * that @p local must be contiguous and the global size of the vector is - * determined by local.size(). The global indices in @p ghost are - * supplied as ghost indices that can also be read locally. + * Construct a new parallel ghosted PETSc vector from an IndexSet. + * Note that @p local must be ascending and 1:1. + * The global size of the vector is determined by local.size(). + * The global indices in @p ghost are supplied as ghost indices + * that can also be read locally. * * Note that the @p ghost IndexSet may be empty and that any indices * already contained in @p local are ignored during construction. That diff --git a/source/lac/petsc_parallel_sparse_matrix.cc b/source/lac/petsc_parallel_sparse_matrix.cc index aaf27a8ddb..438d7a4c3c 100644 --- a/source/lac/petsc_parallel_sparse_matrix.cc +++ b/source/lac/petsc_parallel_sparse_matrix.cc @@ -354,6 +354,7 @@ namespace PETScWrappers ExcMessage("SparsityPattern and IndexSet have different number of columns")); Assert(local_rows.is_contiguous() && local_columns.is_contiguous(), ExcMessage("PETSc only supports contiguous row/column ranges")); + Assert(local_rows.is_ascending_and_one_to_one(communicator), ExcNotImplemented()); #ifdef DEBUG { diff --git a/source/lac/petsc_parallel_vector.cc b/source/lac/petsc_parallel_vector.cc index 0f146f59c1..c1364370f3 100644 --- a/source/lac/petsc_parallel_vector.cc +++ b/source/lac/petsc_parallel_vector.cc @@ -72,7 +72,7 @@ namespace PETScWrappers : communicator (communicator) { - Assert(local.is_contiguous(), ExcNotImplemented()); + Assert(local.is_ascending_and_one_to_one(communicator), ExcNotImplemented()); IndexSet ghost_set = ghost; ghost_set.subtract_set(local); @@ -87,7 +87,7 @@ namespace PETScWrappers : communicator (communicator) { - Assert(local.is_contiguous(), ExcNotImplemented()); + Assert(local.is_ascending_and_one_to_one(communicator), ExcNotImplemented()); Vector::create_vector(local.size(), local.n_elements()); } @@ -189,7 +189,7 @@ namespace PETScWrappers communicator = comm; - Assert(local.is_contiguous(), ExcNotImplemented()); + Assert(local.is_ascending_and_one_to_one(comm), ExcNotImplemented()); IndexSet ghost_set = ghost; ghost_set.subtract_set(local); @@ -211,7 +211,7 @@ namespace PETScWrappers communicator = comm; - Assert(local.is_contiguous(), ExcNotImplemented()); + Assert(local.is_ascending_and_one_to_one(comm), ExcNotImplemented()); Assert(local.size()>0, ExcMessage("can not create vector of size 0.")); create_vector(local.size(), local.n_elements()); } -- 2.39.5