]> https://gitweb.dealii.org/ - dealii.git/commitdiff
bugfix for TrilinosWrapper::SparseMatrix ::add(factor, SparseMatrix) and ::copy_from...
authorUwe Köcher <koecher@hsu-hamburg.de>
Wed, 13 Jun 2018 16:09:20 +0000 (18:09 +0200)
committerUwe Köcher <koecher@hsu-hamburg.de>
Wed, 13 Jun 2018 16:20:49 +0000 (18:20 +0200)
include/deal.II/lac/trilinos_sparse_matrix.h
source/lac/trilinos_sparse_matrix.cc

index c41cc74318302517814dbf13d6ae8b2216831372..54017d21f71e8a64bab6b0cdde9d315c58d631dc 100644 (file)
@@ -519,6 +519,16 @@ namespace TrilinosWrappers
      */
     typedef dealii::types::global_dof_index size_type;
 
+    /**
+     * Exception
+     */
+    DeclException1(ExcAccessToNonlocalRow,
+                   std::size_t,
+                   << "You tried to access row " << arg1
+                   << " of a non-contiguous locally owned row set."
+                   << " The row " << arg1
+                   << " is not stored locally and can't be accessed.");
+
     /**
      * A structure that describes some of the traits of this class in terms of
      * its run-time behavior. Some other classes (such as the block matrix
index 3529b6e22f61871cea8a6ea37508ae6128722827..58bbd5b97775698d5e291be1b4b1a728e5c6057e 100644 (file)
@@ -416,10 +416,11 @@ namespace TrilinosWrappers
         // Try to copy all the rows of the matrix one by one. In case of error
         // (i.e., the column indices are different), we need to abort and blow
         // away the matrix.
-        for (size_type row = local_range.first; row < local_range.second; ++row)
+        for (const auto &row : locally_owned_range_indices())
           {
             const int row_local = matrix->RowMap().LID(
               static_cast<TrilinosWrappers::types::int_type>(row));
+            Assert((row_local >= 0), ExcAccessToNonlocalRow(row));
 
             int             n_entries, rhs_n_entries;
             TrilinosScalar *value_ptr, *rhs_value_ptr;
@@ -1439,6 +1440,7 @@ namespace TrilinosWrappers
     int ncols = -1;
     int local_row =
       matrix->LRID(static_cast<TrilinosWrappers::types::int_type>(row));
+    Assert((local_row >= 0), ExcAccessToNonlocalRow(row));
 
     // on the processor who owns this
     // row, we'll have a non-negative
@@ -1449,7 +1451,7 @@ namespace TrilinosWrappers
         AssertThrow(ierr == 0, ExcTrilinosError(ierr));
       }
 
-    return ncols;
+    return static_cast<unsigned int>(ncols);
   }
 
 
@@ -1885,10 +1887,11 @@ namespace TrilinosWrappers
     const std::pair<size_type, size_type> local_range = rhs.local_range();
     const bool same_col_map = matrix->ColMap().SameAs(rhs.matrix->ColMap());
 
-    for (size_type row = local_range.first; row < local_range.second; ++row)
+    for (const auto &row : locally_owned_range_indices())
       {
         const int row_local = matrix->RowMap().LID(
           static_cast<TrilinosWrappers::types::int_type>(row));
+        Assert((row_local >= 0), ExcAccessToNonlocalRow(row));
 
         // First get a view to the matrix columns of both matrices. Note that
         // the data is in local index spaces so we need to be careful not only

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.