29 params.
addRequiredParam<PostprocessorName>(
"bx_norm",
"To evaluate |Bx| for the eigenvalue");
30 params.
addParam<PostprocessorName>(
"normalization",
"To evaluate |x| for normalization");
31 params.
addParam<Real>(
"normal_factor",
"Normalize x to make |x| equal to this factor");
33 "output_before_normalization",
true,
"True to output a step before normalization");
34 params.
addParam<
bool>(
"auto_initialization",
true,
"True to ask the solver to set initial");
35 params.
addParam<Real>(
"time", 0.0,
"System time");
43 params.
addParam<Real>(
"k0", 1.0,
"Initial guess of the eigenvalue");
58 _problem(_fe_problem),
59 _eigen_sys(cast_ref<
MooseEigenSystem &>(_problem.getNonlinearSystemBase(0))),
60 _feproblem_solve(*this),
61 _eigenvalue(addAttributeReporter(
"eigenvalue", getParam<Real>(
"k0"))),
62 _source_integral(getPostprocessorValue(
"bx_norm")),
63 _source_integral_old(1),
64 _normalization(isParamValid(
"normalization")
65 ? getPostprocessorValue(
"normalization")
66 : getPostprocessorValue(
"bx_norm"))
75 Real system_time = getParam<Real>(
"time");
93 if (getParam<bool>(
"auto_initialization"))
106 mooseError(
"Postprocessor " + getParam<PostprocessorName>(
"bx_norm") +
107 " requires execute_on = 'linear'");
138 Real consistency_tolerance = 1e-10;
145 while (std::fabs(k -
_source_integral) > consistency_tolerance * std::fabs(k))
151 std::stringstream ss;
153 _console <<
"\n|Bx| = " << ss.str() << std::endl;
162 mooseError(
"You have specified time kernels in your steady state eigenvalue simulation");
164 mooseError(
"You have not specified any eigen kernels in your eigenvalue simulation");
169 unsigned int max_iter,
174 PostprocessorName xdiff,
179 mooseAssert(max_iter >= min_iter,
180 "Maximum number of power iterations must be greater than or equal to its minimum");
181 mooseAssert(l_rtol > 0.0,
"Invaid linear convergence tolerance");
182 mooseAssert(tol_eig > 0.0,
"Invalid eigenvalue tolerance");
183 mooseAssert(tol_x > 0.0,
"Invalid solution norm tolerance");
192 mooseError(
"Postprocessor " + xdiff +
" requires execute_on = 'linear'");
211 const Real l_tol_bak = es_params.get<Real>(
"linear solver tolerance");
212 const auto nl_max_its_bak =
213 eigen_sys_params.get<
unsigned int>(
"nonlinear solver maximum iterations");
214 const auto nl_rel_tol_bak =
215 eigen_sys_params.get<Real>(
"nonlinear solver relative residual tolerance");
219 es_params.set<Real>(
"linear solver tolerance") = l_rtol;
226 _console <<
" Power iterations starts\n";
227 _console <<
" ________________________________________________________________________________ "
234 std::vector<Real> keff_history;
235 std::vector<Real> diff_history;
239 unsigned int iter = 0;
247 _console <<
" Power iteration= " << iter << std::endl;
285 keff_history.push_back(k);
287 diff_history.push_back(*solution_diff);
289 std::stringstream ss;
293 ss <<
" +================+=====================+=====================+\n";
294 ss <<
" | iteration | eigenvalue | solution_difference |\n";
295 ss <<
" +================+=====================+=====================+\n";
297 if (keff_history.size() > 10)
300 j = keff_history.size() - 10;
302 for (; j < keff_history.size(); j++)
303 ss <<
" | " << std::setw(14) << j <<
" | " << std::setw(19) << std::scientific
304 << std::setprecision(8) << keff_history[j] <<
" | " << std::setw(19) << std::scientific
305 << std::setprecision(8) << diff_history[j] <<
" |\n";
306 ss <<
" +================+=====================+=====================+\n" << std::flush;
311 ss <<
" +================+=====================+\n";
312 ss <<
" | iteration | eigenvalue |\n";
313 ss <<
" +================+=====================+\n";
315 if (keff_history.size() > 10)
318 j = keff_history.size() - 10;
320 for (; j < keff_history.size(); j++)
321 ss <<
" | " << std::setw(14) << j <<
" | " << std::setw(19) << std::scientific
322 << std::setprecision(8) << keff_history[j] <<
" |\n";
323 ss <<
" +================+=====================+\n" << std::flush;
334 chebyshev(chebyshev_parameters, iter, solution_diff);
336 _console <<
" Chebyshev step: " << chebyshev_parameters.
icheb << std::endl;
341 <<
" ________________________________________________________________________________ "
345 if (iter >= min_iter)
348 if (iter != max_iter)
350 Real keff_error = fabs(k_old - k) / k;
351 if (keff_error > tol_eig)
354 if (*solution_diff > tol_x)
368 es_params.set<Real>(
"linear solver tolerance") = l_tol_bak;
393 if (getParam<bool>(
"output_before_normalization"))
405 _console <<
" Cannot let the normalization postprocessor on custom.\n";
406 _console <<
" Normalization is abandoned!" << std::endl;
412 if (!MooseUtils::absoluteFuzzyEqual(s, 1.0))
413 _console <<
" Solution is rescaled with factor " << s <<
" for normalization!" << std::endl;
416 if ((!getParam<bool>(
"output_before_normalization")) || !MooseUtils::absoluteFuzzyEqual(s, 1.0))
426 TIME_SECTION(
"final", 1,
"Executing Final Objects")
441 factor = getParam<Real>(
"normal_factor");
446 if (!MooseUtils::absoluteFuzzyEqual(scaling, 1.0))
461 std::ostringstream ss;
463 ss <<
"*******************************************************\n";
464 ss <<
" Eigenvalue = " << std::fixed << std::setprecision(10) <<
_eigenvalue <<
'\n';
465 ss <<
"*******************************************************";
471 : n_iter(50), fsmooth(2), finit(6), lgac(0), icheb(0), flux_error_norm_old(1), icho(0)
481 flux_error_norm_old = 1;
491 mooseError(
"solution diff is required for Chebyshev acceleration");
493 if (chebyshev_parameters.
lgac == 0)
495 if (chebyshev_parameters.
icho == 0)
500 chebyshev_parameters.
icho = 0;
503 if (iter > chebyshev_parameters.
finit && chebyshev_parameters.
ratio >= 0.4 &&
504 chebyshev_parameters.
ratio <= 1)
506 chebyshev_parameters.
lgac = 1;
507 chebyshev_parameters.
icheb = 1;
510 double alp = 2 / (2 - chebyshev_parameters.
ratio);
511 std::vector<double> coef(2);
521 chebyshev_parameters.
icheb++;
522 double gamma = acosh(2 / chebyshev_parameters.
ratio - 1);
523 double alp = 4 / chebyshev_parameters.
ratio *
524 std::cosh((chebyshev_parameters.
icheb - 1) * gamma) /
525 std::cosh(chebyshev_parameters.
icheb * gamma);
526 double beta = (1 - chebyshev_parameters.
ratio / 2) * alp - 1;
538 (*solution_diff / chebyshev_parameters.
error_begin) *
539 (std::cosh((chebyshev_parameters.
icheb - 1) * acosh(2 / chebyshev_parameters.
ratio - 1)));
544 chebyshev_parameters.
ratio / 2 *
545 (std::cosh(acosh(gamma_new) / (chebyshev_parameters.
icheb - 1)) + 1);
546 if (gamma_new > 1.01)
548 chebyshev_parameters.
lgac = 0;
552 if (chebyshev_parameters.
icheb > 0)
554 chebyshev_parameters.
icho = 1;
555 chebyshev_parameters.
finit = iter;
559 chebyshev_parameters.
icho = 0;
560 chebyshev_parameters.
finit = iter + chebyshev_parameters.
fsmooth;
565 std::vector<double> coef(3);
567 coef[1] = 1 - alp + beta;
589 const Real l_tol_bak = es_params.get<Real>(
"linear solver tolerance");
590 const Real nl_abs_tol_bak =
591 eigen_sys_params.get<Real>(
"nonlinear solver absolute residual tolerance");
592 const Real nl_rel_tol_bak =
593 eigen_sys_params.get<Real>(
"nonlinear solver relative residual tolerance");
595 es_params.set<Real>(
"linear solver tolerance") = l_rtol;
606 es_params.set<Real>(
"linear solver tolerance") = l_tol_bak;
619 return nl_convergence;
621 mooseError(
"EigenExecutionerBase requires 'nonlinear_convergence' to be of type "
622 "DefaultNonlinearConvergence.");
Real PostprocessorValue
various MOOSE typedefs
const ExecFlagType EXEC_TIMESTEP_END
const ExecFlagType EXEC_CUSTOM
const ExecFlagType EXEC_INITIAL
const ExecFlagType EXEC_LINEAR
const ExecFlagType EXEC_FINAL
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
Default nonlinear convergence criteria for FEProblem.
void setMaximumIterations(const unsigned int max_iter)
Sets the maximum nonlinear iterations.
void setRelativeTolerance(const Real rel_tol)
Sets the relative nonlinear tolerance.
void setAbsoluteTolerance(const Real abs_tol)
Sets the absolute nonlinear tolerance.
double flux_error_norm_old
const unsigned int fsmooth
virtual void postExecute() override
Override this for actions that should take place after the main solve.
const Real & _normalization
Postprocessor for normalization.
const Real & _source_integral
DefaultNonlinearConvergence * getEigenSystemConvergence()
Gets the Convergence object for _eigen_sys and checks it's the right type.
virtual Real normalizeSolution(bool force=true)
Normalize the solution vector based on the postprocessor value for normalization.
virtual void preIteration()
Override this for actions that should take place before linear solve of each inverse power iteration.
virtual void checkIntegrity()
Make sure time kernel is not presented.
MooseEigenSystem & _eigen_sys
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.
Real _source_integral_old
EigenExecutionerBase(const InputParameters ¶meters)
const Real & eigenvalueOld()
The old eigenvalue used by inverse power iterations.
PostprocessorValue & _eigenvalue
Storage for the eigenvalue computed by the executioner.
void chebyshev(Chebyshev_Parameters ¶ms, unsigned int iter, const PostprocessorValue *solution_diff)
virtual void printEigenvalue()
Print eigenvalue.
virtual void makeBXConsistent(Real k)
Normalize solution so that |Bx| = k.
virtual void postIteration()
Override this for actions that should take place after linear solve of each inverse power iteration.
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.
DefaultNonlinearConvergence * _eigen_sys_conv
Convergence object corresponding to _eigen_sys.
virtual void init() override
Initialize the executioner.
A MultiMooseEnum object to hold "execute_on" flags.
const std::set< ExecFlagType > & items() const
Reference the all the available items.
Executioners are objects that do the actual work of solving your problem.
static InputParameters validParams()
FEProblemBase & _fe_problem
virtual void onTimestepEnd() override
T & getUserObject(const std::string &name, unsigned int tid=0) const
Get the user object by its name.
virtual libMesh::EquationSystems & es() override
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 std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
virtual void restoreOldSolutions()
Restore old solutions from the backup vectors and deallocate them.
virtual Real & dt() const
virtual void transient(bool trans)
virtual void solve(const unsigned int nl_sys_num)
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
Execute the MultiApps associated with the ExecFlagType.
virtual Real & timeOld() const
virtual void saveOldSolutions()
Allocate vectors and save old solutions into them.
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
virtual Real & time() const
virtual int & timeStep() const
void initialSetup() override
virtual void outputStep(ExecFlagType type)
Output the current step.
static InputParameters validParams()
void setStartTime(Real time)
Set the starting time for the simulation.
const ExecFlagEnum & getExecuteOnEnum() const
Return the app level ExecFlagEnum, this contains all the available flags for the app.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
void eigenKernelOnOld()
Ask eigenkernels to operate on old or current solution vectors.
void eigenKernelOnCurrent()
void initSystemSolutionOld(SYSTEMTAG tag, Real v)
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 containsEigenKernel() const
Weather or not the system contains eigen kernels.
void combineSystemSolution(SYSTEMTAG tag, const std::vector< Real > &coefficients)
Linear combination of the solution vectors.
void scaleSystemSolution(SYSTEMTAG tag, Real scaling_factor)
Scale the solution vector.
Class for containing MooseEnum item information.
MooseApp & _app
The MOOSE application this is associated with.
bool isValueSet(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
Real referenceResidual() const
The reference residual used in relative convergence check.
Convergence & convergence()
Retrieves the associated Convergence object.
virtual bool containsTimeKernel() override
If the system has a kernel that corresponds to a time derivative.
virtual libMesh::System & system() override
Get the reference to the libMesh system.
virtual bool converged(const unsigned int sys_num)
Eventually we want to convert this virtual over to taking a solver system number argument.
unsigned int number() const
Gets the number of this system.
void advanceStateHistory(Moose::SolutionIterationType iteration_type)
Advance solution vectors and additional system-owned state together.
virtual void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time, libMesh::ParallelType parallel_type=GHOSTED)
Registers that the solution state state is needed.
Base class for user-specific data.