Skip to content

Commit

Permalink
LS: properly set up KSP debug options for the split system
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-iob committed May 29, 2024
1 parent ef2cf6a commit ee7a287
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/LA/system_solvers_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,33 @@ void SplitSystemSolver::setupSplitKrylovs()
}
}

/*!
* Perform actions before Krylov subspace method setup.
*/
void SplitSystemSolver::preKrylovSetupActions()
{
// Execute base actions
SystemSolver::preKrylovSetupActions();

// Set KSP debug options
if (m_debug) {
int nSplits = getSplitCount();
for (int split = 0; split < nSplits; ++split) {
std::string prefix = "fieldsplit_" + std::to_string(split) + "_";

#if (PETSC_VERSION_MAJOR >= 3 && PETSC_VERSION_MINOR >= 7)
PetscOptionsSetValue(PETSC_NULLPTR, ("-" + prefix + "ksp_monitor_true_residual").c_str(), "");
PetscOptionsSetValue(PETSC_NULLPTR, ("-" + prefix + "ksp_converged_reason").c_str(), "");
PetscOptionsSetValue(PETSC_NULLPTR, ("-" + prefix + "ksp_monitor_singular_value").c_str(), "");
#else
PetscOptionsSetValue(("-" + prefix + "ksp_monitor_true_residual").c_str(), "");
PetscOptionsSetValue(("-" + prefix + "ksp_converged_reason").c_str(), "");
PetscOptionsSetValue(("-" + prefix + "ksp_monitor_singular_value").c_str(), "");
#endif
}
}
}

/*!
* Generate the split permutation.
*
Expand Down
2 changes: 2 additions & 0 deletions src/LA/system_solvers_split.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class SplitSystemSolver : public SystemSolver {
using SystemSolver::setupKrylov;
virtual void setupSplitKrylovs();

void preKrylovSetupActions() override;

void postKSPSolveActions() override;

void initializeKSPOptions() override;
Expand Down

0 comments on commit ee7a287

Please sign in to comment.