]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid C-style cast in Trilinos-related files
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 1 Dec 2018 11:10:38 +0000 (12:10 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 1 Dec 2018 16:26:23 +0000 (17:26 +0100)
include/deal.II/lac/trilinos_sparsity_pattern.h
include/deal.II/lac/trilinos_vector.h
source/lac/trilinos_epetra_vector.cc
source/lac/trilinos_precondition.cc
source/lac/trilinos_sparse_matrix.cc
source/lac/trilinos_sparsity_pattern.cc

index 76bf07e5589f202964cc6f18a6bd2234d96bd7c5..dbb039ad1785e5a9ab5783f5fdc5193504f3c8f8 100644 (file)
@@ -1504,12 +1504,17 @@ namespace TrilinosWrappers
            ExcNotImplemented());
 
     TrilinosWrappers::types::int_type *col_index_ptr =
-      (TrilinosWrappers::types::int_type *)(&*begin);
-    const int n_cols = static_cast<int>(end - begin);
+      reinterpret_cast<TrilinosWrappers::types::int_type *>(
+        const_cast<typename std::decay<decltype(*begin)>::type *>(&*begin));
+    // Check at least for the first index that the conversion actually works
+    AssertDimension(*col_index_ptr, *begin);
+    TrilinosWrappers::types::int_type trilinos_row_index = row;
+    const int                         n_cols = static_cast<int>(end - begin);
 
     int ierr;
     if (row_is_stored_locally(row))
-      ierr = graph->InsertGlobalIndices(row, n_cols, col_index_ptr);
+      ierr =
+        graph->InsertGlobalIndices(trilinos_row_index, n_cols, col_index_ptr);
     else if (nonlocal_graph.get() != nullptr)
       {
         // this is the case when we have explicitly set the off-processor rows
@@ -1520,11 +1525,15 @@ namespace TrilinosWrappers
                ExcMessage("Attempted to write into off-processor matrix row "
                           "that has not be specified as being writable upon "
                           "initialization"));
-        ierr = nonlocal_graph->InsertGlobalIndices(row, n_cols, col_index_ptr);
+        ierr = nonlocal_graph->InsertGlobalIndices(trilinos_row_index,
+                                                   n_cols,
+                                                   col_index_ptr);
       }
     else
-      ierr = graph->InsertGlobalIndices(
-        1, (TrilinosWrappers::types::int_type *)&row, n_cols, col_index_ptr);
+      ierr = graph->InsertGlobalIndices(1,
+                                        &trilinos_row_index,
+                                        n_cols,
+                                        col_index_ptr);
 
     AssertThrow(ierr >= 0, ExcTrilinosError(ierr));
   }
