https://mooseframework.inl.gov
Loading...
Searching...
No Matches
DefaultSteadyStateConvergence.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
11#include "FEProblemBase.h"
12#include "TransientBase.h"
13#include "AuxiliarySystem.h"
15
17
20{
23
25 "Default convergence criteria for steady-state detection in a transient simulation.");
26
27 return params;
28}
29
31 : DefaultConvergenceBase(parameters),
32
33 _steady_state_tolerance(getSharedExecutionerParam<Real>("steady_state_tolerance")),
34 _check_aux(getSharedExecutionerParam<bool>("check_aux")),
35 _normalize_norm_by_dt(getSharedExecutionerParam<bool>("normalize_solution_diff_norm_by_dt")),
36
37 _fe_problem(*getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
38 _transient_executioner(dynamic_cast<TransientBase * const>(getMooseApp().getExecutioner())),
39 _aux_system(_fe_problem.getAuxiliarySystem())
40{
42 mooseError("DefaultSteadyStateConvergence can only be used for Executioners derived from "
43 "TransientBase.");
44}
45
46void
48{
50
52 mooseError("DefaultSteadyStateConvergence can only be used with steady-state detection.");
53}
54
57{
58 TIME_SECTION(_perfid_check_convergence);
59
60 Real norm = 0.0;
61 if (_check_aux)
62 {
63 std::vector<Number> aux_var_diff_norms;
65 for (auto & aux_var_diff_norm : aux_var_diff_norms)
66 aux_var_diff_norm /= (_normalize_norm_by_dt ? _fe_problem.dt() : Real(1));
67
68 norm = *std::max_element(aux_var_diff_norms.begin(), aux_var_diff_norms.end());
69 }
70 else
72
73 _console << "Steady-State Relative Differential Norm: " << norm << std::endl;
74
75 if (norm < _steady_state_tolerance)
77 else
79}
registerMooseObject("MooseApp", DefaultSteadyStateConvergence)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
void variableWiseRelativeSolutionDifferenceNorm(std::vector< Number > &var_diffs) const
Computes and stores ||current - old|| / ||current|| for each variable in the given vector.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
PerfID _perfid_check_convergence
Performance ID for checkConvergence.
Definition Convergence.h:80
MooseConvergenceStatus
Status returned by calls to checkConvergence.
Definition Convergence.h:34
virtual void checkIterationType(IterationType) const
Perform checks related to the iteration type.
Definition Convergence.h:48
Base class for default convergence criteria.
static InputParameters validParams()
Default convergence criteria for steady-state detection in a transient simulation.
TransientBase *const _transient_executioner
Transient executioner.
const bool _check_aux
Whether to use the auxiliary system solution to determine steady-state.
AuxiliarySystem & _aux_system
Aux system.
DefaultSteadyStateConvergence(const InputParameters &parameters)
virtual MooseConvergenceStatus checkConvergence(unsigned int n_iter) override
Returns convergence status.
virtual void checkIterationType(IterationType it_type) const override
Perform checks related to the iteration type.
const Real _steady_state_tolerance
Steady-state tolerance for the solution variables or aux variables.
const bool _normalize_norm_by_dt
Whether to normalize solution norm by time step size.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual Real & dt() const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Class for containing MooseEnum item information.
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
static InputParameters defaultSteadyStateConvergenceParams()
Real computeSolutionChangeNorm(bool check_aux, bool normalize_by_dt) const
Compute the relative L2 norm of the change in the solution.