https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NonlinearEigen.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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#include "FEProblemBase.h"
12
14
17{
19 params.addParam<unsigned int>("free_power_iterations", 4, "The number of free power iterations");
20 params.set<Real>("nl_abs_tol", true) = 1.0e-06;
21 params.set<Real>("nl_rel_tol", true) = 1e-50;
22 params.set<Real>("l_tol", true) = 1e-2;
23 params.addParam<Real>("free_l_tol", 1e-2, "Relative linear tolerance in free power iteration");
24 params.addParam<bool>(
25 "output_after_power_iterations", true, "True to output solution after free power iterations");
26 return params;
27}
28
30 : EigenExecutionerBase(parameters),
31 _free_iter(getParam<unsigned int>("free_power_iterations")),
32 _nl_abs_tol(getParam<Real>("nl_abs_tol")),
33 _nl_rel_tol(getParam<Real>("nl_rel_tol")),
34 _l_tol(getParam<Real>("l_tol")),
35 _free_l_tol(getParam<Real>("free_l_tol")),
36 _output_after_pi(getParam<bool>("output_after_power_iterations"))
37{
39 "'NonlinearEigen' executioner is deprecated in favor of 'Eigenvalue' executioner.\n",
40 "Few parameters such as 'bx_norm', 'k0', 'free_l_tol', 'output_before_normalization' and "
41 "'output_after_power_iterations' are no longer supported.\n",
42 "However, 'Eigenvalue' executioner supports more solving options by interfacing SLEPc.\n",
43 "Most of the inputs will work by simply replacing the executioner type with 'Eigenvalue'.");
44}
45
46void
48{
49 if (_app.isRecovering())
50 {
51 _console << "\nCannot recover NonlinearEigen solves!\nExiting...\n" << std::endl;
52 return;
53 }
54
56
57 // Write the initial.
58 // Note: We need to tempararily change the system time to make the output system work properly.
59 _problem.timeStep() = 0;
60 Real t = _problem.time();
63 _problem.time() = t;
64
65 if (_free_iter > 0)
66 {
67 // save the initial guess
69
70 // free power iterations
71 _console << " Free power iteration starts" << std::endl;
72
73 Real initial_res;
77 false,
78 std::numeric_limits<Real>::min(),
79 true,
80 "",
81 std::numeric_limits<Real>::max(),
83 initial_res);
84
87
89 {
90 // output initial guess created by free power iterations
92 Real t = _problem.time();
95 _problem.time() = t;
96 }
97 }
98}
99
100void
102{
103 if (_app.isRecovering())
104 {
106 return;
107 }
108
109 preExecute();
110
111 takeStep();
112
113 postExecute();
114}
115
116void
void mooseInfo(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
Definition MooseError.h:401
const ExecFlagType EXEC_TIMESTEP_END
Definition Moose.C:36
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition Moose.C:37
const ExecFlagType EXEC_INITIAL
Definition Moose.C:30
registerMooseObject("MooseApp", NonlinearEigen)
void ErrorVector unsigned int
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
This class provides reusable routines for eigenvalue executioners.
virtual void postExecute() override
Override this for actions that should take place after the main solve.
static InputParameters validParams()
Constructor.
virtual bool nonlinearSolve(Real rel_tol, Real abs_tol, Real pfactor, Real &k)
Perform nonlinear solve with the initial guess of the solution.
PostprocessorValue & _eigenvalue
Storage for the eigenvalue computed by the executioner.
virtual void printEigenvalue()
Print eigenvalue.
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.
virtual void init() override
Initialize the executioner.
virtual void preExecute()
Override this for actions that should take place before execution.
Definition Executioner.h:73
virtual void postSolve()
Override this for actions that should take place after execution, called by FixedPointSolve.
Definition Executioner.h:88
virtual void preSolve()
Override this for actions that should take place before execution, called by FixedPointSolve.
Definition Executioner.h:83
virtual void onTimestepEnd() override
virtual void advanceState()
Advance all of the state holding vectors / datastructures so that we can move to the next timestep.
void timestepSetup() override
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
virtual Real & time() const
virtual int & timeStep() const
virtual void outputStep(ExecFlagType type)
Output the current step.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition MooseApp.C:1669
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
NonlinearEigen(const InputParameters &parameters)
const unsigned int & _free_iter
virtual void execute() override
Pure virtual execute function MUST be overridden by children classes.
static InputParameters validParams()
virtual void takeStep()
virtual void init() override
Initialize the executioner.
const Real & _nl_rel_tol
const Real & _free_l_tol
const Real & _l_tol
const Real & _nl_abs_tol