index 5443954e0a14d4eeebb0926042cedf4bb2b9e249..140f4b7318297cd0f970b0411d7c1554247f4f8f 100644 (file)
@@ -1613,7 +1613,8 @@ namespace TrilinosWrappers
             {
               const int ierr = vector->ReplaceGlobalValues(
                 1,
-                (const TrilinosWrappers::types::int_type *)(&row),
+                reinterpret_cast<const TrilinosWrappers::types::int_type *>(
+                  &row),
                 &values[i]);
               AssertThrow(ierr == 0, ExcTrilinosError(ierr));
               compressed = false;
@@ -1688,7 +1689,8 @@ namespace TrilinosWrappers
             {
               const int ierr = vector->SumIntoGlobalValues(
                 1,
-                (const TrilinosWrappers::types::int_type *)(&row),
+                reinterpret_cast<const TrilinosWrappers::types::int_type *>(
+                  &row),
                 &values[i]);
               AssertThrow(ierr == 0, ExcTrilinosError(ierr));
               compressed = false;
@@ -1717,11 +1719,9 @@ namespace TrilinosWrappers
     Vector::size() const
     {
 #    ifndef DEAL_II_WITH_64BIT_INDICES
-      return (size_type)(vector->Map().MaxAllGID() + 1 -
-                         vector->Map().MinAllGID());
+      return vector->Map().MaxAllGID() + 1 - vector->Map().MinAllGID();
 #    else
-      return (size_type)(vector->Map().MaxAllGID64() + 1 -
-                         vector->Map().MinAllGID64());
+      return vector->Map().MaxAllGID64() + 1 - vector->Map().MinAllGID64();
 #    endif
     }
 
@@ -1730,7 +1730,7 @@ namespace TrilinosWrappers
     inline Vector::size_type
     Vector::local_size() const
     {
-      return (size_type)vector->Map().NumMyElements();
+      return vector->Map().NumMyElements();
     }
 
 
index 202fa08f687ffdddadfbc839a4ec66fc20bae7c2..52264d727d3afd45e6cbd0c1ea3f75258ddb58fa 100644 (file)
@@ -575,7 +575,7 @@ namespace LinearAlgebra
             (unsigned int *)vector->Map().MyGlobalElements();
 #    else
           size_type *vector_indices =
-            (size_type *)vector->Map().MyGlobalElements64();
+            reinterpret_cast<size_type *>(vector->Map().MyGlobalElements64());
 #    endif
           is.add_indices(vector_indices, vector_indices + n_indices);
         }
index 2365635f1b3cf3635b48a48025f0680afc22c584..2068166215130c7475e1045ce6e331ef49467b43 100644 (file)
@@ -121,7 +121,7 @@ namespace TrilinosWrappers
                       0));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -173,7 +173,7 @@ namespace TrilinosWrappers
                       additional_data.overlap));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -226,7 +226,7 @@ namespace TrilinosWrappers
                       additional_data.overlap));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -288,7 +288,7 @@ namespace TrilinosWrappers
                       0));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -356,7 +356,7 @@ namespace TrilinosWrappers
                       additional_data.overlap));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -425,7 +425,7 @@ namespace TrilinosWrappers
                       additional_data.overlap));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -484,7 +484,7 @@ namespace TrilinosWrappers
                       additional_data.overlap));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -492,7 +492,7 @@ namespace TrilinosWrappers
     int ierr;
 
     Teuchos::ParameterList parameter_list;
-    parameter_list.set("fact: level-of-fill", (int)additional_data.ic_fill);
+    parameter_list.set("fact: level-of-fill", additional_data.ic_fill);
     parameter_list.set("fact: absolute threshold", additional_data.ic_atol);
     parameter_list.set("fact: relative threshold", additional_data.ic_rtol);
     parameter_list.set("schwarz: combine mode", "Add");
@@ -534,7 +534,7 @@ namespace TrilinosWrappers
                       additional_data.overlap));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -587,7 +587,7 @@ namespace TrilinosWrappers
                       additional_data.overlap));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -596,7 +596,8 @@ namespace TrilinosWrappers
 
     Teuchos::ParameterList parameter_list;
     parameter_list.set("fact: drop value", additional_data.ilut_drop);
-    parameter_list.set("fact: level-of-fill", (int)additional_data.ilut_fill);
+    parameter_list.set("fact: level-of-fill",
+                       static_cast<int>(additional_data.ilut_fill));
     parameter_list.set("fact: absolute threshold", additional_data.ilut_atol);
     parameter_list.set("fact: relative threshold", additional_data.ilut_rtol);
     parameter_list.set("schwarz: combine mode", "Add");
@@ -633,7 +634,7 @@ namespace TrilinosWrappers
                       additional_data.overlap));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -683,7 +684,7 @@ namespace TrilinosWrappers
       std::make_shared<Ifpack_Chebyshev>(&matrix.trilinos_matrix());
 
     Ifpack_Chebyshev *ifpack =
-      static_cast<Ifpack_Chebyshev *>(preconditioner.get());
+      dynamic_cast<Ifpack_Chebyshev *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
@@ -697,7 +698,8 @@ namespace TrilinosWrappers
                        additional_data.min_eigenvalue);
     parameter_list.set("chebyshev: max eigenvalue",
                        additional_data.max_eigenvalue);
