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 
16 
17 template <>
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 Real
53 {
56  else
58 
59  return _num_iters;
60 }
virtual unsigned int nNonlinearIterations() const
Definition: SubProblem.C:570
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.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< GeneralPostprocessor >()
Real _time
Stores the last time this was executed.
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
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.
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:138
InputParameters validParams< NumNonlinearIterations >()
FEProblemBase * _fe_problem
Pointer to the FEProblemBase.
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)
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() override
Get the numer of nonlinear iterations.