Skip to content

Commit

Permalink
Eigenvalue solver (matrix-free) works with old petsc
Browse files Browse the repository at this point in the history
In order to get the best performance, users should use petsc-3.13 or higher

Closes #7398
  • Loading branch information
fdkong committed Mar 26, 2020
1 parent 97349f9 commit f563890
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions framework/src/problems/EigenProblem.C
Expand Up @@ -303,8 +303,10 @@ EigenProblem::solve()
void
EigenProblem::init()
{
#if !PETSC_RELEASE_LESS_THAN(3, 13, 0)
// If matrix_free=true, this set Libmesh to use shell matrices
_nl_eigen->sys().use_shell_matrices(solverParams()._eigen_matrix_free);
#endif

FEProblemBase::init();

Expand Down
3 changes: 2 additions & 1 deletion framework/src/systems/NonlinearEigenSystem.C
Expand Up @@ -39,6 +39,7 @@ assemble_matrix(EquationSystems & es, const std::string & system_name)
EigenSystem & eigen_system = es.get_system<EigenSystem>(system_name);
NonlinearEigenSystem & eigen_nl = p->getNonlinearEigenSystem();

#if !PETSC_RELEASE_LESS_THAN(3, 13, 0)
// If we use shell matrices, we only need to form a preconditioning matrix
if (eigen_system.use_shell_matrices())
{
Expand All @@ -47,7 +48,7 @@ assemble_matrix(EquationSystems & es, const std::string & system_name)
eigen_nl.nonEigenMatrixTag());
return;
}

#endif
// If it is a linear generalized eigenvalue problem,
// we assemble A and B together
if (!p->isNonlinearEigenvalueSolver() && eigen_system.generalized())
Expand Down
6 changes: 3 additions & 3 deletions framework/src/utils/SlepcSupport.C
Expand Up @@ -369,9 +369,9 @@ setEigenSolverOptions(SolverParams & solver_params, const InputParameters & para
#else
mooseError("Nonlinear Inverse Power requires SLEPc 3.7.3 or higher");
#endif
break;


case Moose::EST_NEWTON:
case Moose::EST_NEWTON:
#if !SLEPC_VERSION_LESS_THAN(3, 8, 0) || !PETSC_VERSION_RELEASE
Moose::PetscSupport::setSinglePetscOption("-eps_type", "power");
Moose::PetscSupport::setSinglePetscOption("-eps_power_nonlinear", "1");
Expand All @@ -387,7 +387,7 @@ setEigenSolverOptions(SolverParams & solver_params, const InputParameters & para
Moose::PetscSupport::setSinglePetscOption("-init_eps_power_snes_mf_operator", "1");
}
#else
mooseError("Newton-based eigenvalue solver requires SLEPc 3.7.3 or higher");
mooseError("Newton-based eigenvalue solver requires SLEPc 3.7.3 or higher");
#endif
break;
default:
Expand Down
3 changes: 2 additions & 1 deletion test/tests/problems/eigen_problem/ne_coupled_scaled.i
Expand Up @@ -109,7 +109,8 @@

[Executioner]
type = Eigenvalue
solve_type = MF_MONOLITH_NEWTON
solve_type = NEWTON
matrix_free = true
eigen_problem_type = GEN_NON_HERMITIAN

# Postprocessor value to normalize
Expand Down

0 comments on commit f563890

Please sign in to comment.