Skip to content

Commit

Permalink
PreconditionChebyshev: reduce number of writes by one
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrum committed Sep 6, 2022
1 parent 978b425 commit 043815f
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions include/deal.II/lac/precondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -2819,7 +2819,9 @@ namespace internal
// + f_2 * P^{-1} * (b-A*x^{n})
DEAL_II_OPENMP_SIMD_PRAGMA
for (std::size_t i = begin; i < end; ++i)
solution_old[i] =
// for efficiency reason, write back to temp_vector that is
// already read (avoid read-for-ownership)
tmp_vector[i] =
factor1_plus_1 * solution[i] - factor1 * solution_old[i] +
factor2 * matrix_diagonal_inverse[i] * (rhs[i] - tmp_vector[i]);
}
Expand Down Expand Up @@ -2892,13 +2894,11 @@ namespace internal
// nothing to do here because we can immediately write into the
// solution vector without remembering any of the other vectors
}
else if (iteration_index == 1)
else
{
solution.swap(temp_vector1);
solution_old.swap(temp_vector1);
}
else
solution.swap(solution_old);
}

// selection for diagonal matrix around parallel deal.II vector
Expand Down Expand Up @@ -2934,13 +2934,11 @@ namespace internal
// nothing to do here because we can immediately write into the
// solution vector without remembering any of the other vectors
}
else if (iteration_index == 1)
else
{
solution.swap(temp_vector1);
solution_old.swap(temp_vector1);
}
else
solution.swap(solution_old);
}

// We need to have a separate declaration for static const members
Expand Down Expand Up @@ -3031,13 +3029,11 @@ namespace internal
// nothing to do here because we can immediately write into the
// solution vector without remembering any of the other vectors
}
else if (iteration_index == 1)
else
{
solution.swap(temp_vector1);
solution_old.swap(temp_vector1);
}
else
solution.swap(solution_old);
}

template <typename MatrixType, typename PreconditionerType>
Expand Down

0 comments on commit 043815f

Please sign in to comment.