https://mooseframework.inl.gov
Executioner.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 "Executioner.h"
12 
13 #include "MooseApp.h"
14 #include "MooseMesh.h"
15 #include "FEProblem.h"
16 #include "NonlinearSystem.h"
17 #include "SlepcSupport.h"
18 #include "SecantSolve.h"
19 #include "SteffensenSolve.h"
20 
21 // C++ includes
22 #include <vector>
23 #include <limits>
24 
27 {
29  params += FixedPointSolve::validParams();
30  params += Reporter::validParams();
32 
33  params.addParam<MooseEnum>("fixed_point_algorithm",
35  "The fixed point algorithm to converge the sequence of problems.");
36 
37  params.addParam<bool>("verbose", false, "Set to true to print additional information");
38 
39  params.addDeprecatedParam<FileNameNoExtension>(
40  "restart_file_base",
41  "",
42  "File base name used for restart",
43  "Please use \"Problem/restart_file_base\" instead");
44 
45  // An executioner should never be disabled
46  params.suppressParameter<bool>("enable");
47 
48  params.registerBase("Executioner");
49 
50  params.addParamNamesToGroup("fixed_point_algorithm", "Fixed point iterations");
51  params.addParamNamesToGroup("restart_file_base", "Restart");
52 
53  // Whether or not this executioner supports --test-restep capability
54  params.addPrivateParam<bool>("_supports_test_restep", false);
55 
56  return params;
57 }
58 
60  : MooseObject(parameters),
61  Reporter(this),
62  ReporterInterface(this),
63  UserObjectInterface(this),
65  Restartable(this, "Executioners"),
66  PerfGraphInterface(this),
67  _fe_problem(*getCheckedPointerParam<FEProblemBase *>(
68  "_fe_problem_base", "This might happen if you don't have a mesh")),
69  _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")),
70  _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")),
71  _verbose(getParam<bool>("verbose"))
72 {
73  for (const auto i : make_range(_fe_problem.numNonlinearSystems()))
75 
76  if (!_restart_file_base.empty())
78 
79  if (!getParam<bool>("_supports_test_restep") && _app.testReStep())
80  mooseInfo("This Executioner does not support --test-restep; solve will behave as normal");
81 
82  // Instantiate the SolveObject for the MultiApp fixed point iteration algorithm
83  if (_iteration_method == "picard")
84  _fixed_point_solve = std::make_unique<PicardSolve>(*this);
85  else if (_iteration_method == "secant")
86  _fixed_point_solve = std::make_unique<SecantSolve>(*this);
87  else if (_iteration_method == "steffensen")
88  _fixed_point_solve = std::make_unique<SteffensenSolve>(*this);
89 
90  // Propagate the verbosity down to the problem
91  if (_verbose)
93 }
94 
95 Executioner::Executioner(const InputParameters & parameters, bool)
96  : MooseObject(parameters),
97  Reporter(this),
98  ReporterInterface(this),
99  UserObjectInterface(this),
101  Restartable(this, "Executioners"),
102  PerfGraphInterface(this),
103  _fe_problem(*getCheckedPointerParam<FEProblemBase *>(
104  "_fe_problem_base", "This might happen if you don't have a mesh")),
105  _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")),
106  _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")),
107  _verbose(getParam<bool>("verbose"))
108 {
109  if (!_restart_file_base.empty())
111 
112  if (!getParam<bool>("_supports_test_restep") && _app.testReStep())
113  mooseInfo("This Executioner does not support --test-restep; solve will behave as normal");
114 }
115 
116 Problem &
118 {
119  mooseDoOnce(mooseWarning("This method is deprecated, use feProblem() instead"));
120  return _fe_problem;
121 }
122 
125 {
126  return _fe_problem;
127 }
128 
130 Executioner::addAttributeReporter(const std::string & name, Real initial_value)
131 {
132  // Get a reference to the value
133  PostprocessorValue & value = declareValueByName<PostprocessorValue>(name, initial_value);
134 
135  // Create storage for the old/older values
136  ReporterName r_name(this->name(), name);
137  getReporterValueByName<PostprocessorValue>(r_name, 1);
138  getReporterValueByName<PostprocessorValue>(r_name, 2);
139 
140  return value;
141 }
virtual PostprocessorValue & addAttributeReporter(const std::string &name, Real initial_value=0)
Adds a postprocessor that the executioner can directly assign values to.
Definition: Executioner.C:130
static MooseEnum iterationMethods()
Return supported iteration methods that can work with MultiApps on timestep_begin and timestep_end...
Definition: Executioner.h:136
A class for creating restricted objects.
Definition: Restartable.h:28
Executioner(const InputParameters &parameters)
Constructor.
Definition: Executioner.C:59
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
static InputParameters validParams()
virtual std::size_t numNonlinearSystems() const override
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
void mooseInfo(Args &&... args) const
Class that hold the whole problem being solved.
Definition: Problem.h:19
FEProblemBase & feProblem()
Return a reference to this Executioner&#39;s FEProblemBase instance.
Definition: Executioner.C:124
const bool & _verbose
True if printing out additional information.
Definition: Executioner.h:157
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void setVerboseFlag(const bool &verbose)
Sets the verbose flag.
Definition: SystemBase.h:134
MooseEnum _iteration_method
Definition: Executioner.h:150
Reporter objects allow for the declaration of arbitrary data types that are aggregate values for a si...
Definition: Reporter.h:47
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
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...
std::string _restart_file_base
Definition: Executioner.h:154
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
static InputParameters validParams()
Definition: Executioner.C:26
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
Interface to allow object to consume Reporter values.
Real PostprocessorValue
various MOOSE typedefs
Definition: MooseTypes.h:202
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
virtual Problem & problem()
Deprecated: Return a reference to this Executioner&#39;s Problem instance.
Definition: Executioner.C:117
bool testReStep() const
Whether or not this simulation should fail a timestep and repeat (for testing).
Definition: MooseApp.h:550
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
Interface for objects that need to use UserObjects.
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
Interface for objects interacting with the PerfGraph.
static InputParameters validParams()
static InputParameters validParams()
Definition: Reporter.C:16
void setRestartFile(const std::string &file_name)
Communicate to the Resurector the name of the restart filer.
IntRange< T > make_range(T beg, T end)
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...
static InputParameters validParams()
Definition: MooseObject.C:25
void setVerboseProblem(bool verbose)
Make the problem be verbose.
Number initial_value(const Point &, const Parameters &, const std::string &, const std::string &)
std::unique_ptr< FixedPointSolve > _fixed_point_solve
Definition: Executioner.h:151
The Reporter system is comprised of objects that can contain any number of data values.
Definition: ReporterName.h:30
Interface class for classes which interact with Postprocessors.
FEProblemBase & _fe_problem
Definition: Executioner.h:148
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...