https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
MultiAppSamplerControl Class Reference

A Control object for receiving data from a parent application Sampler object. More...

#include <MultiAppSamplerControl.h>

Inheritance diagram for MultiAppSamplerControl:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 MultiAppSamplerControl (const InputParameters &parameters)
 
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::vector< std::string > & getDependencies ()
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
bool isImplicit ()
 
Moose::StateArg determineState () const
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void residualSetup ()
 
virtual void subdomainSetup ()
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnumgetExecuteOnEnum () const
 
const FunctiongetFunction (const std::string &name) const
 
const FunctiongetFunctionByName (const FunctionName &name) const
 
bool hasFunction (const std::string &param_name) const
 
bool hasFunctionByName (const FunctionName &name) const
 
UserObjectName getUserObjectName (const std::string &param_name) const
 
const T & getUserObject (const std::string &param_name, bool is_dependency=true) const
 
const T & getUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
PerfGraphperfGraph ()
 
bool isDefaultPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessor (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessorByName (const PostprocessorName &name) const
 
std::size_t coupledPostprocessors (const std::string &param_name) const
 
const PostprocessorName & getPostprocessorName (const std::string &param_name, const unsigned int index=0) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name) const
 
const VectorPostprocessorName & getVectorPostprocessorName (const std::string &param_name) const
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
T & getSampler (const std::string &name)
 
SamplergetSampler (const std::string &name)
 
T & getSamplerByName (const SamplerName &name)
 
SamplergetSamplerByName (const SamplerName &name)
 

Static Public Member Functions

static InputParameters validParams ()
 
static MultiMooseEnum getExecuteOptions ()
 

Public Attributes

const ConsoleStream _console
 

Protected Member Functions

bool hasControllableParameterByName (const std::string &name) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 
virtual void addUserObjectDependencyHelper (const UserObject &) const
 
T & declareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const T & getRestartableData (const std::string &data_name) const
 
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &) const
 
virtual void addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &) const
 
ControllableParameter getControllableParameter (const std::string &param_name)
 
ControllableParameter getControllableParameter (const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const std::string &tag, const std::string &object_name, const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const MooseObjectName &object_name, const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const MooseObjectParameterName &param_name)
 
ControllableParameter getControllableParameterByName (const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const std::string &tag, const std::string &object_name, const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const MooseObjectName &object_name, const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const MooseObjectParameterName &param_name)
 
getControllableValue (const std::string &name, bool warn_when_values_differ=true)
 
getControllableValue (const std::string &name, bool warn_when_values_differ=true)
 
getControllableValueByName (const std::string &name, bool warn_when_values_differ=true)
 