-    parameter_list.set("chebyshev: degree", (int)additional_data.degree);
+    parameter_list.set("chebyshev: degree",
+                       static_cast<int>(additional_data.degree));
     parameter_list.set("chebyshev: min diagonal value",
                        additional_data.min_diagonal);
     parameter_list.set("chebyshev: zero starting solution",
@@ -738,7 +740,7 @@ namespace TrilinosWrappers
                       0));
 
     Ifpack_Preconditioner *ifpack =
-      static_cast<Ifpack_Preconditioner *>(preconditioner.get());
+      dynamic_cast<Ifpack_Preconditioner *>(preconditioner.get());
     Assert(ifpack != nullptr,
            ExcMessage("Trilinos could not create this "
                       "preconditioner"));
index 2f1c18e426775698ba377eff9e751ef9a06ab927..b9bb3bbed93d10f9d9a5d1c11b410fa97f3d454d 100644 (file)
@@ -143,7 +143,7 @@ namespace TrilinosWrappers
         }
 
       int ierr = matrix->trilinos_matrix().ExtractGlobalRowCopy(
-        (TrilinosWrappers::types::int_type)this->a_row,
+        static_cast<TrilinosWrappers::types::int_type>(this->a_row),
         colnums,
         ncols,
         &((*value_cache)[0]),
@@ -205,8 +205,9 @@ namespace TrilinosWrappers
     : column_space_map(new Epetra_Map(input_map))
     , matrix(new Epetra_FECrsMatrix(Copy,
                                     *column_space_map,
-                                    (int *)const_cast<unsigned int *>(
-                                      &(n_entries_per_row[0])),
+                                    reinterpret_cast<int *>(
+                                      const_cast<unsigned int *>(
+                                        &(n_entries_per_row[0]))),
                                     false))
     , last_action(Zero)
     , compressed(false)
@@ -235,8 +236,9 @@ namespace TrilinosWrappers
     : column_space_map(new Epetra_Map(input_col_map))
     , matrix(new Epetra_FECrsMatrix(Copy,
                                     input_row_map,
-                                    (int *)const_cast<unsigned int *>(
-                                      &(n_entries_per_row[0])),
+                                    reinterpret_cast<int *>(
+                                      const_cast<unsigned int *>(
+                                        &(n_entries_per_row[0]))),
                                     false))
     , last_action(Zero)
     , compressed(false)
@@ -288,7 +290,8 @@ namespace TrilinosWrappers
                    0,
                    Utilities::Trilinos::comm_self()),
         *column_space_map,
-        (int *)const_cast<unsigned int *>(&(n_entries_per_row[0])),
+        reinterpret_cast<int *>(
+          const_cast<unsigned int *>(&(n_entries_per_row[0]))),
         false))
     , last_action(Zero)
     , compressed(false)
@@ -318,8 +321,9 @@ namespace TrilinosWrappers
         parallel_partitioning.make_trilinos_map(communicator, false)))
     , matrix(new Epetra_FECrsMatrix(Copy,
                                     *column_space_map,
-                                    (int *)const_cast<unsigned int *>(
-                                      &(n_entries_per_row[0])),
+                                    reinterpret_cast<int *>(
+                                      const_cast<unsigned int *>(
+                                        &(n_entries_per_row[0]))),
                                     false))
     , last_action(Zero)
     , compressed(false)
@@ -353,7 +357,8 @@ namespace TrilinosWrappers
     , matrix(new Epetra_FECrsMatrix(
         Copy,
         row_parallel_partitioning.make_trilinos_map(communicator, false),
-        (int *)const_cast<unsigned int *>(&(n_entries_per_row[0])),
+        reinterpret_cast<int *>(
+          const_cast<unsigned int *>(&(n_entries_per_row[0]))),
         false))
     , last_action(Zero)
     , compressed(false)
@@ -1243,7 +1248,7 @@ namespace TrilinosWrappers
 
         int *diag_find =
           std::find(col_indices, col_indices + num_entries, local_row);
-        int diag_index = (int)(diag_find - col_indices);
+        int diag_index = static_cast<int>(diag_find - col_indices);
 
         for (TrilinosWrappers::types::int_type j = 0; j < num_entries; ++j)
           if (diag_index != j || new_diag_value == 0)
