www.mooseframework.org
NumNonlinearIterations.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "NumNonlinearIterations.h"
16 
17 #include "FEProblem.h"
18 #include "SubProblem.h"
19 
20 template <>
23 {
25  params.addParam<bool>(
26  "accumulate_over_step",
27  false,
28  "When set to true, accumulates to count the total over all Picard iterations for each step");
29  params.addClassDescription("Outputs the number of nonlinear iterations");
30  return params;
31 }
32 
34  : GeneralPostprocessor(parameters),
35  _fe_problem(dynamic_cast<FEProblemBase *>(&_subproblem)),
36  _accumulate_over_step(getParam<bool>("accumulate_over_step")),
37  _num_iters(0),
38  _time(-std::numeric_limits<Real>::max())
39 {
40  if (!_fe_problem)
41  mooseError("Couldn't cast to FEProblemBase");
42 }
43 
44 void
46 {
47  if (_fe_problem->time() != _time)
48  {
49  _num_iters = 0;
50  _time = _fe_problem->time();
51  }
52 }
53 
54 Real
56 {
59  else
61 
62  return _num_iters;
63 }
virtual void timestepSetup() override
Initialization to be done at each timestep.
NumNonlinearIterations(const InputParameters &parameters)
virtual unsigned int nNonlinearIterations()
Definition: SubProblem.C:308
virtual Real & time() const
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.
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:146
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...
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
virtual Real getValue() override
Get the numer of nonlinear iterations.