20 #include "libmesh/petsc_solver_exception.h" 33 "Eigenvalue solves a standard/generalized linear or nonlinear eigenvalue problem");
44 "Whether or not to use a matrix free fashion to form operators. " 45 "If true, shell matrices will be used and meanwhile a preconditioning matrix" 46 "may be formed as well.");
49 "precond_matrix_free",
51 "Whether or not to use a matrix free fashion for forming the preconditioning matrix. " 52 "If true, a shell matrix will be used for preconditioner.");
54 params.
addParam<
bool>(
"constant_matrices",
56 "Whether or not to use constant matrices so that we can use them to form " 57 "residuals on both linear and " 58 "nonlinear iterations");
60 params.
addParam<
bool>(
"precond_matrix_includes_eigen",
62 "Whether or not to include eigen kernels in the preconditioning matrix. " 63 "If true, the preconditioning matrix will include eigen kernels.");
67 params.
addParam<
Real>(
"initial_eigenvalue", 1,
"Initial eigenvalue");
69 "normalization",
"Postprocessor evaluating norm of eigenvector for normalization");
71 "Normalize eigenvector to make a defined norm equal to this factor");
73 params.
addParam<
bool>(
"auto_initialization",
75 "If true, we will set an initial eigen vector in moose, otherwise EPS " 76 "solver will initial eigen vector");
79 "precond_matrix_includes_eigen",
80 "Matrix and Matrix-Free");
82 "Eigenvector and eigenvalue initialization");
89 #ifdef LIBMESH_HAVE_SLEPC 100 "_eigen_problem",
"This might happen if you don't have a mesh")),
101 _feproblem_solve(*this),
102 _normalization(isParamValid(
"normalization") ? &getPostprocessorValue(
"normalization")
104 _system_time(getParam<
Real>(
"time")),
105 _time_step(_eigen_problem.timeStep()),
106 _time(_eigen_problem.time()),
107 _final_timer(registerTimedSection(
"final", 1))
110 #ifdef LIBMESH_HAVE_SLEPC 112 "The Eigenvalue executioner only currently supports a single solver system.");
122 getParam<unsigned int>(
"free_power_iterations");
124 getParam<unsigned int>(
"extra_power_iterations");
128 "Cannot set scaling factor without defining normalization postprocessor.");
135 const auto & normpp = getParam<PostprocessorName>(
"normalization");
148 mooseError(
"SLEPc is required to use Eigenvalue executioner, please use '--download-slepc in " 149 "PETSc configuration'");
153 #if PETSC_RELEASE_LESS_THAN(3, 13, 0) 155 "Please use SLEPc-3.13.0 or higher. Old versions of SLEPc likely produce bad convergence");
169 #ifdef LIBMESH_HAVE_SLEPC 175 const auto & normpp = getParam<PostprocessorName>(
"normalization");
178 mooseError(
"Normalization postprocessor ", normpp,
" requires execute_on = 'linear'");
206 #if PETSC_RELEASE_LESS_THAN(3, 12, 0) 220 LibmeshPetscCall(PetscOptionsPop());
231 mooseError(
"You have specified time kernels in your eigenvalue simulation");
239 #ifdef LIBMESH_HAVE_SLEPC 244 _console <<
"\nCannot recover eigenvalue solves!\nExiting...\n" << std::endl;
265 #ifdef LIBMESH_ENABLE_AMR 269 for (
const auto r_step :
make_range(steps + 1))
271 #endif // LIBMESH_ENABLE_AMR 277 _console <<
"Aborting as solve did not converge" << std::endl;
292 #ifdef LIBMESH_ENABLE_AMR 316 mooseError(
"SLEPc is required for eigenvalue executioner, please use --download-slepc when " 317 "configuring PETSc ");
virtual void preExecute()
Override this for actions that should take place before execution.
void timestepSetup() override
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
Moose::PetscSupport::PetscOptions & getPetscOptions()
Retrieve a writable reference the PETSc options (used by PetscSupport)
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
static InputParameters validParams()
Constructor.
T & getUserObject(const std::string &name, unsigned int tid=0) const
Get the user object by its name.
void precondMatrixIncludesEigenKernels(bool precond_matrix_includes_eigen)
If the preconditioning matrix includes eigen kernels.
void mooseDeprecated(Args &&... args) const
virtual void init() override
Initialize the executioner.
Eigenvalue executioner is used to drive the eigenvalue calculations.
virtual void postExecute()
Method called at the end of the simulation.
void initEigenvector(const Real initial_value)
For nonlinear eigen solver, a good initial value can help convergence.
virtual void computeMarkers()
virtual void execute(const ExecFlagType &exec_type) override
Convenience function for performing execution of MOOSE systems.
const ExecFlagType EXEC_TIMESTEP_END
bool isRestarting() const
Whether or not this is a "restart" calculation.
bool _last_solve_converged
bool & petscOptionsInserted()
If PETSc options are already inserted.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
virtual void advanceState()
Advance all of the state holding vectors / datastructures so that we can move to the next timestep...
virtual bool containsTimeKernel() override
If the system has a kernel that corresponds to a time derivative.
InputParameters getSlepcValidParams(InputParameters ¶ms)
void setNormalization(const PostprocessorName &pp, const Real value=std::numeric_limits< Real >::max())
Set postprocessor and normalization factor 'Postprocessor' is often used to compute an integral of ph...
Moose::EigenProblemType _eigen_problem_type
static InputParameters validParams()
virtual void execute() override
Pure virtual execute function MUST be overridden by children classes.
virtual void checkIntegrity()
Eigenvalue executioner does not allow time kernels.
Eigenvalue(const InputParameters ¶meters)
void slepcSetOptions(EigenProblem &eigen_problem, SolverParams &solver_params, const InputParameters ¶ms)
Push all SLEPc/PETSc options into SLEPc/PETSc side.
void dontAddPetscFlag(const std::string &flag, PetscOptions &petsc_options)
Function to ensure that a particular petsc option is not added to the PetscOptions storage object to ...
const ExecFlagType EXEC_PRE_MULTIAPP_SETUP
virtual void computeIndicators()
virtual void postExecute()
Override this for actions that should take place after execution.
void initialSetup() override
Executioners are objects that do the actual work of solving your problem.
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
MooseApp & _app
The MOOSE application this is associated with.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
const ExecFlagType EXEC_LINEAR
FEProblemSolve _feproblem_solve
inner-most solve object to perform Newton solve with SLEPc
static InputParameters validParams()
registerMooseObject("MooseApp", Eigenvalue)
NonlinearEigenSystem & getNonlinearEigenSystem(const unsigned int nl_sys_num)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
PetscOptions & petscOptionsDatabase()
void prepareSolverOptions()
Prepare right petsc options.
void dontAddNonlinearConvergedReason(FEProblemBase &fe_problem)
Function to ensure that -snes_converged_reason is not added to the PetscOptions storage object to be ...
unsigned int getSteps() const
Pull out the number of steps previously set by calling init()
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
unsigned int _free_power_iterations
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
SolverParams & solverParams(unsigned int solver_sys_num=0)
Get the solver parameters.
const InputParameters & parameters() const
Get the parameters of the object.
void dontAddLinearConvergedReason(FEProblemBase &fe_problem)
Function to ensure that -ksp_converged_reason is not added to the PetscOptions storage object to be l...
void setInitialEigenvalue(const Real initial_eigenvalue)
Set an initial eigenvalue for initial normalization.
void setEigenProblemSolverParams(EigenProblem &eigen_problem, const InputParameters ¶ms)
Retrieve eigen problem params from 'params', and then set these params into SolverParams.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
EigenProblem & _eigen_problem
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
Execute the MultiApps associated with the ExecFlagType.
unsigned int _extra_power_iterations
Problem for solving eigenvalue problems.
void storeSolveType(FEProblemBase &fe_problem, const InputParameters ¶ms)
Set solve type into eigen problem (solverParams)
Adaptivity & adaptivity()
bool isRecovering() const
Whether or not this is a "recover" calculation.
virtual std::size_t numSolverSystems() const override
const ExecFlagType EXEC_FINAL
void setEigenproblemType(Moose::EigenProblemType eigen_problem_type)
Set eigen problem type.
Base class for user-specific data.
std::unique_ptr< FixedPointSolve > _fixed_point_solve
virtual void outputStep(ExecFlagType type)
Output the current step.
InputParameters getSlepcEigenProblemValidParams()
Retrieve valid params that allow users to specify eigen problem configuration.
FEProblemBase & _fe_problem
const ExecFlagType EXEC_INITIAL