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
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));
}
{
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;
{
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;
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
}
inline Vector::size_type
Vector::local_size() const
{
- return (size_type)vector->Map().NumMyElements();
+ return vector->Map().NumMyElements();
}
(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);
}
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"));
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"));
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"));
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"));
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"));
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"));
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"));
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");
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"));
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"));
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");
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"));
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"));
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",
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"));
}
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]),
: 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)
: 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)
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)
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)
, 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)
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)
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)
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
// 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;
}
}
}
- Assert(n_columns <= (TrilinosWrappers::types::int_type)n_cols,
- ExcInternalError());
+ AssertIndexRange(n_columns, n_cols + 1);
}
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);
{
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,
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,
// 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
}
}
- 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)
// 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));
}
// 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(),
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();
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 &&
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));
}
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;
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;
{
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>(
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);
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;
}
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;
}
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;
}
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;
}