www.mooseframework.org
Executioner.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 "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 += PicardSolve::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  params.registerBase("Executioner");
46 
47  params.addParamNamesToGroup("fixed_point_algorithm", "Fixed point iterations");
48  params.addParamNamesToGroup("restart_file_base", "Restart");
49 
50  return params;
51 }
52 
54  : MooseObject(parameters),
55  Reporter(this),
56  ReporterInterface(this),
57  UserObjectInterface(this),
59  Restartable(this, "Executioners"),
60  PerfGraphInterface(this),
61  _fe_problem(*getCheckedPointerParam<FEProblemBase *>(
62  "_fe_problem_base", "This might happen if you don't have a mesh")),
63  _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")),
64  _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")),
65  _verbose(getParam<bool>("verbose"))
66 {
67  for (const auto i : make_range(_fe_problem.numNonlinearSystems()))
69 
70  if (!_restart_file_base.empty())
72 
73  // Instantiate the SolveObject for the fixed point iteration algorithm
74  if (_iteration_method == "picard")
75  _fixed_point_solve = std::make_unique<PicardSolve>(*this);
76  else if (_iteration_method == "secant")
77  _fixed_point_solve = std::make_unique<SecantSolve>(*this);
78  else if (_iteration_method == "steffensen")
79  _fixed_point_solve = std::make_unique<SteffensenSolve>(*this);
80 
81  // Propagate the verbosity down to the problem
82  if (_verbose)
84 }
85 
86 Executioner::Executioner(const InputParameters & parameters, bool)
87  : MooseObject(parameters),
88  Reporter(this),
89  ReporterInterface(this),
90  UserObjectInterface(this),
92  Restartable(this, "Executioners"),
93  PerfGraphInterface(this),
94  _fe_problem(*getCheckedPointerParam<FEProblemBase *>(
95  "_fe_problem_base", "This might happen if you don't have a mesh")),
96  _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")),
97  _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")),
98  _verbose(getParam<bool>("verbose"))
99 {
100  if (!_restart_file_base.empty())
102 }
103 
104 Problem &
106 {
107  mooseDoOnce(mooseWarning("This method is deprecated, use feProblem() instead"));
108  return _fe_problem;
109 }
110 
113 {
114  return _fe_problem;
115 }
116 
118 Executioner::addAttributeReporter(const std::string & name, Real initial_value)
119 {
120  // Get a reference to the value
121  PostprocessorValue & value = declareValueByName<PostprocessorValue>(name, initial_value);
122 
123  // Create storage for the old/older values
124  ReporterName r_name(this->name(), name);
125  getReporterValueByName<PostprocessorValue>(r_name, 1);
126  getReporterValueByName<PostprocessorValue>(r_name, 2);
127 
128  return value;
129 }
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:118
static InputParameters validParams()
Definition: PicardSolve.C:19
static MooseEnum iterationMethods()
Return supported iteration methods that can work with MultiApps on timestep_begin and timestep_end...
Definition: Executioner.h:154
A class for creating restricted objects.
Definition: Restartable.h:28
Executioner(const InputParameters &parameters)
Constructor.
Definition: Executioner.C:53
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
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:112
const bool & _verbose
True if printing out additional information.
Definition: Executioner.h:175
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:129
MooseEnum _iteration_method
Definition: Executioner.h:168
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:56
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
std::string _restart_file_base
Definition: Executioner.h:172
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:33
Interface to allow object to consume Reporter values.
Real PostprocessorValue
various MOOSE typedefs
Definition: MooseTypes.h:191
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
virtual Problem & problem()
Deprecated: Return a reference to this Executioner&#39;s Problem instance.
Definition: Executioner.C:105
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
Interface for objects that need to use UserObjects.
Interface for objects interacting with the PerfGraph.
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 option parameter and a documentation string to the InputParameters object...
static InputParameters validParams()
Definition: MooseObject.C:24
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:169
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:166
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...