geodynamics / aspect

A parallel, extensible finite element code to simulate convection in both 2D and 3D models.
https://aspect.geodynamics.org/
Other
227 stars 237 forks source link

Do we *need* to always compute eigenvalues in SolverCG? #6074

Closed bangerth closed 1 month ago

bangerth commented 1 month ago

A recent report on the ASPECT forum (https://community.geodynamics.org/t/issues-with-block-gmg-solver-scheme/3703) shows that SolverCG now requires LAPACK. That surprised me, and it turns out that it is because we are always computing the eigenvalue approximations:

template <typename VectorType>
DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector<VectorType>)
inline void SolverCG<VectorType>::compute_eigs_and_cond(
  const std::vector<typename VectorType::value_type> &diagonal,
  const std::vector<typename VectorType::value_type> &offdiagonal,
  const boost::signals2::signal<void(const std::vector<double> &)>
                                              &eigenvalues_signal,
  const boost::signals2::signal<void(double)> &cond_signal)
{
  // Avoid computing eigenvalues unless they are needed.
  if (!cond_signal.empty() || !eigenvalues_signal.empty())                // ******************* apparently there are signals attached
    {
      TridiagonalMatrix<typename VectorType::value_type> T(diagonal.size(),
                                                           true);
      for (size_type i = 0; i < diagonal.size(); ++i)
        {
          T(i, i) = diagonal[i];
          if (i < diagonal.size() - 1)
            T(i, i + 1) = offdiagonal[i];
        }
      T.compute_eigenvalues();                                 // ***************** triggers call to LAPACK

      [...]

But I can't seem to find in ASPECT or deal.II where we are actually attaching signals that are monitoring the eigenvalues or condition number. Where is this place, and is this on purpose?

tjhei commented 1 month ago

But I can't seem to find in ASPECT or deal.II where we are actually attaching signals that are monitoring the eigenvalues or condition number. Where is this place, and is this on purpose?

Yes, we need eigenvalue estimates for the Chebyshev smoother for GMG: https://github.com/geodynamics/aspect/blob/69b3924b343b717ac0e3bbca4d48f7fb044e1a22/source/simulator/stokes_matrix_free.cc#L1799

bangerth commented 1 month ago

I see -- I just didn't seem to find the right place to look this up. Thanks for the feedback!