diff --git a/framework/src/utils/PetscSupport.C b/framework/src/utils/PetscSupport.C index 8a3e8325c14f..0cc2d8816f17 100644 --- a/framework/src/utils/PetscSupport.C +++ b/framework/src/utils/PetscSupport.C @@ -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 @@ -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);