https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NumFailedTimeSteps.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 "NumFailedTimeSteps.h"
11#include "Transient.h"
12
14
17{
19 params.addClassDescription("Collects the number of failed time steps from the time stepper.");
20 params.addParam<bool>("current_time_step_only",
21 false,
22 "Count only the failed solves of the current time step, which is reset "
23 "to zero when a time step converges.");
24 return params;
25}
26
28 : GeneralPostprocessor(parameters),
29 _current_time_step_only(getParam<bool>("current_time_step_only")),
30 _failures_before_step(declareRestartableData<unsigned int>("failures_before_step", 0)),
31 _t_step_counted(declareRestartableData<int>("t_step_counted", -1))
32{
34 {
35 _timestepper = dynamic_cast<TransientBase *>(_app.getExecutioner())->getTimeStepper();
36 if (!_timestepper)
37 mooseError("No user-specified time stepper in Executioner block");
38 }
39 else
40 mooseError("Problem is not transient, and will not calculate timesteps.");
41}
42
43void
45{
46 // A new time step number means the previous step converged
48 {
51 }
52}
53
54Real
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", NumFailedTimeSteps)
void ErrorVector unsigned int
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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.
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition MooseApp.C:2024
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
This postprocessor outputs the amount of failed time steps.
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
const TimeStepper * _timestepper
Retrieves the current TimeStepper used by the executioner.
static InputParameters validParams()
int & _t_step_counted
Time step number at which _failures_before_step was recorded.
unsigned int & _failures_before_step
Number of failures before the current time step.
const bool _current_time_step_only
Whether to count only the failed solves of the current time step.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
NumFailedTimeSteps(const InputParameters &parameters)
virtual bool isTransient() const =0
unsigned int numFailures() const
Gets the number of failures and returns them.
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
int & _t_step
The number of the time step.
SubProblem & _subproblem
Reference to the Subproblem for this user object.