https://mooseframework.inl.gov
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 
24  params.addClassDescription(
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 
46 void
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 
77  else
79 }
const bool _normalize_norm_by_dt
Whether to normalize solution norm by time step size.
const bool _check_aux
Whether to use the auxiliary system solution to determine steady-state.
FEProblemBase & _fe_problem
FE problem.
const Real _steady_state_tolerance
Steady-state tolerance for the solution variables or aux variables.
Real computeSolutionChangeNorm(bool check_aux, bool normalize_by_dt) const
Compute the relative L2 norm of the change in the solution.
Base class for default convergence criteria.
virtual MooseConvergenceStatus checkConvergence(unsigned int n_iter) override
Returns convergence status.
AuxiliarySystem & _aux_system
Aux system.
TransientBase *const _transient_executioner
Transient executioner.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
DefaultSteadyStateConvergence(const InputParameters &parameters)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void checkIterationType(IterationType) const
Perform checks related to the iteration type.
Definition: Convergence.h:48
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
Definition: TransientBase.h:27
MooseConvergenceStatus
Status returned by calls to checkConvergence.
Definition: Convergence.h:33
PerfID _perfid_check_convergence
Performance ID for checkConvergence.
Definition: Convergence.h:80
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
auto norm(const T &a)
Default convergence criteria for steady-state detection in a transient simulation.
static InputParameters defaultSteadyStateConvergenceParams()
Definition: TransientBase.C:42
virtual void checkIterationType(IterationType it_type) const override
Perform checks related to the iteration type.
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...
Definition: MooseBase.h:271
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...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
registerMooseObject("MooseApp", DefaultSteadyStateConvergence)
virtual Real & dt() const
void variableWiseRelativeSolutionDifferenceNorm(std::vector< Number > &var_diffs) const
Computes and stores ||current - old|| / ||current|| for each variable in the given vector...
static InputParameters validParams()