www.mooseframework.org
Steady.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 // MOOSE includes
11 #include "Steady.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 
19 registerMooseObject("MooseApp", Steady);
20 
23 {
25  params.addClassDescription("Executioner for steady-state simulations.");
26  params += FEProblemSolve::validParams();
27  params.addParam<Real>("time", 0.0, "System time");
28  return params;
29 }
30 
31 Steady::Steady(const InputParameters & parameters)
32  : Executioner(parameters),
33  _problem(_fe_problem),
34  _feproblem_solve(*this),
35  _system_time(getParam<Real>("time")),
36  _time_step(_problem.timeStep()),
37  _time(_problem.time()),
38  _output_iteration_number(0)
39 {
40  _fixed_point_solve->setInnerSolve(_feproblem_solve);
41 
43 }
44 
45 void
47 {
51 }
52 
53 void
55 {
56  if (_app.isRecovering())
57  {
58  _console << "\nCannot recover steady solves!\nExiting...\n" << std::endl;
59  return;
60  }
61 
62  _time_step = 0;
63  _time = _time_step;
66 
67  preExecute();
68 
70 
71  // first step in any steady state solve is always 1 (preserving backwards compatibility)
72  _time_step = 1;
73 
74 #ifdef LIBMESH_ENABLE_AMR
75 
76  // Define the refinement loop
77  unsigned int steps = _problem.adaptivity().getSteps();
78  for (unsigned int r_step = 0; r_step <= steps; r_step++)
79  {
80 #endif // LIBMESH_ENABLE_AMR
82 
84 
85  if (!lastSolveConverged())
86  {
87  _console << "Aborting as solve did not converge" << std::endl;
88  break;
89  }
90 
93 
94  // need to keep _time in sync with _time_step to get correct output
95  _time = _time_step;
98 
99 #ifdef LIBMESH_ENABLE_AMR
100  if (r_step != steps)
101  {
103  }
104 
105  _time_step++;
106  }
107 #endif
108 
109  {
110  TIME_SECTION("final", 1, "Executing Final Objects")
115  _time = _time_step;
118  }
119 
120  postExecute();
121 }
122 
123 void
125 {
126  // check to make sure that we don't have any time kernels in this simulation (Steady State)
128  mooseError("You have specified time kernels in your steady state simulation");
129 }
void finalizeMultiApps()
virtual void preExecute()
Override this for actions that should take place before execution.
Definition: Executioner.h:73
void timestepSetup() override
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
Definition: Steady.h:46
bool _last_solve_converged
Definition: Steady.h:78
virtual void postExecute()
Method called at the end of the simulation.
virtual void computeMarkers()
Steady executioners usually only call "solve()" on the NonlinearSystem once.
Definition: Steady.h:27
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const ExecFlagType EXEC_TIMESTEP_END
Definition: Moose.C:32
registerMooseObject("MooseApp", Steady)
virtual void advanceState()
Advance all of the state holding vectors / datastructures so that we can move to the next timestep...
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
FEProblemSolve _feproblem_solve
Definition: Steady.h:68
static InputParameters validParams()
Definition: Executioner.C:26
const ExecFlagType EXEC_PRE_MULTIAPP_SETUP
Definition: Moose.C:46
virtual void computeIndicators()
virtual void postExecute()
Override this for actions that should take place after execution.
Definition: Executioner.h:78
Real & _time
Definition: Steady.h:72
void initialSetup() override
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:30
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:69
int & _time_step
Definition: Steady.h:71
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
Constructor.
Definition: Steady.C:22
unsigned int getSteps() const
Pull out the number of steps previously set by calling init()
Definition: Adaptivity.h:104
FEProblemBase & _problem
Definition: Steady.h:66
virtual void checkIntegrity()
Definition: Steady.C:124
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 option parameter and a documentation string to the InputParameters object...
virtual void execute() override
Pure virtual execute function MUST be overridden by children classes.
Definition: Steady.C:54
virtual void init() override
Initialize the executioner.
Definition: Steady.C:46
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:1167
Steady(const InputParameters &parameters)
Definition: Steady.C:31
const ExecFlagType EXEC_FINAL
Definition: Moose.C:38
std::unique_ptr< FixedPointSolve > _fixed_point_solve
Definition: Executioner.h:169
virtual void outputStep(ExecFlagType type)
Output the current step.
virtual bool adaptMesh()
Real _system_time
Definition: Steady.h:70
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:28