Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify if-else branches with common code. #16410

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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