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 14287 : InversePowerMethod::validParams()
17 : {
18 14287 : InputParameters params = EigenExecutionerBase::validParams();
19 14287 : params.addClassDescription("Inverse power method for eigenvalue problems.");
20 14287 : params.addParam<PostprocessorName>(
21 : "xdiff", "", "To evaluate |x-x_previous| for power iterations");
22 42861 : params.addParam<unsigned int>(
23 28574 : "max_power_iterations", 300, "The maximum number of power iterations");
24 14287 : params.addParam<unsigned int>("min_power_iterations", 1, "Minimum number of power iterations");
25 14287 : params.addParam<Real>("eig_check_tol", 1e-6, "Eigenvalue convergence tolerance");
26 42861 : params.addParam<Real>("sol_check_tol",
27 28574 : std::numeric_limits<Real>::max(),
28 : "Convergence tolerance on |x-x_previous| when provided");
29 14287 : params.set<Real>("l_tol", true) = 1e-2;
30 42861 : params.addParam<bool>(
31 28574 : "Chebyshev_acceleration_on", true, "If Chebyshev acceleration is turned on");
32 14287 : return params;
33 0 : }
34 :
35 11 : InversePowerMethod::InversePowerMethod(const InputParameters & parameters)
36 : : EigenExecutionerBase(parameters),
37 11 : _solution_diff_name(getParam<PostprocessorName>("xdiff")),
38 11 : _min_iter(getParam<unsigned int>("min_power_iterations")),
39 11 : _max_iter(getParam<unsigned int>("max_power_iterations")),
40 11 : _eig_check_tol(getParam<Real>("eig_check_tol")),
41 11 : _sol_check_tol(getParam<Real>("sol_check_tol")),
42 11 : _l_tol(getParam<Real>("l_tol")),
43 22 : _cheb_on(getParam<bool>("Chebyshev_acceleration_on"))
44 : {
45 11 : if (_max_iter < _min_iter)
46 0 : mooseError("max_power_iterations<min_power_iterations!");
47 11 : if (_eig_check_tol < 0.0)
48 0 : mooseError("eig_check_tol<0!");
49 11 : if (_l_tol < 0.0)
50 0 : paramError("l_tol", "l_tol<0!");
51 :
52 11 : 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 11 : }
59 :
60 : void
61 11 : InversePowerMethod::init()
62 : {
63 11 : if (_app.isRecovering())
64 : {
65 0 : _console << "\nCannot recover InversePowerMethod solves!\nExiting...\n" << std::endl;
66 0 : return;
67 : }
68 :
69 11 : 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 11 : _problem.timeStep() = 0;
74 11 : Real t = _problem.time();
75 11 : _problem.time() = _problem.timeStep();
76 11 : _problem.outputStep(EXEC_INITIAL);
77 11 : _problem.time() = t;
78 : }
79 :
80 : void
81 11 : InversePowerMethod::execute()
82 : {
83 11 : if (_app.isRecovering())
84 : {
85 0 : _last_solve_converged = true;
86 0 : return;
87 : }
88 :
89 11 : preExecute();
90 :
91 11 : takeStep();
92 :
93 11 : postExecute();
94 : }
95 :
96 : void
97 11 : InversePowerMethod::takeStep()
98 : {
99 : // save the initial guess and mark a new time step
100 11 : _problem.advanceState();
101 :
102 11 : preSolve();
103 : Real initial_res;
104 11 : _last_solve_converged = inversePowerIteration(_min_iter,
105 11 : _max_iter,
106 11 : _l_tol,
107 11 : _cheb_on,
108 11 : _eig_check_tol,
109 : true,
110 : _solution_diff_name,
111 11 : _sol_check_tol,
112 11 : _eigenvalue,
113 : initial_res);
114 11 : postSolve();
115 :
116 11 : if (lastSolveConverged())
117 : {
118 11 : printEigenvalue();
119 11 : _problem.onTimestepEnd();
120 11 : _problem.execute(EXEC_TIMESTEP_END);
121 : }
122 11 : }
|