28 params.
addRequiredParam<PostprocessorName>(
"bx_norm",
"To evaluate |Bx| for the eigenvalue");
29 params.
addParam<PostprocessorName>(
"normalization",
"To evaluate |x| for normalization");
30 params.
addParam<
Real>(
"normal_factor",
"Normalize x to make |x| equal to this factor");
32 "output_before_normalization",
true,
"True to output a step before normalization");
33 params.
addParam<
bool>(
"auto_initialization",
true,
"True to ask the solver to set initial");
42 params.
addParam<
Real>(
"k0", 1.0,
"Initial guess of the eigenvalue");
57 _problem(_fe_problem),
58 _eigen_sys(static_cast<
MooseEigenSystem &>(_problem.getNonlinearSystemBase(0))),
59 _feproblem_solve(*this),
60 _eigenvalue(addAttributeReporter(
"eigenvalue", getParam<
Real>(
"k0"))),
61 _source_integral(getPostprocessorValue(
"bx_norm")),
62 _source_integral_old(1),
63 _normalization(isParamValid(
"normalization")
64 ? getPostprocessorValue(
"normalization")
65 : getPostprocessorValue(
"bx_norm"))
74 Real system_time = getParam<Real>(
"time");
92 if (getParam<bool>(
"auto_initialization"))
105 mooseError(
"Postprocessor " + getParam<PostprocessorName>(
"bx_norm") +
106 " requires execute_on = 'linear'");
135 Real consistency_tolerance = 1e-10;
142 while (std::fabs(k -
_source_integral) > consistency_tolerance * std::fabs(k))
148 std::stringstream ss;
150 _console <<
"\n|Bx| = " << ss.str() << std::endl;
159 mooseError(
"You have specified time kernels in your steady state eigenvalue simulation");
161 mooseError(
"You have not specified any eigen kernels in your eigenvalue simulation");
166 unsigned int max_iter,
171 PostprocessorName xdiff,
176 mooseAssert(max_iter >= min_iter,
177 "Maximum number of power iterations must be greater than or equal to its minimum");
178 mooseAssert(l_rtol > 0.0,
"Invaid linear convergence tolerance");
179 mooseAssert(tol_eig > 0.0,
"Invalid eigenvalue tolerance");
180 mooseAssert(tol_x > 0.0,
"Invalid solution norm tolerance");
189 mooseError(
"Postprocessor " + xdiff +
" requires execute_on = 'linear'");
208 _problem.
es().parameters.get<
unsigned int>(
"nonlinear solver maximum iterations");
209 Real tol2 =
_problem.
es().parameters.get<
Real>(
"nonlinear solver relative residual tolerance");
212 _problem.
es().parameters.set<
Real>(
"linear solver tolerance") = l_rtol;
214 _problem.
es().parameters.set<
unsigned int>(
"nonlinear solver maximum iterations") = 1;
215 _problem.
es().parameters.set<
Real>(
"nonlinear solver relative residual tolerance") = 1 - 1e-8;
220 _console <<
" Power iterations starts\n";
221 _console <<
" ________________________________________________________________________________ " 228 std::vector<Real> keff_history;
229 std::vector<Real> diff_history;
233 unsigned int iter = 0;
241 _console <<
" Power iteration= " << iter << std::endl;
276 keff_history.push_back(k);
278 diff_history.push_back(*solution_diff);
280 std::stringstream ss;
284 ss <<
" +================+=====================+=====================+\n";
285 ss <<
" | iteration | eigenvalue | solution_difference |\n";
286 ss <<
" +================+=====================+=====================+\n";
288 if (keff_history.size() > 10)
291 j = keff_history.size() - 10;
293 for (; j < keff_history.size(); j++)
294 ss <<
" | " << std::setw(14) << j <<
" | " << std::setw(19) << std::scientific
295 << std::setprecision(8) << keff_history[j] <<
" | " << std::setw(19) << std::scientific
296 << std::setprecision(8) << diff_history[j] <<
" |\n";
297 ss <<
" +================+=====================+=====================+\n" << std::flush;
302 ss <<
" +================+=====================+\n";
303 ss <<
" | iteration | eigenvalue |\n";
304 ss <<
" +================+=====================+\n";
306 if (keff_history.size() > 10)
309 j = keff_history.size() - 10;
311 for (; j < keff_history.size(); j++)
312 ss <<
" | " << std::setw(14) << j <<
" | " << std::setw(19) << std::scientific
313 << std::setprecision(8) << keff_history[j] <<
" |\n";
314 ss <<
" +================+=====================+\n" << std::flush;
325 chebyshev(chebyshev_parameters, iter, solution_diff);
327 _console <<
" Chebyshev step: " << chebyshev_parameters.
icheb << std::endl;
332 <<
" ________________________________________________________________________________ " 336 if (iter >= min_iter)
339 if (iter != max_iter)
341 Real keff_error = fabs(k_old - k) / k;
342 if (keff_error > tol_eig)
345 if (*solution_diff > tol_x)
359 _problem.
es().parameters.set<
Real>(
"linear solver tolerance") = tol1;
360 _problem.
es().parameters.set<
unsigned int>(
"nonlinear solver maximum iterations") = num1;
361 _problem.
es().parameters.set<
Real>(
"nonlinear solver relative residual tolerance") = tol2;
384 if (getParam<bool>(
"output_before_normalization"))
396 _console <<
" Cannot let the normalization postprocessor on custom.\n";
397 _console <<
" Normalization is abandoned!" << std::endl;
404 _console <<
" Solution is rescaled with factor " << s <<
" for normalization!" << std::endl;
417 TIME_SECTION(
"final", 1,
"Executing Final Objects")
432 factor = getParam<Real>(
"normal_factor");
452 std::ostringstream ss;
454 ss <<
"*******************************************************\n";
455 ss <<
" Eigenvalue = " << std::fixed << std::setprecision(10) <<
_eigenvalue <<
'\n';
456 ss <<
"*******************************************************";
462 : n_iter(50), fsmooth(2), finit(6), lgac(0), icheb(0), flux_error_norm_old(1), icho(0)
472 flux_error_norm_old = 1;
482 mooseError(
"solution diff is required for Chebyshev acceleration");
484 if (chebyshev_parameters.
lgac == 0)
486 if (chebyshev_parameters.
icho == 0)
491 chebyshev_parameters.
icho = 0;
494 if (iter > chebyshev_parameters.
finit && chebyshev_parameters.
ratio >= 0.4 &&
495 chebyshev_parameters.
ratio <= 1)
497 chebyshev_parameters.
lgac = 1;
498 chebyshev_parameters.
icheb = 1;
501 double alp = 2 / (2 - chebyshev_parameters.
ratio);
502 std::vector<double> coef(2);
512 chebyshev_parameters.
icheb++;
513 double gamma = acosh(2 / chebyshev_parameters.
ratio - 1);
514 double alp = 4 / chebyshev_parameters.
ratio *
517 double beta = (1 - chebyshev_parameters.
ratio / 2) * alp - 1;
529 (*solution_diff / chebyshev_parameters.
error_begin) *
535 chebyshev_parameters.
ratio / 2 *
536 (
std::cosh(acosh(gamma_new) / (chebyshev_parameters.
icheb - 1)) + 1);
537 if (gamma_new > 1.01)
539 chebyshev_parameters.
lgac = 0;
543 if (chebyshev_parameters.
icheb > 0)
545 chebyshev_parameters.
icho = 1;
546 chebyshev_parameters.
finit = iter;
550 chebyshev_parameters.
icho = 0;
551 chebyshev_parameters.
finit = iter + chebyshev_parameters.
fsmooth;
556 std::vector<double> coef(3);
558 coef[1] = 1 - alp + beta;
578 Real tol1 =
_problem.
es().parameters.get<
Real>(
"nonlinear solver absolute residual tolerance");
580 Real tol3 =
_problem.
es().parameters.get<
Real>(
"nonlinear solver relative residual tolerance");
582 _problem.
es().parameters.set<
Real>(
"nonlinear solver absolute residual tolerance") = nl_atol;
583 _problem.
es().parameters.set<
Real>(
"nonlinear solver relative residual tolerance") = nl_rtol;
584 _problem.
es().parameters.set<
Real>(
"linear solver tolerance") = l_rtol;
592 _problem.
es().parameters.set<
Real>(
"nonlinear solver absolute residual tolerance") = tol1;
593 _problem.
es().parameters.set<
Real>(
"linear solver tolerance") = tol2;
594 _problem.
es().parameters.set<
Real>(
"nonlinear solver relative residual tolerance") = tol3;
void scaleSystemSolution(SYSTEMTAG tag, Real scaling_factor)
Scale the solution vector.
virtual void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Registers that the solution state state is needed.
A MultiMooseEnum object to hold "execute_on" flags.
virtual Real & time() const
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
T & getUserObject(const std::string &name, unsigned int tid=0) const
Get the user object by its name.
const ExecFlagType EXEC_CUSTOM
virtual bool converged(const unsigned int nl_sys_num)
Eventually we want to convert this virtual over to taking a nonlinear system number argument...
EigenExecutionerBase(const InputParameters ¶meters)
virtual void copyOldSolutions()
Shifts the solutions backwards in time.
const Real & _source_integral
const ExecFlagEnum & getExecuteOnEnum() const
Return the app level ExecFlagEnum, this contains all the available flags for the app.
Real _source_integral_old
virtual void makeBXConsistent(Real k)
Normalize solution so that |Bx| = k.
double flux_error_norm_old
const Real & eigenvalueOld()
The old eigenvalue used by inverse power iterations.
virtual void onTimestepEnd() override
const ExecFlagType EXEC_TIMESTEP_END
virtual void postIteration()
Override this for actions that should take place after linear solve of each inverse power iteration...
PostprocessorValue & _eigenvalue
Storage for the eigenvalue computed by the executioner.
virtual void checkIntegrity()
Make sure time kernel is not presented.
virtual void solve(const unsigned int nl_sys_num)
Real _initial_residual_before_preset_bcs
virtual EquationSystems & es() override
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
void buildSystemDoFIndices(SYSTEMTAG tag=ALL)
Build DoF indices for a system.
void initSystemSolution(SYSTEMTAG tag, Real v)
Initialize the solution vector with a constant value.
bool contains(const std::string &value) const
Contains methods for seeing if a value is in the MultiMooseEnum.
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
void eigenKernelOnOld()
Ask eigenkernels to operate on old or current solution vectors.
void combineSystemSolution(SYSTEMTAG tag, const std::vector< Real > &coefficients)
Linear combination of the solution vectors.
const std::set< ExecFlagType > & items() const
Reference the all the available items.
static InputParameters validParams()
virtual bool nonlinearSolve(Real rel_tol, Real abs_tol, Real pfactor, Real &k)
Perform nonlinear solve with the initial guess of the solution.
Real PostprocessorValue
various MOOSE typedefs
const ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum for this object.
void initialSetup() override
const unsigned int fsmooth
Executioners are objects that do the actual work of solving your problem.
MooseApp & _app
The MOOSE application this is associated with.
unsigned int number() const
Gets the number of this system.
const ExecFlagType EXEC_LINEAR
static InputParameters validParams()
bool containsTimeKernel()
AuxiliarySystem & getAuxiliarySystem()
const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name, std::size_t t_index=0) const
Get a read-only reference to the value associated with a Postprocessor that exists.
virtual int & timeStep() const
const Real & _normalization
Postprocessor for normalization.
void chebyshev(Chebyshev_Parameters ¶ms, unsigned int iter, const PostprocessorValue *solution_diff)
void eigenKernelOnCurrent()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Class for containing MooseEnum item information.
virtual void restoreOldSolutions()
Restore old solutions from the backup vectors and deallocate them.
bool containsEigenKernel() const
Weather or not the system contains eigen kernels.
MooseEigenSystem & _eigen_sys
virtual void printEigenvalue()
Print eigenvalue.
virtual void transient(bool trans)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
virtual void saveOldSolutions()
Allocate vectors and save old solutions into them.
static InputParameters validParams()
Constructor.
virtual Real & timeOld() const
virtual Real normalizeSolution(bool force=true)
Normalize the solution vector based on the postprocessor value for normalization. ...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
void initSystemSolutionOld(SYSTEMTAG tag, Real v)
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
Execute the MultiApps associated with the ExecFlagType.
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template cosh(_arg) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(cosh
virtual void postExecute() override
Override this for actions that should take place after the main solve.
virtual void init() override
Initialize the executioner.
virtual Real & dt() const
const ExecFlagType EXEC_FINAL
Base class for user-specific data.
virtual void preIteration()
Override this for actions that should take place before linear solve of each inverse power iteration...
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.
void setStartTime(Real time)
Set the starting time for the simulation.
FEProblemBase & _fe_problem
const ExecFlagType EXEC_INITIAL