From c9074c7b38e19ee54b143661efbe0515bc4eb563 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 31 Dec 2023 18:18:14 -0700 Subject: [PATCH] Deal with IndexSet operations in a more efficient way. --- source/lac/trilinos_sparse_matrix.cc | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index 1d0fec67b2..0a9ce64272 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -664,19 +664,22 @@ namespace TrilinosWrappers std::vector ghost_rows; std::vector n_entries_per_row(row_space_map.NumMyElements()); std::vector n_entries_per_ghost_row; - for (unsigned int i = 0, own = 0; i < n_rows; ++i) - { - const TrilinosWrappers::types::int_type global_row = - relevant_rows.nth_index_in_set(i); - if (row_space_map.MyGID(global_row)) - n_entries_per_row[own++] = sparsity_pattern.row_length(global_row); - else if (sparsity_pattern.row_length(global_row) > 0) - { - ghost_rows.push_back(global_row); - n_entries_per_ghost_row.push_back( - sparsity_pattern.row_length(global_row)); - } - } + { + SparseMatrix::size_type own = 0; + for (const auto global_row : relevant_rows) + { + if (row_space_map.MyGID( + static_cast(global_row))) + n_entries_per_row[own++] = + sparsity_pattern.row_length(global_row); + else if (sparsity_pattern.row_length(global_row) > 0) + { + ghost_rows.push_back(global_row); + n_entries_per_ghost_row.push_back( + sparsity_pattern.row_length(global_row)); + } + } + } Epetra_Map off_processor_map(-1, ghost_rows.size(), -- 2.39.5