https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
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", "MultiApp 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),
65 Restartable(this, "Executioners"),
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
92 : MooseObject(parameters),
93 Reporter(this),
97 Restartable(this, "Executioners"),
99 _fe_problem(*getCheckedPointerParam<FEProblemBase *>(
100 "_fe_problem_base", "This might happen if you don't have a mesh")),
101 _iteration_method(getParam<MooseEnum>("fixed_point_algorithm")),
102 _restart_file_base(getParam<FileNameNoExtension>("restart_file_base")),
103 _verbose(getParam<bool>("verbose"))
104{
105 if (!_restart_file_base.empty())
107
108 if (!getParam<bool>("_supports_test_restep") && _app.testReStep())
109 mooseInfo("This Executioner does not support --test-restep; solve will behave as normal");
110}
111
112Problem &
114{
115 mooseDoOnce(mooseWarning("This method is deprecated, use feProblem() instead"));
116 return _fe_problem;
117}
118
121{
122 return _fe_problem;
123}
124
126Executioner::addAttributeReporter(const std::string & name, Real initial_value)
127{
128 // Get a reference to the value
129 PostprocessorValue & value = declareValueByName<PostprocessorValue>(name, initial_value);
130
131 // Create storage for the old/older values
132 ReporterName r_name(this->name(), name);
133 getReporterValueByName<PostprocessorValue>(r_name, 1);
134 getReporterValueByName<PostprocessorValue>(r_name, 2);
135
136 return value;
137}
Real PostprocessorValue
various MOOSE typedefs
Definition MooseTypes.h:230
Number initial_value(const Point &, const Parameters &, const std::string &, const std::string &)
Executioner(const InputParameters &parameters)
Constructor.
Definition Executioner.C:59
static InputParameters validParams()
Definition Executioner.C:26
virtual Problem & problem()
Deprecated: Return a reference to this Executioner's Problem instance.
FEProblemBase & _fe_problem
virtual PostprocessorValue & addAttributeReporter(const std::string &name, Real initial_value=0)
Adds a postprocessor that the executioner can directly assign values to.
static MooseEnum iterationMethods()
Return supported iteration methods that can work with MultiApps on timestep_begin and timestep_end.
std::unique_ptr< FixedPointSolve > _fixed_point_solve
std::string _restart_file_base
MooseEnum _iteration_method
FEProblemBase & feProblem()
Return a reference to this Executioner's FEProblemBase instance.
const bool & _verbose
True if printing out additional information.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual std::size_t numNonlinearSystems() const override
void setRestartFile(const std::string &file_name)
Communicate to the Resurector the name of the restart filer.
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn't required or valid in the derived class...
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...
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.
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
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 registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
bool testReStep() const
Whether or not this simulation should fail a timestep and repeat (for testing).
Definition MooseApp.h:530
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
void mooseInfo(Args &&... args) const
Definition MooseBase.h:334
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
static InputParameters validParams()
Definition MooseObject.C:25
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
Interface for objects interacting with the PerfGraph.
Interface class for classes which interact with Postprocessors.
Class that hold the whole problem being solved.
Definition Problem.h:20
Interface to allow object to consume Reporter values.
static InputParameters validParams()
The Reporter system is comprised of objects that can contain any number of data values.
Reporter objects allow for the declaration of arbitrary data types that are aggregate values for a si...
Definition Reporter.h:48
static InputParameters validParams()
Definition Reporter.C:16
A class for creating restricted objects.
Definition Restartable.h:29
void mooseWarning(Args &&... args) const
void setVerboseFlag(const bool &verbose)
Sets the verbose flag.
Definition SystemBase.h:135
Interface for objects that need to use UserObjects.