]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Error out with too large Trilinos sparsity patterns. 13445/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 24 Feb 2022 22:26:13 +0000 (15:26 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 25 Feb 2022 18:36:44 +0000 (11:36 -0700)
source/lac/trilinos_sparsity_pattern.cc

index 71111b2b6ea016f02e54ba4cca19602becd39c25..2dd0ffc391e6c8e410dad98636f92e52613331c8 100644 (file)
@@ -257,6 +257,18 @@ namespace TrilinosWrappers
       graph.reset();
       column_space_map = std::make_unique<Epetra_Map>(col_map);
 
+      AssertThrow((TrilinosWrappers::max_my_gid(row_map) -
+                   TrilinosWrappers::min_my_gid(row_map)) *
+                      std::uint64_t(n_entries_per_row) <
+                    std::numeric_limits<int>::max(),
+                  ExcMessage("The TrilinosWrappers use Epetra internally which "
+                             "uses 'signed int' to represent local indices. "
+                             "Therefore, only 2,147,483,647 nonzero matrix "
+                             "entries can be stored on a single process, "
+                             "but you are requesting more than that. "
+                             "If possible, use more MPI processes."));
+
+
       // for more than one processor, need to specify only row map first and
       // let the matrix entries decide about the column map (which says which
       // columns are present in the matrix, not to be confused with the
@@ -303,6 +315,9 @@ namespace TrilinosWrappers
                       TrilinosWrappers::n_global_elements(row_map));
 
       column_space_map = std::make_unique<Epetra_Map>(col_map);
+
+      // Translate the vector of row lengths into one that only stores
+      // those entries that related to the locally stored rows of the matrix:
       std::vector<int> local_entries_per_row(
         TrilinosWrappers::max_my_gid(row_map) -
         TrilinosWrappers::min_my_gid(row_map));
@@ -310,6 +325,17 @@ namespace TrilinosWrappers
         local_entries_per_row[i] =
           n_entries_per_row[TrilinosWrappers::min_my_gid(row_map) + i];
 
+      AssertThrow(std::accumulate(local_entries_per_row.begin(),
+                                  local_entries_per_row.end(),
+                                  std::uint64_t(0)) <
+                    std::numeric_limits<int>::max(),
+                  ExcMessage("The TrilinosWrappers use Epetra internally which "
+                             "uses 'signed int' to represent local indices. "
+                             "Therefore, only 2,147,483,647 nonzero matrix "
+                             "entries can be stored on a single process, "
+                             "but you are requesting more than that. "
+                             "If possible, use more MPI processes."));
+
       if (row_map.Comm().NumProc() > 1)
         graph = std::make_unique<Epetra_FECrsGraph>(
           Copy, row_map, local_entries_per_row.data(), false
@@ -360,6 +386,17 @@ namespace TrilinosWrappers
         n_entries_per_row[row - first_row] =
           static_cast<int>(sp.row_length(row));
 
+      AssertThrow(std::accumulate(n_entries_per_row.begin(),
+                                  n_entries_per_row.end(),
+                                  std::uint64_t(0)) <
+                    std::numeric_limits<int>::max(),
+                  ExcMessage("The TrilinosWrappers use Epetra internally which "
+                             "uses 'signed int' to represent local indices. "
+                             "Therefore, only 2,147,483,647 nonzero matrix "
+                             "entries can be stored on a single process, "
+                             "but you are requesting more than that. "
+                             "If possible, use more MPI processes."));
+
       if (row_map.Comm().NumProc() > 1)
         graph = std::make_unique<Epetra_FECrsGraph>(Copy,
                                                     row_map,

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.