@@ -1325,7 +1330,7 @@ namespace TrilinosWrappers
         int *el_find =
           std::find(col_indices, col_indices + nnz_present, trilinos_j);
 
-        int local_col_index = (int)(el_find - col_indices);
+        int local_col_index = static_cast<int>(el_find - col_indices);
 
         // This is actually the only
         // difference to the el(i,j)
@@ -1401,7 +1406,7 @@ namespace TrilinosWrappers
         int *el_find =
           std::find(col_indices, col_indices + nnz_present, trilinos_j);
 
-        int local_col_index = (int)(el_find - col_indices);
+        int local_col_index = static_cast<int>(el_find - col_indices);
 
 
         // This is actually the only
@@ -1542,7 +1547,8 @@ namespace TrilinosWrappers
     // we will not modify const data)
     if (elide_zero_values == false)
       {
-        col_index_ptr = (TrilinosWrappers::types::int_type *)col_indices;
+        col_index_ptr = reinterpret_cast<TrilinosWrappers::types::int_type *>(
+          const_cast<size_type *>(col_indices));
         col_value_ptr = const_cast<TrilinosScalar *>(values);
         n_columns     = n_cols;
       }
@@ -1566,8 +1572,7 @@ namespace TrilinosWrappers
               }
           }
 
-        Assert(n_columns <= (TrilinosWrappers::types::int_type)n_cols,
-               ExcInternalError());
+        AssertIndexRange(n_columns, n_cols + 1);
       }
 
 
@@ -1585,7 +1590,7 @@ namespace TrilinosWrappers
         if (matrix->Filled() == false)
           {
             ierr = matrix->Epetra_CrsMatrix::InsertGlobalValues(
-              static_cast<TrilinosWrappers::types::int_type>(row),
+              row,
               static_cast<int>(n_columns),
               const_cast<double *>(col_value_ptr),
               col_index_ptr);
@@ -1616,7 +1621,8 @@ namespace TrilinosWrappers
           {
             ierr = matrix->InsertGlobalValues(
               1,
-              (TrilinosWrappers::types::int_type *)&row,
+              reinterpret_cast<TrilinosWrappers::types::int_type *>(
+                const_cast<size_type *>(&row)),
               n_columns,
               col_index_ptr,
               &col_value_ptr,
@@ -1627,7 +1633,8 @@ namespace TrilinosWrappers
         else
           ierr = matrix->ReplaceGlobalValues(
             1,
-            (TrilinosWrappers::types::int_type *)&row,
+            reinterpret_cast<TrilinosWrappers::types::int_type *>(
+              const_cast<size_type *>(&row)),
             n_columns,
             col_index_ptr,
             &col_value_ptr,
@@ -1739,7 +1746,8 @@ namespace TrilinosWrappers
     // we will not modify const data)
     if (elide_zero_values == false)
       {
-        col_index_ptr = (TrilinosWrappers::types::int_type *)col_indices;
+        col_index_ptr = reinterpret_cast<TrilinosWrappers::types::int_type *>(
+          const_cast<size_type *>(col_indices));
         col_value_ptr = const_cast<TrilinosScalar *>(values);
         n_columns     = n_cols;
 #  ifdef DEBUG
@@ -1768,8 +1776,7 @@ namespace TrilinosWrappers
               }
           }
 
-        Assert(n_columns <= (TrilinosWrappers::types::int_type)n_cols,
-               ExcInternalError());
+        AssertIndexRange(n_columns, n_cols + 1);
       }
     // Exit early if there is nothing to do
     if (n_columns == 0)
@@ -1816,13 +1823,14 @@ namespace TrilinosWrappers
         // a time).
         compressed = false;
 
-        ierr =
-          matrix->SumIntoGlobalValues(1,
-                                      (TrilinosWrappers::types::int_type *)&row,
-                                      n_columns,
-                                      col_index_ptr,
-                                      &col_value_ptr,
-                                      Epetra_FECrsMatrix::ROW_MAJOR);
+        ierr = matrix->SumIntoGlobalValues(
+          1,
+          reinterpret_cast<TrilinosWrappers::types::int_type *>(
+            const_cast<size_type *>(&row)),
+          n_columns,
+          col_index_ptr,
+          &col_value_ptr,
+          Epetra_FECrsMatrix::ROW_MAJOR);
         AssertThrow(ierr == 0, ExcTrilinosError(ierr));
       }
 
index 2a2bdf71f19a2886765e09b6cdb9fb0bc0ca44bc..8883e5194545b937de0e214a640d1beea3a8c2bd 100644 (file)
@@ -56,10 +56,11 @@ namespace TrilinosWrappers
           // get a representation of the present row
           int       ncols;
           const int ierr = sparsity_pattern->graph->ExtractGlobalRowCopy(
-            (TrilinosWrappers::types::int_type)this->a_row,
+            static_cast<TrilinosWrappers::types::int_type>(this->a_row),
             colnum_cache->size(),
             ncols,
-            (TrilinosWrappers::types::int_type *)&(*colnum_cache)[0]);
+            reinterpret_cast<TrilinosWrappers::types::int_type *>(
+              const_cast<size_type *>(&(*colnum_cache)[0])));
           AssertThrow(ierr == 0, ExcTrilinosError(ierr));
           AssertThrow(static_cast<std::vector<size_type>::size_type>(ncols) ==
                         colnum_cache->size(),
@@ -459,10 +460,10 @@ namespace TrilinosWrappers
               row_indices.data());
           }
 
