]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Save the locally owned rows in TrilinosWrappers::SparsityPattern
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Tue, 24 Jul 2018 23:05:58 +0000 (01:05 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Tue, 24 Jul 2018 23:09:55 +0000 (01:09 +0200)
include/deal.II/lac/trilinos_sparsity_pattern.h
source/lac/trilinos_sparsity_pattern.cc

index 4402336ff3465dd6fd34594c23a8354a10d98b14..0dc3bb4cbb911ae390e1e0c84e9c8a8073a8ee30 100644 (file)
@@ -1230,6 +1230,11 @@ namespace TrilinosWrappers
      */
     std::unique_ptr<Epetra_CrsGraph> nonlocal_graph;
 
+    /**
+     * The set of locally owned rows.
+     */
+    IndexSet locally_owned_rows;
+
     friend class TrilinosWrappers::SparseMatrix;
     friend class SparsityPatternIterators::Accessor;
     friend class SparsityPatternIterators::Iterator;
@@ -1318,7 +1323,8 @@ namespace TrilinosWrappers
               const auto row_length =
                 accessor.sparsity_pattern->row_length(accessor.a_row);
               if (row_length == 0 ||
-                  row_length == static_cast<SparsityPattern::size_type>(-1))
+                  !accessor.sparsity_pattern->locally_owned_rows.is_element(
+                    accessor.a_row))
                 ++accessor.a_row;
               else
                 break;
@@ -1500,8 +1506,7 @@ namespace TrilinosWrappers
     const int n_cols = static_cast<int>(end - begin);
 
     int ierr;
-    if (graph->RowMap().LID(
-          static_cast<TrilinosWrappers::types::int_type>(row)) != -1)
+    if (locally_owned_rows.is_element(row))
       ierr = graph->InsertGlobalIndices(row, n_cols, col_index_ptr);
     else if (nonlocal_graph.get() != nullptr)
       {
index e5fe4baf5fdb237aef2d9c0ba38aee4ba145619e..905ca2d9212ef2fa56e07b74c62bcc6411184d1c 100644 (file)
@@ -154,9 +154,11 @@ namespace TrilinosWrappers
     , column_space_map(std::move(other.column_space_map))
     , graph(std::move(other.graph))
     , nonlocal_graph(std::move(other.nonlocal_graph))
+    , locally_owned_rows(std::move(other.locally_owned_rows))
   {}
 
 
+
   // Copy function only works if the
   // sparsity pattern is empty.
   SparsityPattern::SparsityPattern(const SparsityPattern &input_sparsity)
@@ -484,6 +486,9 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
+    locally_owned_rows.clear();
+    const auto range = this->local_range();
+    locally_owned_rows.add_range(range.first, range.second);
   }
 
 
@@ -499,6 +504,8 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
+    const auto range = this->local_range();
+    locally_owned_rows.add_range(range.first, range.second);
   }
 
 
@@ -513,6 +520,8 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
+    const auto range = this->local_range();
+    locally_owned_rows.add_range(range.first, range.second);
   }
 
 
@@ -528,6 +537,8 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
+    const auto range = this->local_range();
+    locally_owned_rows.add_range(range.first, range.second);
   }
 
 
@@ -541,6 +552,7 @@ namespace TrilinosWrappers
       parallel_partitioning.make_trilinos_map(communicator, false);
     reinit_sp(
       map, map, n_entries_per_row, column_space_map, graph, nonlocal_graph);
+    locally_owned_rows = parallel_partitioning;
   }
 
 
@@ -554,6 +566,7 @@ namespace TrilinosWrappers
       parallel_partitioning.make_trilinos_map(communicator, false);
     reinit_sp(
       map, map, n_entries_per_row, column_space_map, graph, nonlocal_graph);
+    locally_owned_rows = parallel_partitioning;
   }
 
 
@@ -574,6 +587,7 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
+    locally_owned_rows = row_parallel_partitioning;
   }
 
 
@@ -594,6 +608,7 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
+    locally_owned_rows = row_parallel_partitioning;
   }
 
 
@@ -615,6 +630,7 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
+    locally_owned_rows = row_parallel_partitioning;
 
     IndexSet nonlocal_partitioner = writable_rows;
     AssertDimension(nonlocal_partitioner.size(),
@@ -662,6 +678,7 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
+    locally_owned_rows = row_parallel_partitioning;
   }
 
 
@@ -683,6 +700,7 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
+    locally_owned_rows = parallel_partitioning;
   }
 
 
@@ -700,6 +718,8 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
+    const auto range = this->local_range();
+    locally_owned_rows.add_range(range.first, range.second);
   }
 
 
@@ -718,7 +738,8 @@ namespace TrilinosWrappers
               column_space_map,
               graph,
               nonlocal_graph);
-
+    const auto range = this->local_range();
+    locally_owned_rows.add_range(range.first, range.second);
     compress();
   }
 
@@ -738,6 +759,7 @@ namespace TrilinosWrappers
   {
     column_space_map = std_cxx14::make_unique<Epetra_Map>(*sp.column_space_map);
     graph            = std_cxx14::make_unique<Epetra_FECrsGraph>(*sp.graph);
+    locally_owned_rows = sp.locally_owned_rows;
 
     if (sp.nonlocal_graph.get() != nullptr)
       nonlocal_graph =
@@ -761,6 +783,7 @@ namespace TrilinosWrappers
 
     reinit_sp(
       rows, columns, sp, false, column_space_map, graph, nonlocal_graph);
+    locally_owned_rows = complete_index_set(sp.n_rows());
   }
 
 
@@ -835,25 +858,19 @@ namespace TrilinosWrappers
   bool
   SparsityPattern::exists(const size_type i, const size_type j) const
   {
-    // Extract local indices in
-    // the matrix.
-    int trilinos_i =
-          graph->LRID(static_cast<TrilinosWrappers::types::int_type>(i)),
-        trilinos_j =
-          graph->LCID(static_cast<TrilinosWrappers::types::int_type>(j));
-
-    // If the data is not on the
-    // present processor, we throw
-    // an exception. This is on of
-    // the two tiny differences to
-    // the el(i,j) call, which does
-    // not throw any assertions.
-    if (trilinos_i == -1)
+    if (!locally_owned_rows.is_element(i))
       {
         return false;
       }
     else
       {
+        // Extract local indices in
+        // the matrix.
+        int trilinos_i =
+              graph->LRID(static_cast<TrilinosWrappers::types::int_type>(i)),
+            trilinos_j =
+              graph->LCID(static_cast<TrilinosWrappers::types::int_type>(j));
+
         // Check whether the matrix
         // already is transformed to
         // local 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.