Skip to content

Commit

Permalink
Merge pull request #16410 from bangerth/trilinos-5
Browse files Browse the repository at this point in the history
Unify if-else branches with common code.
  • Loading branch information
peterrum committed Jan 3, 2024
2 parents 0290cf9 + 0c5d311 commit ab40d37
Showing 1 changed file with 28 additions and 46 deletions.
74 changes: 28 additions & 46 deletions source/lac/trilinos_sparsity_pattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,58 +412,40 @@ namespace TrilinosWrappers

std::vector<TrilinosWrappers::types::int_type> 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 =
Expand Down

0 comments on commit ab40d37

Please sign in to comment.