Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
DefaultNonlinearConvergence.h
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 
10 #pragma once
11 
12 #include "Convergence.h"
13 #include "MooseApp.h"
14 #include "Executioner.h"
15 
20 {
21 public:
23 
25 
27 
28  virtual void initialSetup() override;
29 
30  virtual MooseConvergenceStatus checkConvergence(unsigned int iter) override;
31 
32 protected:
41  virtual bool checkRelativeConvergence(const unsigned int it,
42  const Real fnorm,
43  const Real ref_norm,
44  const Real rel_tol,
45  const Real abs_tol,
46  std::ostringstream & oss);
47 
51  virtual void nonlinearConvergenceSetup() {}
52 
61  template <typename T>
62  const T & getSharedExecutionerParam(const std::string & name);
63 
74 
75 private:
77  const bool _added_as_default;
78 
80  std::vector<std::string> _duplicate_shared_executioner_params;
81 
82 protected:
91  unsigned int _nl_forced_its;
93  const unsigned int _nl_max_pingpong;
95  unsigned int _nl_current_pingpong;
96 };
97 
98 template <typename T>
99 const T &
101 {
102  const auto * executioner = getMooseApp().getExecutioner();
103  if (executioner->isParamSetByUser(param))
104  {
105  if (isParamSetByUser(param))
106  _duplicate_shared_executioner_params.push_back(param);
107  return executioner->getParam<T>(param);
108  }
109  else
110  return getParam<T>(param);
111 }
virtual void nonlinearConvergenceSetup()
Performs setup necessary for each call to checkConvergence.
const Real _nl_rel_div_tol
Nonlinear relative divergence tolerance.
DefaultNonlinearConvergence(const InputParameters &parameters)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual bool checkRelativeConvergence(const unsigned int it, const Real fnorm, const Real ref_norm, const Real rel_tol, const Real abs_tol, std::ostringstream &oss)
Check the relative convergence of the nonlinear solution.
virtual MooseConvergenceStatus checkConvergence(unsigned int iter) override
Returns convergence status.
const bool _added_as_default
True if this object was added as a default instead of by the user.
const Real _nl_abs_div_tol
Nonlinear absolute divergence tolerance.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition: MooseBase.h:45
static InputParameters residualConvergenceParams()
const unsigned int _nl_max_pingpong
Maximum number of nonlinear ping-pong iterations for a solve.
Base class for convergence criteria.
Definition: Convergence.h:21
void checkDuplicateSetSharedExecutionerParams() const
Throws an error if any of the parameters shared with the executioner have been set by the user in bot...
const T & getSharedExecutionerParam(const std::string &name)
This method is to be used for parameters that are shared with the executioner.
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition: MooseApp.C:1552
MooseConvergenceStatus
Status returned by calls to checkConvergence.
Definition: Convergence.h:33
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
bool isParamSetByUser(const std::string &nm) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int _nl_current_pingpong
Current number of nonlinear ping-pong iterations for the current solve.
unsigned int _nl_forced_its
Number of iterations to force.
std::vector< std::string > _duplicate_shared_executioner_params
List of shared executioner parameters that have been set by the user in both places.
const InputParameters & parameters() const
Get the parameters of the object.
const Real _div_threshold
Divergence threshold value.
Default convergence criteria for FEProblem.