https://mooseframework.inl.gov
SteadyBase.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 // MOOSE includes
11 #include "SteadyBase.h"
12 #include "FEProblem.h"
13 #include "Factory.h"
14 #include "MooseApp.h"
15 #include "NonlinearSystem.h"
16 
17 #include "libmesh/equation_systems.h"
18 
21 {
23  params.addParam<Real>("time", 0.0, "System time");
24  return params;
25 }
26 
28  : Executioner(parameters),
29  _problem(_fe_problem),
30  _system_time(getParam<Real>("time")),
31  _time_step(_problem.timeStep()),
32  _time(_problem.time()),
33  _output_iteration_number(0)
34 {
36 }
37 
38 void
40 {
41  if (_app.isRecovering())
42  {
43  _console << "\nCannot recover steady-state solves of type: " << this->type()
44  << "!\nExiting...\n"
45  << std::endl;
46  _last_solve_converged = true;
47  return;
48  }
49 
50  _time_step = 0;
51  _time = _time_step;
54 
55  preExecute();
56 
58 
59  // first step in any SteadyBase state solve is always 1 (preserving backwards compatibility)
60  _time_step = 1;
61 
62 #ifdef LIBMESH_ENABLE_AMR
63 
64  // Define the refinement loop
65  unsigned int steps = _problem.adaptivity().getSteps();
66  for (unsigned int r_step = 0; r_step <= steps; r_step++)
67  {
68 #endif // LIBMESH_ENABLE_AMR
70 
72 
73  if (!lastSolveConverged())
74  {
75  _console << "Aborting as solve did not converge" << std::endl;
76  break;
77  }
78 
81 
82  // need to keep _time in sync with _time_step to get correct output
83  _time = _time_step;
86 
87 #ifdef LIBMESH_ENABLE_AMR
88  if (r_step != steps)
89  {
91  }
92 
93  _time_step++;
94  }
95 #endif
96 
97  {
98  TIME_SECTION("final", 1, "Executing Final Objects")
103  _time = _time_step;
106  }
107 
108  postExecute();
109 }
void finalizeMultiApps()
virtual void preExecute()
Override this for actions that should take place before execution.
Definition: Executioner.h:73
void timestepSetup() override
bool _last_solve_converged
Flag showing if the last solve converged.
Definition: SteadyBase.h:75
static InputParameters validParams()
Definition: SteadyBase.C:20
virtual void postExecute()
Method called at the end of the simulation.
Real & _time
The current time.
Definition: SteadyBase.h:68
virtual void computeMarkers()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
int & _time_step
The time step index.
Definition: SteadyBase.h:65
const ExecFlagType EXEC_TIMESTEP_END
Definition: Moose.C:34
virtual void advanceState()
Advance all of the state holding vectors / datastructures so that we can move to the next timestep...
Real _system_time
The system time.
Definition: SteadyBase.h:62
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
static InputParameters validParams()
Definition: Executioner.C:26
virtual void execute() override
Pure virtual execute function MUST be overridden by children classes.
Definition: SteadyBase.C:39
virtual void computeIndicators()
virtual void postExecute()
Override this for actions that should take place after execution.
Definition: Executioner.h:78
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:51
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:30
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
Definition: SteadyBase.h:38
FEProblemBase & _problem
Just an alias for now.
Definition: SteadyBase.h:59
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SteadyBase(const InputParameters &parameters)
Constructor.
Definition: SteadyBase.C:27
unsigned int getSteps() const
Pull out the number of steps previously set by calling init()
Definition: Adaptivity.h:105
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...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
Execute the MultiApps associated with the ExecFlagType.
Adaptivity & adaptivity()
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:1802
const ExecFlagType EXEC_FINAL
Definition: Moose.C:44
std::unique_ptr< FixedPointSolve > _fixed_point_solve
Definition: Executioner.h:151
virtual void outputStep(ExecFlagType type)
Output the current step.
virtual bool adaptMesh()
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:28