From: David Wells Date: Sun, 30 Dec 2018 15:38:51 +0000 (-0500) Subject: Clean up some casts in the Trilinos wrappers. X-Git-Tag: v9.1.0-rc1~470^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7560%2Fhead;p=dealii.git Clean up some casts in the Trilinos wrappers. Many of the const_casts and integral downcasts are not necessary. --- diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index edce04ddb7..62b73b1c75 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -1529,10 +1529,10 @@ namespace TrilinosWrappers last_action = Insert; - TrilinosWrappers::types::int_type *col_index_ptr; - TrilinosScalar * col_value_ptr; - TrilinosWrappers::types::int_type trilinos_row = row; - TrilinosWrappers::types::int_type n_columns; + const TrilinosWrappers::types::int_type *col_index_ptr; + const TrilinosScalar * col_value_ptr; + const TrilinosWrappers::types::int_type trilinos_row = row; + TrilinosWrappers::types::int_type n_columns; boost::container::small_vector local_value_array( n_cols); @@ -1544,9 +1544,10 @@ namespace TrilinosWrappers // we will not modify const data) if (elide_zero_values == false) { - col_index_ptr = reinterpret_cast( - const_cast(col_indices)); - col_value_ptr = const_cast(values); + col_index_ptr = + reinterpret_cast( + col_indices); + col_value_ptr = values; n_columns = n_cols; } else @@ -1563,8 +1564,8 @@ namespace TrilinosWrappers AssertIsFinite(value); if (value != 0) { - col_index_ptr[n_columns] = col_indices[j]; - col_value_ptr[n_columns] = value; + local_index_array[n_columns] = col_indices[j]; + local_value_array[n_columns] = value; n_columns++; } } @@ -1587,10 +1588,7 @@ namespace TrilinosWrappers if (matrix->Filled() == false) { ierr = matrix->Epetra_CrsMatrix::InsertGlobalValues( - row, - static_cast(n_columns), - const_cast(col_value_ptr), - col_index_ptr); + row, static_cast(n_columns), col_value_ptr, col_index_ptr); // When inserting elements, we do not want to create exceptions in // the case when inserting non-local data (since that's what we @@ -1725,10 +1723,10 @@ namespace TrilinosWrappers last_action = Add; - TrilinosWrappers::types::int_type *col_index_ptr; - TrilinosScalar * col_value_ptr; - TrilinosWrappers::types::int_type trilinos_row = row; - TrilinosWrappers::types::int_type n_columns; + const TrilinosWrappers::types::int_type *col_index_ptr; + const TrilinosScalar * col_value_ptr; + const TrilinosWrappers::types::int_type trilinos_row = row; + TrilinosWrappers::types::int_type n_columns; boost::container::small_vector local_value_array( n_cols); @@ -1740,9 +1738,10 @@ namespace TrilinosWrappers // we will not modify const data) if (elide_zero_values == false) { - col_index_ptr = reinterpret_cast( - const_cast(col_indices)); - col_value_ptr = const_cast(values); + col_index_ptr = + reinterpret_cast( + col_indices); + col_value_ptr = values; n_columns = n_cols; # ifdef DEBUG for (size_type j = 0; j < n_cols; ++j) @@ -1764,9 +1763,9 @@ namespace TrilinosWrappers AssertIsFinite(value); if (value != 0) { - col_index_ptr[n_columns] = col_indices[j]; - col_value_ptr[n_columns] = value; - n_columns++; + local_index_array[n_columns] = col_indices[j]; + local_value_array[n_columns] = value; + ++n_columns; } }