Skip to content

Commit

Permalink
Add missing prefix argument to PetscNonlinearSolver::snes
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayad committed Nov 22, 2024
1 parent 9f8f61c commit 5eeb127
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion framework/src/utils/PetscSupport.C
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,9 @@ petscSetKSPDefaults(FEProblemBase & problem, KSP ksp)
void
petscSetDefaults(FEProblemBase & problem)
{
// We care about both nonlinear and linear systems when setting the SNES prefix because
// SNESSetOptionsPrefix will also set its KSP prefix which could compete with linear system KSPs
const auto num_solver_sys = problem.numSolverSystems();
for (auto nl_index : make_range(problem.numNonlinearSystems()))
{
// dig out PETSc solver
Expand All @@ -443,7 +446,14 @@ petscSetDefaults(FEProblemBase & problem)
(problem.getNonlinearSystemNames()[nl_index] + "_").c_str()));
LibmeshPetscCall2(nl.comm(), MatSetFromOptions(petsc_sys_matrix->mat()));
}
SNES snes = petsc_solver->snes();
const char * snes_prefix = nullptr;
std::string snes_prefix_str;
if (num_solver_sys > 1)
{
snes_prefix_str = nl.name() + "_";
snes_prefix = snes_prefix_str.c_str();
}
SNES snes = petsc_solver->snes(snes_prefix);
KSP ksp;
auto ierr = SNESGetKSP(snes, &ksp);
CHKERRABORT(nl.comm().get(), ierr);
Expand Down

0 comments on commit 5eeb127

Please sign in to comment.