-      int ierr = graph->GlobalAssemble(*column_space_map,
-                                       static_cast<const Epetra_Map &>(
-                                         graph->RangeMap()),
-                                       true);
+      // TODO A dynamic_cast fails here, this is suspicious.
+      const auto &range_map =
+        static_cast<const Epetra_Map &>(graph->RangeMap());
+      int ierr = graph->GlobalAssemble(*column_space_map, range_map, true);
       AssertThrow(ierr == 0, ExcTrilinosError(ierr));
 
       ierr = graph->OptimizeStorage();
@@ -786,7 +787,7 @@ namespace TrilinosWrappers
   SparsityPattern::compress()
   {
     int ierr;
-    Assert(column_space_map.get() != nullptr, ExcInternalError());
+    Assert(column_space_map.get(), ExcInternalError());
     if (nonlocal_graph.get() != nullptr)
       {
         if (nonlocal_graph->IndicesAreGlobal() == false &&
@@ -801,24 +802,24 @@ namespace TrilinosWrappers
         Assert(nonlocal_graph->RowMap().NumMyElements() == 0 ||
                  nonlocal_graph->IndicesAreGlobal() == true,
                ExcInternalError());
-        nonlocal_graph->FillComplete(*column_space_map,
-                                     static_cast<const Epetra_Map &>(
-                                       graph->RangeMap()));
+
+        // TODO A dynamic_cast fails here, this is suspicious.
+        const auto &range_map =
+          static_cast<const Epetra_Map &>(graph->RangeMap());
+        nonlocal_graph->FillComplete(*column_space_map, range_map);
         nonlocal_graph->OptimizeStorage();
         Epetra_Export exporter(nonlocal_graph->RowMap(), graph->RowMap());
         ierr = graph->Export(*nonlocal_graph, exporter, Add);
         AssertThrow(ierr == 0, ExcTrilinosError(ierr));
-        ierr = graph->FillComplete(*column_space_map,
-                                   static_cast<const Epetra_Map &>(
-                                     graph->RangeMap()));
+        ierr = graph->FillComplete(*column_space_map, range_map);
         AssertThrow(ierr == 0, ExcTrilinosError(ierr));
       }
     else
       {
-        ierr = graph->GlobalAssemble(*column_space_map,
-                                     static_cast<const Epetra_Map &>(
-                                       graph->RangeMap()),
-                                     true);
+        // TODO A dynamic_cast fails here, this is suspicious.
+        const auto &range_map =
+          static_cast<const Epetra_Map &>(graph->RangeMap());
+        ierr = graph->GlobalAssemble(*column_space_map, range_map, true);
         AssertThrow(ierr == 0, ExcTrilinosError(ierr));
       }
 
@@ -881,8 +882,9 @@ namespace TrilinosWrappers
             TrilinosWrappers::types::int_type *el_find =
               std::find(col_indices, col_indices + nnz_present, trilinos_j);
 
-            TrilinosWrappers::types::int_type local_col_index =
-              (TrilinosWrappers::types::int_type)(el_find - col_indices);
+            const auto &local_col_index =
+              static_cast<TrilinosWrappers::types::int_type>(el_find -
+                                                             col_indices);
 
             if (local_col_index == nnz_present)
               return false;
@@ -912,7 +914,7 @@ namespace TrilinosWrappers
                                      col_indices + nnz_present,
                                      static_cast<int>(trilinos_j));
 
-            int local_col_index = (int)(el_find - col_indices);
+            const int local_col_index = static_cast<int>(el_find - col_indices);
 
             if (local_col_index == nnz_present)
               return false;
@@ -929,12 +931,13 @@ namespace TrilinosWrappers
   {
     size_type                         local_b  = 0;
     TrilinosWrappers::types::int_type global_b = 0;
-    for (int i = 0; i < (int)local_size(); ++i)
+    for (int i = 0; i < static_cast<int>(local_size()); ++i)
       {
         int *indices;
         int  num_entries;
         graph->ExtractMyRowView(i, num_entries, indices);
-        for (unsigned int j = 0; j < (unsigned int)num_entries; ++j)
+        for (unsigned int j = 0; j < static_cast<unsigned int>(num_entries);
+             ++j)
           {
             if (static_cast<size_type>(
                   std::abs(static_cast<TrilinosWrappers::types::int_type>(
@@ -943,7 +946,8 @@ namespace TrilinosWrappers
                 static_cast<TrilinosWrappers::types::int_type>(i - indices[j]));
           }
       }
-    graph->Comm().MaxAll((TrilinosWrappers::types::int_type *)&local_b,
+    graph->Comm().MaxAll(reinterpret_cast<TrilinosWrappers::types::int_type *>(
+                           &local_b),
                          &global_b,
                          1);
     return static_cast<size_type>(global_b);
@@ -1039,7 +1043,10 @@ namespace TrilinosWrappers
   const Epetra_Map &
   SparsityPattern::domain_partitioner() const
   {
-    return static_cast<const Epetra_Map &>(graph->DomainMap());
+    // TODO A dynamic_cast fails here, this is suspicious.
+    const auto &domain_map =
+      static_cast<const Epetra_Map &>(graph->DomainMap());
+    return domain_map;
   }
 
 
@@ -1047,7 +1054,9 @@ namespace TrilinosWrappers
   const Epetra_Map &
   SparsityPattern::range_partitioner() const
   {
-    return static_cast<const Epetra_Map &>(graph->RangeMap());
+    // TODO A dynamic_cast fails here, this is suspicious.
+    const auto &range_map = static_cast<const Epetra_Map &>(graph->RangeMap());
+    return range_map;
   }
 
 
@@ -1055,7 +1064,9 @@ namespace TrilinosWrappers
   const Epetra_Map &
   SparsityPattern::row_partitioner() const
   {
-    return static_cast<const Epetra_Map &>(graph->RowMap());
+    // TODO A dynamic_cast fails here, this is suspicious.
+    const auto &row_map = static_cast<const Epetra_Map &>(graph->RowMap());
+    return row_map;
   }
 
 
@@ -1063,7 +1074,9 @@ namespace TrilinosWrappers
   const Epetra_Map &
   SparsityPattern::col_partitioner() const
   {
-    return static_cast<const Epetra_Map &>(graph->ColMap());
+    // TODO A dynamic_cast fails here, this is suspicious.
+    const auto &col_map = static_cast<const Epetra_Map &>(graph->ColMap());
+    return col_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.