From: Wolfgang Bangerth Date: Tue, 2 Jan 2024 21:43:08 +0000 (-0700) Subject: Unify if-else branches with common code. X-Git-Tag: relicensing~204^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c5d3111845601bddd4e6162e8d67932b81e5d22;p=dealii.git Unify if-else branches with common code. --- diff --git a/source/lac/trilinos_sparsity_pattern.cc b/source/lac/trilinos_sparsity_pattern.cc index ccf17e785f..3b7bcb23cd 100644 --- a/source/lac/trilinos_sparsity_pattern.cc +++ b/source/lac/trilinos_sparsity_pattern.cc @@ -412,58 +412,40 @@ namespace TrilinosWrappers std::vector row_indices; - // Include possibility to exchange data since DynamicSparsityPattern is - // able to do so - if (exchange_data == false) - for (size_type row = first_row; row < last_row; ++row) - { - const TrilinosWrappers::types::int_type row_length = - sp.row_length(row); - if (row_length == 0) - continue; + for (size_type row = first_row; row < last_row; ++row) + { + const TrilinosWrappers::types::int_type row_length = + sp.row_length(row); + if (row_length == 0) + continue; - row_indices.resize(row_length, -1); - { - typename SparsityPatternType::iterator p = sp.begin(row); - // avoid incrementing p over the end of the current row because - // it is slow for DynamicSparsityPattern in parallel - for (int col = 0; col < row_length;) - { - row_indices[col++] = p->column(); - if (col < row_length) - ++p; - } - } + row_indices.resize(row_length, -1); + { + typename SparsityPatternType::iterator p = sp.begin(row); + // avoid incrementing p over the end of the current row because + // it is slow for DynamicSparsityPattern in parallel + for (int col = 0; col < row_length;) + { + row_indices[col++] = p->column(); + if (col < row_length) + ++p; + } + } + if (exchange_data == false) graph->Epetra_CrsGraph::InsertGlobalIndices(row, row_length, row_indices.data()); - } - else - for (size_type row = 0; row < sp.n_rows(); ++row) - { - const TrilinosWrappers::types::int_type row_length = - sp.row_length(row); - if (row_length == 0) - continue; - - row_indices.resize(row_length, -1); + else { - typename SparsityPatternType::iterator p = sp.begin(row); - // avoid incrementing p over the end of the current row because - // it is slow for DynamicSparsityPattern in parallel - for (int col = 0; col < row_length;) - { - row_indices[col++] = p->column(); - if (col < row_length) - ++p; - } + // Include possibility to exchange data since + // DynamicSparsityPattern is able to do so + const TrilinosWrappers::types::int_type trilinos_row = row; + graph->InsertGlobalIndices(1, + &trilinos_row, + row_length, + row_indices.data()); } - const TrilinosWrappers::types::int_type trilinos_row = row; - graph->InsertGlobalIndices(1, - &trilinos_row, - row_length, - row_indices.data()); - } + } // TODO A dynamic_cast fails here, this is suspicious. const auto &range_map =