www.mooseframework.org
NonlinearEigen.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "NonlinearEigen.h"
11 
13 
16 {
18  params.addParam<unsigned int>("free_power_iterations", 4, "The number of free power iterations");
19  params.set<Real>("nl_abs_tol", true) = 1.0e-06;
20  params.set<Real>("nl_rel_tol", true) = 1e-50;
21  params.set<Real>("l_tol", true) = 1e-2;
22  params.addParam<Real>("free_l_tol", 1e-2, "Relative linear tolerance in free power iteration");
23  params.addParam<bool>(
24  "output_after_power_iterations", true, "True to output solution after free power iterations");
25  return params;
26 }
27 
29  : EigenExecutionerBase(parameters),
30  _free_iter(getParam<unsigned int>("free_power_iterations")),
31  _nl_abs_tol(getParam<Real>("nl_abs_tol")),
32  _nl_rel_tol(getParam<Real>("nl_rel_tol")),
33  _l_tol(getParam<Real>("l_tol")),
34  _free_l_tol(getParam<Real>("free_l_tol")),
35  _output_after_pi(getParam<bool>("output_after_power_iterations"))
36 {
37  mooseInfo(
38  "'NonlinearEigen' executioner is deprecated in favor of 'Eigenvalue' executioner.\n",
39  "Few parameters such as 'bx_norm', 'k0', 'free_l_tol', 'output_before_normalization' and "
40  "'output_after_power_iterations' are no longer supported.\n",
41  "However, 'Eigenvalue' executioner supports more solving options by interfacing SLEPc.\n",
42  "Most of the inputs will work by simply replacing the executioner type with 'Eigenvalue'.");
43 }
44 
45 void
47 {
48  if (_app.isRecovering())
49  {
50  _console << "\nCannot recover NonlinearEigen solves!\nExiting...\n" << std::endl;
51  return;
52  }
53 
55 
56  // Write the initial.
57  // Note: We need to tempararily change the system time to make the output system work properly.
58  _problem.timeStep() = 0;
59  Real t = _problem.time();
62  _problem.time() = t;
63 
64  if (_free_iter > 0)
65  {
66  // save the initial guess
68 
69  // free power iterations
70  _console << " Free power iteration starts" << std::endl;
71 
72  Real initial_res;
74  _free_iter,
76  false,
78  true,
79  "",
82  initial_res);
83 
86 
87  if (_output_after_pi)
88  {
89  // output initial guess created by free power iterations
90  _problem.timeStep()++;
91  Real t = _problem.time();
94  _problem.time() = t;
95  }
96  }
97 }
98 
99 void
101 {
102  if (_app.isRecovering())
103  return;
104 
105  preExecute();
106 
107  takeStep();
108 
109  postExecute();
110 }
111 
112 void
114 {
115  _console << " Nonlinear iteration starts" << std::endl;
116 
117  preSolve();
121 
123  postSolve();
124 
125  if (lastSolveConverged())
126  {
127  printEigenvalue();
128 
131  }
132 }
const unsigned int & _free_iter
virtual void preExecute()
Override this for actions that should take place before execution.
Definition: Executioner.h:73
void timestepSetup() override
registerMooseObject("MooseApp", NonlinearEigen)
virtual Real & time() const
static InputParameters validParams()
virtual void init() override
Initialize the executioner.
const Real & _free_l_tol
void mooseInfo(Args &&... args) const
virtual void preSolve()
Override this for actions that should take place before execution, called by PicardSolve.
Definition: Executioner.h:83
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
virtual void takeStep()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void onTimestepEnd() override
const ExecFlagType EXEC_TIMESTEP_END
Definition: Moose.C:32
PostprocessorValue & _eigenvalue
Storage for the eigenvalue computed by the executioner.
NonlinearEigen(const InputParameters &parameters)
auto max(const L &left, const R &right)
virtual void advanceState()
Advance all of the state holding vectors / datastructures so that we can move to the next timestep...
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
virtual void execute() override
Pure virtual execute function MUST be overridden by children classes.
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition: Moose.C:33
This class provides reusable routines for eigenvalue executioners.
virtual bool nonlinearSolve(Real rel_tol, Real abs_tol, Real pfactor, Real &k)
Perform nonlinear solve with the initial guess of the solution.
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:69
virtual int & timeStep() const
const Real & _l_tol
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void postSolve()
Override this for actions that should take place after execution, called by PicardSolve.
Definition: Executioner.h:88
const Real & _nl_abs_tol
virtual void printEigenvalue()
Print eigenvalue.
static InputParameters validParams()
Constructor.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
bool _last_solve_converged
const Real & _nl_rel_tol
virtual void postExecute() override
Override this for actions that should take place after the main solve.
virtual void init() override
Initialize the executioner.
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:1167
auto min(const L &left, const R &right)
void ErrorVector unsigned int
virtual void outputStep(ExecFlagType type)
Output the current step.
virtual bool inversePowerIteration(unsigned int min_iter, unsigned int max_iter, Real pfactor, bool cheb_on, Real tol_eig, bool echo, PostprocessorName xdiff, Real tol_x, Real &k, Real &initial_res)
Perform inverse power iterations with the initial guess of the solution.
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:28