From 40f35c556bd4e4cfb44d7729b21d10a65917de7a Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sat, 1 Dec 2018 16:33:23 +0100 Subject: [PATCH] Avoid a few static_casts for readability --- source/lac/trilinos_sparse_matrix.cc | 14 ++++++------- source/lac/trilinos_sparsity_pattern.cc | 27 +++++++++---------------- source/lac/trilinos_vector.cc | 3 +-- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index b9bb3bbed9..3b5683449a 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -143,7 +143,7 @@ namespace TrilinosWrappers } int ierr = matrix->trilinos_matrix().ExtractGlobalRowCopy( - static_cast(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(row))); + indices.resize(graph->NumGlobalIndices(row)); int n_indices = 0; - graph->ExtractGlobalRowCopy( - static_cast(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) diff --git a/source/lac/trilinos_sparsity_pattern.cc b/source/lac/trilinos_sparsity_pattern.cc index 8883e51945..8da0186abf 100644 --- a/source/lac/trilinos_sparsity_pattern.cc +++ b/source/lac/trilinos_sparsity_pattern.cc @@ -56,7 +56,7 @@ namespace TrilinosWrappers // get a representation of the present row int ncols; const int ierr = sparsity_pattern->graph->ExtractGlobalRowCopy( - static_cast(this->a_row), + this->a_row, colnum_cache->size(), ncols, reinterpret_cast( @@ -795,8 +795,7 @@ namespace TrilinosWrappers { // insert dummy element TrilinosWrappers::types::int_type row = - nonlocal_graph->RowMap().MyGID( - static_cast(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(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(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(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(num_entries); ++j) { - if (static_cast( - std::abs(static_cast( - i - indices[j]))) > local_b) - local_b = std::abs( - static_cast(i - indices[j])); + if (static_cast(std::abs(i - indices[j])) > local_b) + local_b = std::abs(i - indices[j]); } } graph->Comm().MaxAll(reinterpret_cast( diff --git a/source/lac/trilinos_vector.cc b/source/lac/trilinos_vector.cc index 7d084d7634..dd96f6d021 100644 --- a/source/lac/trilinos_vector.cc +++ b/source/lac/trilinos_vector.cc @@ -827,8 +827,7 @@ namespace TrilinosWrappers if (size() != local_size()) { auto global_id = [&](const size_type index) { - return gid(vector->Map(), - static_cast(index)); + return gid(vector->Map(), index); }; out << "size:" << size() << " local_size:" << local_size() << " :" << std::endl; -- 2.39.5