Line data Source code
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 "InversePowerMethod.h"
11 : #include "FEProblemBase.h"
12 :
13 : registerMooseObject("MooseApp", InversePowerMethod);
14 :
15 : InputParameters
16 14285 : InversePowerMethod::validParams()
17 : {
18 14285 : InputParameters params = EigenExecutionerBase::validParams();
19 14285 : params.addClassDescription("Inverse power method for eigenvalue problems.");
20 14285 : params.addParam<PostprocessorName>(
21 : "xdiff", "", "To evaluate |x-x_previous| for power iterations");
22 42855 : params.addParam<unsigned int>(
23 28570 : "max_power_iterations", 300, "The maximum number of power iterations");
24 14285 : params.addParam<unsigned int>("min_power_iterations", 1, "Minimum number of power iterations");
25 14285 : params.addParam<Real>("eig_check_tol", 1e-6, "Eigenvalue convergence tolerance");
26 42855 : params.addParam<Real>("sol_check_tol",
27 28570 : std::numeric_limits<Real>::max(),
28 : "Convergence tolerance on |x-x_previous| when provided");
29 14285 : params.set<Real>("l_tol", true) = 1e-2;
30 42855 : params.addParam<bool>(
31 28570 : "Chebyshev_acceleration_on", true, "If Chebyshev acceleration is turned on");
32 14285 : return params;
33 0 : }
34 :
35 10 : InversePowerMethod::InversePowerMethod(const InputParameters & parameters)
36 : : EigenExecutionerBase(parameters),
37 10 : _solution_diff_name(getParam<PostprocessorName>("xdiff")),
38 10 : _min_iter(getParam<unsigned int>("min_power_iterations")),
39 10 : _max_iter(getParam<unsigned int>("max_power_iterations")),
40 10 : _eig_check_tol(getParam<Real>("eig_check_tol")),
41 10 : _sol_check_tol(getParam<Real>("sol_check_tol")),
42 10 : _l_tol(getParam<Real>("l_tol")),
43 20 : _cheb_on(getParam<bool>("Chebyshev_acceleration_on"))
44 : {
45 10 : if (_max_iter < _min_iter)
46 0 : mooseError("max_power_iterations<min_power_iterations!");
47 10 : if (_eig_check_tol < 0.0)
48 0 : mooseError("eig_check_tol<0!");
49 10 : if (_l_tol < 0.0)
50 0 : paramError("l_tol", "l_tol<0!");
51 :
52 10 : mooseInfo(
53 : "'InversePowerMethod' executioner is deprecated in favor of 'Eigenvalue' executioner.\n",
54 : "Few parameters such as 'bx_norm', 'k0', 'xdiff', 'max_power_iterations', "
55 : "'min_power_iterations', 'eig_check_tol', 'sol_check_tol', and 'output_before_normalization' "
56 : "are no longer supported.\n",
57 : "However, 'Eigenvalue' executioner supports more solving options by interfacing SLEPc.\n");
58 10 : }
59 :
60 : void
61 10 : InversePowerMethod::init()
62 : {
63 10 : if (_app.isRecovering())
64 : {
65 0 : _console << "\nCannot recover InversePowerMethod solves!\nExiting...\n" << std::endl;
66 0 : return;
67 : }
68 :
69 10 : EigenExecutionerBase::init();
70 :
71 : // Write the initial.
72 : // Note: We need to tempararily change the system time to make the output system work properly.
73 10 : _problem.timeStep() = 0;
74 10 : Real t = _problem.time();
75 10 : _problem.time() = _problem.timeStep();
76 10 : _problem.outputStep(EXEC_INITIAL);
77 10 : _problem.time() = t;
78 : }
79 :
80 : void
81 10 : InversePowerMethod::execute()
82 : {
83 10 : if (_app.isRecovering())
84 : {
85 0 : _last_solve_converged = true;
86 0 : return;
87 : }
88 :
89 10 : preExecute();
90 :
91 10 : takeStep();
92 :
93 10 : postExecute();
94 : }
95 :
96 : void
97 10 : InversePowerMethod::takeStep()
98 : {
99 : // save the initial guess and mark a new time step
100 10 : _problem.advanceState();
101 :
102 10 : preSolve();
103 : Real initial_res;
104 10 : _last_solve_converged = inversePowerIteration(_min_iter,
105 10 : _max_iter,
106 10 : _l_tol,
107 10 : _cheb_on,
108 10 : _eig_check_tol,
109 : true,
110 : _solution_diff_name,
111 10 : _sol_check_tol,
112 10 : _eigenvalue,
113 : initial_res);
114 10 : postSolve();
115 :
116 10 : if (lastSolveConverged())
117 : {
118 10 : printEigenvalue();
119 10 : _problem.onTimestepEnd();
120 10 : _problem.execute(EXEC_TIMESTEP_END);
121 : }
122 10 : }
|