]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add check on PETSc contiguos memory 2502/head
authorESeNonFossiIo <esenonfossiio@gmail.com>
Thu, 14 Apr 2016 15:15:51 +0000 (17:15 +0200)
committerESeNonFossiIo <esenonfossiio@gmail.com>
Thu, 14 Apr 2016 16:54:20 +0000 (18:54 +0200)
source/lac/petsc_parallel_sparse_matrix.cc

index 0888d3582a9045d6e739c8210dd92500ce00481a..cade60680d455ae6175b97330173ec4cabf9f398 100644 (file)
@@ -893,10 +893,11 @@ namespace PETScWrappers
     IndexSet
     SparseMatrix::locally_owned_domain_indices () const
     {
-      PetscInt n_rows, n_cols, min, max;
+      PetscInt n_rows, n_cols, min, max, size;
       PetscErrorCode ierr;
       IS *rows = nullptr;
       IS *cols = nullptr;
+      IS *is = nullptr;
 
       ierr = MatGetSize (matrix, &n_rows, &n_cols);
       AssertThrow (ierr == 0, ExcPETScError(ierr));
@@ -908,16 +909,21 @@ namespace PETScWrappers
       IndexSet locally_owned_domain_indices(n_rows);
       locally_owned_domain_indices.add_range(min, max);
 
+      ierr = ISGetLocalSize(*is, &size);
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+      Assert(size==max-min+1, ExcMessage("PETSc is requiring non contiguous memory allocation."));
+
       return locally_owned_domain_indices;
     }
 
     IndexSet
     SparseMatrix::locally_owned_range_indices () const
     {
-      PetscInt n_rows, n_cols, min, max;
+      PetscInt n_rows, n_cols, min, max, size;
       PetscErrorCode ierr;
       IS *rows = nullptr;
       IS *cols = nullptr;
+      IS *is = nullptr;
 
       ierr = MatGetSize (matrix, &n_rows, &n_cols);
       AssertThrow (ierr == 0, ExcPETScError(ierr));
@@ -929,6 +935,10 @@ namespace PETScWrappers
       IndexSet locally_owned_range_indices(n_cols);
       locally_owned_range_indices.add_range(min, max);
 
+      ierr = ISGetLocalSize(*is, &size);
+      AssertThrow (ierr == 0, ExcPETScError(ierr));
+      Assert(size==max-min+1, ExcMessage("PETSc is requiring non contiguous memory allocation."));
+
       return locally_owned_range_indices;
     }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.