https://mooseframework.inl.gov
Convergence.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 
10 #include "Convergence.h"
11 #include "MooseApp.h"
12 #include "Executioner.h"
13 #include "MooseUtils.h"
14 
17 {
19  params += SetupInterface::validParams();
23 
24  params.addParam<bool>(
25  "verbose",
26  false,
27  "Enable printing of additional information, including convergence and divergence reasons.");
28 
29  params.registerBase("Convergence");
30 
31  // This parameter is present because of SetupInterface, which is a requirement
32  // of MooseObjectWarehouse, but it should not be used.
33  params.suppressParameter<ExecFlagEnum>("execute_on");
34 
35  return params;
36 }
37 
39  : MooseObject(parameters),
40  SetupInterface(this),
42  PerfGraphInterface(this),
43  TransientInterface(this),
44  _perfid_check_convergence(registerTimedSection("checkConvergence", 5, "Checking Convergence")),
45  _tid(getParam<THREAD_ID>("_tid")),
46  _verbose(getParam<bool>("verbose") ? true : getMooseApp().getExecutioner()->verbose())
47 {
48 }
49 
50 void
51 Convergence::verboseOutput(std::ostringstream & oss)
52 {
53  const auto str = oss.str();
54 
55  if (str.length() == 0)
56  return;
57 
58  if (verbose())
59  _console << name() << ": " << MooseUtils::trim(str) << std::endl;
60 }
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
static InputParameters validParams()
void verboseOutput(std::ostringstream &oss)
Outputs the stream to the console if verbose output is enabled.
Definition: Convergence.C:51
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
Interface for objects that needs transient capabilities.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
std::string trim(const std::string &str, const std::string &white_space=" \\\)
Standard scripting language trim function.
static InputParameters validParams()
Interface for objects interacting with the PerfGraph.
static InputParameters validParams()
static InputParameters validParams()
Definition: Convergence.C:16
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
static InputParameters validParams()
Definition: MooseObject.C:25
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
bool verbose() const
Returns whether verbose mode has been enabled.
Definition: Convergence.h:68
Convergence(const InputParameters &parameters)
Definition: Convergence.C:38