www.mooseframework.org
NumNonlinearIterations.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "NumNonlinearIterations.h"
11 
12 #include "FEProblem.h"
13 #include "SubProblem.h"
14 #include "SystemBase.h"
15 
17 
20 {
22  params.addParam<bool>(
23  "accumulate_over_step",
24  false,
25  "When set to true, accumulates to count the total over all Picard iterations for each step");
26  params.addClassDescription("Outputs the number of nonlinear iterations");
27  return params;
28 }
29 
31  : GeneralPostprocessor(parameters),
32  _fe_problem(dynamic_cast<FEProblemBase *>(&_subproblem)),
33  _accumulate_over_step(getParam<bool>("accumulate_over_step")),
34  _num_iters(0),
35  _time(-std::numeric_limits<Real>::max())
36 {
37  if (!_fe_problem)
38  mooseError("Couldn't cast to FEProblemBase");
39 }
40 
41 void
43 {
44  if (_fe_problem->time() != _time)
45  {
46  _num_iters = 0;
47  _time = _fe_problem->time();
48  }
49 }
50 
51 void
53 {
56  else
58 }
59 
60 Real
62 {
63  return _num_iters;
64 }
virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const
Definition: SubProblem.C:718
virtual void timestepSetup() override
Initialization to be done at each timestep.
virtual Real & time() const
NumNonlinearIterations(const InputParameters &parameters)
NumNonlinearIterations is a postprocessor that reports the number of nonlinear iterations.
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Real _time
Stores the last time this was executed.
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
unsigned int _num_iters
Stores the nonlinear iteration count.
auto max(const L &left, const R &right)
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:207
static InputParameters validParams()
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
FEProblemBase * _fe_problem
Pointer to the FEProblemBase.
SystemBase & _sys
Reference to the system object for this user object.
Definition: UserObject.h:214
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1125
bool _accumulate_over_step
True if we should accumulate over all nonlinear solves done as part of Picard iterations in a step...
registerMooseObject("MooseApp", NumNonlinearIterations)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
virtual Real getValue() const override
Get the number of nonlinear iterations.