]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid a few static_casts for readability
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 1 Dec 2018 15:33:23 +0000 (16:33 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 1 Dec 2018 16:26:23 +0000 (17:26 +0100)
source/lac/trilinos_sparse_matrix.cc
source/lac/trilinos_sparsity_pattern.cc
source/lac/trilinos_vector.cc

index b9bb3bbed93d10f9d9a5d1c11b410fa97f3d454d..3b5683449a93867b2de1ed3c0c3d1e05a29a7e1c 100644 (file)
@@ -143,7 +143,7 @@ namespace TrilinosWrappers
         }
 
       int ierr = matrix->trilinos_matrix().ExtractGlobalRowCopy(
-        static_cast<TrilinosWrappers::types::int_type>(this->a_row),
+        this->a_row,
         colnums,
         ncols,
         &((*value_cache)[0]),
@@ -1859,14 +1859,12 @@ namespace TrilinosWrappers
             &nonlocal_matrix->Graph() :
             &matrix->Graph();
 
-        indices.resize(graph->NumGlobalIndices(
-          static_cast<TrilinosWrappers::types::int_type>(row)));
+        indices.resize(graph->NumGlobalIndices(row));
         int n_indices = 0;
-        graph->ExtractGlobalRowCopy(
-          static_cast<TrilinosWrappers::types::int_type>(row),
-          indices.size(),
-          n_indices,
-          indices.data());
+        graph->ExtractGlobalRowCopy(row,
+                                    indices.size(),
+                                    n_indices,
+                                    indices.data());
         AssertDimension(n_indices, indices.size());
 
         for (TrilinosWrappers::types::int_type i = 0; i < n_indices; ++i)
index 8883e5194545b937de0e214a640d1beea3a8c2bd..8da0186abf68def65a68ee25a3d9fff61c3a655d 100644 (file)
@@ -56,7 +56,7 @@ namespace TrilinosWrappers
           // get a representation of the present row
           int       ncols;
           const int ierr = sparsity_pattern->graph->ExtractGlobalRowCopy(
-            static_cast<TrilinosWrappers::types::int_type>(this->a_row),
+            this->a_row,
             colnum_cache->size(),
             ncols,
             reinterpret_cast<TrilinosWrappers::types::int_type *>(
@@ -795,8 +795,7 @@ namespace TrilinosWrappers
           {
             // insert dummy element
             TrilinosWrappers::types::int_type row =
-              nonlocal_graph->RowMap().MyGID(
-                static_cast<TrilinosWrappers::types::int_type>(0));
+              nonlocal_graph->RowMap().MyGID(0);
             nonlocal_graph->InsertGlobalIndices(row, 1, &row);
           }
         Assert(nonlocal_graph->RowMap().NumMyElements() == 0 ||
@@ -869,10 +868,9 @@ namespace TrilinosWrappers
             // TODO: trilinos_i is the local row index -> it is an int but
             // ExtractGlobalRowView requires trilinos_i to be the global row
             // index and thus it should be a long long int
-            int ierr = graph->ExtractGlobalRowView(
-              static_cast<TrilinosWrappers::types::int_type>(trilinos_i),
-              nnz_extracted,
-              col_indices);
+            int ierr = graph->ExtractGlobalRowView(trilinos_i,
+                                                   nnz_extracted,
+                                                   col_indices);
             (void)ierr;
             Assert(ierr == 0, ExcTrilinosError(ierr));
             Assert(nnz_present == nnz_extracted,
@@ -882,9 +880,8 @@ namespace TrilinosWrappers
             TrilinosWrappers::types::int_type *el_find =
               std::find(col_indices, col_indices + nnz_present, trilinos_j);
 
-            const auto &local_col_index =
-              static_cast<TrilinosWrappers::types::int_type>(el_find -
-                                                             col_indices);
+            const TrilinosWrappers::types::int_type local_col_index =
+              el_find - col_indices;
 
             if (local_col_index == nnz_present)
               return false;
@@ -893,8 +890,7 @@ namespace TrilinosWrappers
           {
             // Prepare pointers for extraction
             // of a view of the row.
-            int nnz_present = graph->NumGlobalIndices(
-              static_cast<TrilinosWrappers::types::int_type>(i));
+            int  nnz_present = graph->NumGlobalIndices(i);
             int  nnz_extracted;
             int *col_indices;
 
@@ -939,11 +935,8 @@ namespace TrilinosWrappers
         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>(
-                    i - indices[j]))) > local_b)
-              local_b = std::abs(
-                static_cast<TrilinosWrappers::types::int_type>(i - indices[j]));
+            if (static_cast<size_type>(std::abs(i - indices[j])) > local_b)
+              local_b = std::abs(i - indices[j]);
           }
       }
     graph->Comm().MaxAll(reinterpret_cast<TrilinosWrappers::types::int_type *>(
index 7d084d7634e69c8ffc03747884e135aba17a885a..dd96f6d021263226d4970c81ab81114e375b5237 100644 (file)
@@ -827,8 +827,7 @@ namespace TrilinosWrappers
       if (size() != local_size())
         {
           auto global_id = [&](const size_type index) {
-            return gid(vector->Map(),
-                       static_cast<TrilinosWrappers::types::int_type>(index));
+            return gid(vector->Map(), index);
           };
           out << "size:" << size() << " local_size:" << local_size() << " :"
               << std::endl;

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.