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([this]() -> Real & { return this->_problem.time() = this->_system_time; }()),
33  _output_iteration_number(0)
34 {
35 }
36 
37 void
39 {
40  if (_app.isRecovering())
41  {
42  _console << "\nCannot recover steady-state solves of type: " << this->type()
43  << "!\nExiting...\n"
44  << std::endl;
45  _last_solve_converged = true;
46  return;
47  }
48 
49  _time_step = 0;
50  _time = _time_step;
53 
54  preExecute();
55 
57 
58  // first step in any SteadyBase state solve is always 1 (preserving backwards compatibility)
59  _time_step = 1;
60 
61 #ifdef LIBMESH_ENABLE_AMR
62 
63  // Define the refinement loop
64  unsigned int steps = _problem.adaptivity().getSteps();
65  for (unsigned int r_step = 0; r_step <= steps; r_step++)
66  {
67 #endif // LIBMESH_ENABLE_AMR
69 
71 
72  if (!lastSolveConverged())
73  {
74  _console << "Aborting as solve did not converge" << std::endl;
75  break;
76  }
77 
80 
81  // need to keep _time in sync with _time_step to get correct output
82  _time = _time_step;
85 
86 #ifdef LIBMESH_ENABLE_AMR
87  if (r_step != steps)
88  {
90  }
91 
92  _time_step++;
93  }
94 #endif
95 
96  {
97  TIME_SECTION("final", 1, "Executing Final Objects")
102  _time = _time_step;
105  }
106 
107  postExecute();
108 }
void finalizeMultiApps()
virtual void preExecute()
Override this for actions that should take place before execution.
Definition: Executioner.h:73
void timestepSetup() override
virtual Real & time() const
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:36
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:38
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:89
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:353
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:1801
const ExecFlagType EXEC_FINAL
Definition: Moose.C:46
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:30