A Control object for receiving data from a master application Sampler object.
More...
#include <MultiAppCommandLineControl.h>
|
| MultiAppCommandLineControl (const InputParameters ¶meters) |
|
virtual void | initialSetup () override final |
| Do not allow the use of initialSetup, because this class is designed to operate on PRE_MULTIAPP_SETUP, which occurs before this callback. More...
|
|
virtual void | execute () override |
|
|
std::shared_ptr< MultiApp > | _multi_app |
| The MultiApp this Transfer is transferring data to or from. More...
|
|
Sampler & | _sampler |
| Sampler to utilize for creating MultiApps. More...
|
|
const std::vector< std::string > & | _param_names |
| Storage for the parameter names to be applied. More...
|
|
A Control object for receiving data from a master application Sampler object.
Definition at line 29 of file MultiAppCommandLineControl.h.
◆ MultiAppCommandLineControl()
MultiAppCommandLineControl::MultiAppCommandLineControl |
( |
const InputParameters & |
parameters | ) |
|
Definition at line 42 of file MultiAppCommandLineControl.C.
43 : Control(parameters),
44 SamplerInterface(
this),
45 _multi_app(_fe_problem.getMultiApp(getParam<MultiAppName>(
"multi_app"))),
46 _sampler(SamplerInterface::getSampler(
"sampler")),
47 _param_names(getParam<std::vector<std::string>>(
"param_names"))
49 if (!
_sampler.getParamTempl<ExecFlagEnum>(
"execute_on").contains(EXEC_PRE_MULTIAPP_SETUP))
52 "The sampler object, '",
54 "', is being used by the '",
56 "' object, thus the 'execute_on' of the sampler must include 'PRE_MULTIAPP_SETUP'.");
58 bool batch_reset =
_multi_app->isParamValid(
"mode") &&
59 (
_multi_app->getParamTempl<MooseEnum>(
"mode") ==
"batch-reset");
60 bool batch_restore =
_multi_app->isParamValid(
"mode") &&
61 (
_multi_app->getParamTempl<MooseEnum>(
"mode") ==
"batch-restore");
65 else if (batch_restore)
68 "The MultiApp object, '",
70 "', supplied to the '",
72 "' object is setup to run in 'batch-restore' mode, when using this mode command line "
73 "arguments cannot be modified; batch-reset mode should be used instead.");
76 mooseError(
"The number of sub apps (",
78 ") created by MultiApp object '",
80 "' must be equal to the number for rows (",
◆ execute()
void MultiAppCommandLineControl::execute |
( |
| ) |
|
|
overridevirtual |
Definition at line 95 of file MultiAppCommandLineControl.C.
97 std::vector<std::string> cli_args;
100 paramError(
"param_names",
101 "The number of columns (",
103 ") must match the number of parameters (",
111 if (std::dynamic_pointer_cast<SamplerFullSolveMultiApp>(
_multi_app) ==
nullptr)
113 for (dof_id_type row =
_sampler.getLocalRowBegin(); row <
_sampler.getLocalRowEnd(); ++row)
115 std::vector<Real> data =
_sampler.getNextLocalRow();
116 std::ostringstream oss;
117 for (std::size_t col = 0; col < data.size(); ++col)
121 oss <<
_param_names[col] <<
"=" << Moose::stringify(data[col]);
124 cli_args.push_back(oss.str());
129 std::ostringstream oss;
130 for (dof_id_type col = 0; col <
_sampler.getNumberOfCols(); ++col)
137 cli_args.push_back(oss.str());
140 setControllableValueByName<std::vector<std::string>>(
141 "MultiApp",
_multi_app->name(),
"cli_args", cli_args);
◆ initialSetup()
void MultiAppCommandLineControl::initialSetup |
( |
| ) |
|
|
finaloverridevirtual |
Do not allow the use of initialSetup, because this class is designed to operate on PRE_MULTIAPP_SETUP, which occurs before this callback.
This will prevent a child class adding something to this function without it doing anything.
Definition at line 88 of file MultiAppCommandLineControl.C.
◆ validParams()
InputParameters MultiAppCommandLineControl::validParams |
( |
| ) |
|
|
static |
Definition at line 22 of file MultiAppCommandLineControl.C.
26 params.addClassDescription(
"Control for modifying the command line arguments of MultiApps.");
29 params.set<ExecFlagEnum>(
"execute_on") = {EXEC_PRE_MULTIAPP_SETUP};
30 params.suppressParameter<ExecFlagEnum>(
"execute_on");
32 params.addRequiredParam<MultiAppName>(
"multi_app",
"The name of the MultiApp to control.");
33 params.addParam<SamplerName>(
35 "The Sampler object to utilize for altering the command line options of the MultiApp.");
36 params.addParam<std::vector<std::string>>(
37 "param_names",
"The names of the command line parameters to set via the sampled data.");
◆ _multi_app
std::shared_ptr<MultiApp> MultiAppCommandLineControl::_multi_app |
|
protected |
◆ _param_names
const std::vector<std::string>& MultiAppCommandLineControl::_param_names |
|
protected |
◆ _sampler
Sampler& MultiAppCommandLineControl::_sampler |
|
protected |
The documentation for this class was generated from the following files: