https://mooseframework.inl.gov
NumNonlinearIterations.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 "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 
28  // Not supported
29  params.suppressParameter<bool>("use_displaced_mesh");
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 void
56 {
59  else
61 }
62 
63 Real
65 {
66  return _num_iters;
67 }
virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const
Definition: SubProblem.C:760
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)
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...
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:208
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:215
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1159
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 optional parameter and a documentation string to the InputParameters object...
virtual Real getValue() const override
Get the number of nonlinear iterations.