getControllableValueByName (const std::string &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
getControllableValueByName (const MooseObjectName &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
getControllableValueByName (const std::string &tag, const std::string &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
getControllableValueByName (const MooseObjectParameterName &desired, bool warn_when_values_differ=true)
 
getControllableValueByName (const std::string &name, bool warn_when_values_differ=true)
 
getControllableValueByName (const std::string &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
getControllableValueByName (const MooseObjectName &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
getControllableValueByName (const std::string &tag, const std::string &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
getControllableValueByName (const MooseObjectParameterName &desired, bool warn_when_values_differ=true)
 
void setControllableValue (const std::string &name, const T &value)
 
void setControllableValue (const std::string &name, const T &value)
 
void setControllableValueByName (const std::string &name, const T &value)
 
void setControllableValueByName (const std::string &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const MooseObjectName &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const std::string &tag, const std::string &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const MooseObjectParameterName &name, const T &value)
 
void setControllableValueByName (const std::string &name, const T &value)
 
void setControllableValueByName (const std::string &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const MooseObjectName &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const std::string &tag, const std::string &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const MooseObjectParameterName &name, const T &value)
 

Protected Attributes

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...
 
std::vector< CLIArgString > _orig_args
 The original cli_args from input. More...
 
FEProblemBase_fe_problem
 
std::vector< std::string > _depends_on
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
const InputParameters_ti_params
 
FEProblemBase_ti_feproblem
 
bool _is_implicit
 
Real_t
 
const Real_t_old
 
int_t_step
 
Real_dt
 
Real_dt_old
 
bool _is_transient
 
const ExecFlagEnum_execute_enum
 
const ExecFlagType_current_execute_flag
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
const Parallel::Communicator & _communicator
 

Detailed Description

A Control object for receiving data from a parent application Sampler object.

Definition at line 25 of file MultiAppSamplerControl.h.

Constructor & Destructor Documentation

◆ MultiAppSamplerControl()

MultiAppSamplerControl::MultiAppSamplerControl ( const InputParameters parameters)

Definition at line 44 of file MultiAppSamplerControl.C.

46  SamplerInterface(this),
47  _multi_app(_fe_problem.getMultiApp(getParam<MultiAppName>("multi_app"))),
49  _param_names(getParam<std::vector<std::string>>("param_names"))
50 {
51  if (!_sampler.getParam<ExecFlagEnum>("execute_on").isValueSet(EXEC_PRE_MULTIAPP_SETUP))
53  "execute_on",
54  "The sampler object, '",
55  _sampler.name(),
56  "', is being used by the '",
57  name(),
58  "' object, thus the 'execute_on' of the sampler must include 'PRE_MULTIAPP_SETUP'.");
59 
60  if (_multi_app->usingPositions())
61  paramError("multi_app",
62  "The MultiApp must construct its sub-apps in initial setup but not during its "
63  "creation for '",
64  type(),
65  "'.\nTypically only sampler MultiApps work with '",
66  type(),
67  "' objects.");
68 
69  bool batch_reset = _multi_app->isParamValid("mode") &&
70  (_multi_app->getParam<MooseEnum>("mode") == "batch-reset");
71  bool batch_restore = _multi_app->isParamValid("mode") &&
72  (_multi_app->getParam<MooseEnum>("mode") == "batch-restore");
73  if (batch_reset)
74  ; // Do not perform the App count test, because in batch mode there is only one
75 
76  else if (batch_restore)
77  _multi_app->paramError(
78  "mode",
79  "The MultiApp object, '",
80  _multi_app->name(),
81  "', supplied to the '",
82  name(),
83  "' object is setup to run in 'batch-restore' mode, when using this mode command line "
84  "arguments cannot be modified; batch-reset mode should be used instead.");
85 
86  else if (_multi_app->numGlobalApps() != _sampler.getNumberOfRows())
87  mooseError("The number of sub apps (",
88  _multi_app->numGlobalApps(),
89  ") created by MultiApp object '",
90  _multi_app->name(),
91  "' must be equal to the number for rows (",
93  ") for the '",
94  _sampler.name(),
95  "' Sampler object.");
96 }
Sampler & _sampler
Sampler to utilize for creating MultiApps.
virtual const std::string & name() const
std::shared_ptr< MultiApp > getMultiApp(const std::string &multi_app_name) const
FEProblemBase & _fe_problem
const std::string & type() const
const T & getParam(const std::string &name) const
void paramError(const std::string &param, Args... args) const
bool isValueSet(const std::string &value) const
dof_id_type getNumberOfRows() const
T & getSampler(const std::string &name)
Control(const InputParameters &parameters)
SamplerInterface(const MooseObject *moose_object)
void mooseError(Args &&... args) const
std::shared_ptr< MultiApp > _multi_app
The MultiApp this Transfer is transferring data to or from.
const InputParameters & parameters() const
const std::vector< std::string > & _param_names
Storage for the parameter names to be applied.

Member Function Documentation

◆ execute()

void MultiAppSamplerControl::execute ( )
overridevirtual

Implements Control.

Definition at line 106 of file MultiAppSamplerControl.C.

107 {
108  // Gather the original arguments given in the parameter so we can keep them
109  if (_orig_args.empty())
110  {
111  _orig_args = getControllableValueByName<std::vector<CLIArgString>>(
112  "MultiApp", _multi_app->name(), "cli_args", true);
113  if (_orig_args.size() == 0)
114  _orig_args.push_back("");
115  else if (_param_names.size())
116  for (auto & clia : _orig_args)
117  clia += ";";
118  }
119 
120  auto cli_args = _orig_args;
121 
122  // To avoid storing duplicated param_names for each sampler, we store only param_names once in
123  // "cli_args".
124 
125  // Handle a couple errors up front regarding bracket expressions
126  bool has_brackets = false;
127  if (_param_names.size())
128  {
129  has_brackets = _param_names[0].find("[") != std::string::npos;
130  for (unsigned int i = 1; i < _param_names.size(); ++i)
131  if (has_brackets != (_param_names[i].find("[") != std::string::npos))
132  paramError("param_names",
133  "If the bracket is used, it must be provided to every parameter.");
134  }
135  if (!has_brackets && _sampler.getNumberOfCols() != _param_names.size())
136  paramError("param_names",
137  "The number of columns (",
139  ") must match the number of parameters (",
140  _param_names.size(),
141  ").");
142 
143  // Add the parameters that will be modified. The MultiApp will ultimately be
144  // responsible for assigning the values from the sampler.
145  std::ostringstream oss;
146  for (dof_id_type col = 0; col < _param_names.size(); ++col)
147  {
148  if (col > 0)
149  oss << ";";
150  oss << _param_names[col];
151  }
152 
153  // Put all the parameters in a single string
154  for (auto & clia : cli_args)
155  clia += oss.str();
156 
157  setControllableValueByName<std::vector<CLIArgString>>(
158  "MultiApp", _multi_app->name(), "cli_args", cli_args);
159 }
Sampler & _sampler
Sampler to utilize for creating MultiApps.
std::vector< CLIArgString > _orig_args
The original cli_args from input.
void paramError(const std::string &param, Args... args) const
std::shared_ptr< MultiApp > _multi_app
The MultiApp this Transfer is transferring data to or from.
const std::vector< std::string > & _param_names
Storage for the parameter names to be applied.
dof_id_type getNumberOfCols() const
uint8_t dof_id_type

◆ initialSetup()

void MultiAppSamplerControl::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.

Reimplemented from Control.

Definition at line 99 of file MultiAppSamplerControl.C.

100 {
101  // Do not put anything here, this method is being called after execute because the execute_on
102  // is set to PRE_MULTIAPP_SETUP for this class. It won't work any other way.
103 }

◆ validParams()

InputParameters MultiAppSamplerControl::validParams ( )
static

Definition at line 24 of file MultiAppSamplerControl.C.

25 {
28  params.addClassDescription("Control for modifying the command line arguments of MultiApps.");
29 
30  // Set and suppress the 'execute_on' flag, it doesn't work with any other flag
31  params.set<ExecFlagEnum>("execute_on") = {EXEC_PRE_MULTIAPP_SETUP};
32  params.suppressParameter<ExecFlagEnum>("execute_on");
33 
34  params.addRequiredParam<MultiAppName>("multi_app", "The name of the MultiApp to control.");
35  params.addRequiredParam<SamplerName>(
36  "sampler",
37  "The Sampler object to utilize for altering the command line options of the MultiApp.");
38  params.addRequiredParam<std::vector<std::string>>(
39  "param_names", "The names of the command line parameters to set via the sampled data.");
40 
41  return params;
42 }
static InputParameters validParams()
static InputParameters validParams()
T & set(const std::string &name, bool quiet_mode=false)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void suppressParameter(const std::string &name)
const ExecFlagType EXEC_PRE_MULTIAPP_SETUP
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _multi_app

std::shared_ptr<MultiApp> MultiAppSamplerControl::_multi_app
protected

The MultiApp this Transfer is transferring data to or from.

Definition at line 43 of file MultiAppSamplerControl.h.

Referenced by execute(), and MultiAppSamplerControl().

◆ _orig_args

std::vector<CLIArgString> MultiAppSamplerControl::_orig_args
protected

The original cli_args from input.

Definition at line 52 of file MultiAppSamplerControl.h.

Referenced by execute().

◆ _param_names

const std::vector<std::string>& MultiAppSamplerControl::_param_names
protected

Storage for the parameter names to be applied.

Definition at line 49 of file MultiAppSamplerControl.h.

Referenced by execute().

◆ _sampler

Sampler& MultiAppSamplerControl::_sampler
protected

Sampler to utilize for creating MultiApps.

Definition at line 46 of file MultiAppSamplerControl.h.

Referenced by execute(), and MultiAppSamplerControl().


The documentation for this class was generated from the following files: