www.mooseframework.org
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
StochasticToolsTransfer Class Reference

The class creates an additional API to allow Transfers to work when running the StochasticTools<FullSolve/Transient>MultiApp objects in batch-mode. More...

#include <StochasticToolsTransfer.h>

Inheritance diagram for StochasticToolsTransfer:
[legend]

Public Member Functions

 StochasticToolsTransfer (const InputParameters &parameters)
 
void setGlobalMultiAppIndex (dof_id_type index)
 Method for keeping track of the global MultiApp index when running in batch mode. More...
 
virtual void initializeFromMultiapp ()
 Methods for transferring data from sub-applications to the master application. More...
 
virtual void executeFromMultiapp ()
 
virtual void finalizeFromMultiapp ()
 
virtual void initializeToMultiapp ()
 Methods for transferring data to sub-applications to the master application. More...
 
virtual void executeToMultiapp ()
 
virtual void finalizeToMultiapp ()
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Attributes

dof_id_type _global_index = 0
 Index for tracking the global index when using batch mode operation. More...
 
Sampler * _sampler_ptr
 Pointer to the Sampler object used by the SamplerTransientMultiApp or SamplerFullSolveMultiApp. More...
 

Detailed Description

The class creates an additional API to allow Transfers to work when running the StochasticTools<FullSolve/Transient>MultiApp objects in batch-mode.

Definition at line 24 of file StochasticToolsTransfer.h.

Constructor & Destructor Documentation

◆ StochasticToolsTransfer()

StochasticToolsTransfer::StochasticToolsTransfer ( const InputParameters &  parameters)

Definition at line 26 of file StochasticToolsTransfer.C.

27  : MultiAppTransfer(parameters), SamplerInterface(this)
28 {
29  // When the MultiApp is running in batch mode the execute flags for the transfer object must
30  // be removed. If not the 'regular' transfer that occurs will potentially destroy data
31  // populated during the calls from the MultiApp in batch mode. To prevent the Transfer from
32  // running the execute flags must be removed. This is done automatically here, unless
33  // 'execute_on' was modified by the user, which an error is produced.
34  if (_multi_app->isParamValid("mode") &&
35  (_multi_app->getParamTempl<MooseEnum>("mode") == "batch-reset" ||
36  _multi_app->getParamTempl<MooseEnum>("mode") == "batch-restore"))
37  {
38  if (parameters.isParamSetByUser("execute_on"))
39  paramError("execute_on",
40  "The 'execute_on' parameter for the '",
41  name(),
42  "' transfer was set, but the parent MultiApp object (",
43  _multi_app->name(),
44  ") is running in 'batch' mode. For this case the 'execute_on' parameter must not "
45  "be set by the user or set to NONE.");
46  else
47  {
48  ExecFlagEnum & exec_flags = const_cast<ExecFlagEnum &>(getParam<ExecFlagEnum>("execute_on"));
49  exec_flags = EXEC_NONE;
50  }
51  }
52 
53  // In the validParams method above the 'check_multiapp_execute_on' is disabled. This is required
54  // to allow for the error above to be triggered. If the 'execute_on' is set by the without
55  // the 'check_multiapp_execute_on' flag the above if statement may not be reached. Therefore,
56  // a bit of a trick is performed to allow the above check to run first and then the regular
57  // check.
58  //
59  // If the else statement is reached then the user is not running in batch mode, so the
60  // 'check_multiapp_execute_on' is a valid check to perform. If the 'check_multiapp_execute_on'
61  // has not been set, then the user wants the check to be performed, so do it.
62  else if (!parameters.isParamSetByUser("check_multiapp_execute_on"))
63  checkMultiAppExecuteOn();
64 
65  // Determine the Sampler
66  if (isParamValid("sampler"))
67  {
68  _sampler_ptr = &(getSampler("sampler"));
69 
70  SamplerTransientMultiApp * ptr_transient =
71  dynamic_cast<SamplerTransientMultiApp *>(_multi_app.get());
72  SamplerFullSolveMultiApp * ptr_fullsolve =
73  dynamic_cast<SamplerFullSolveMultiApp *>(_multi_app.get());
74 
75  if (!ptr_transient && !ptr_fullsolve)
76  mooseError("The 'multi_app' parameter must provide either a 'SamplerTransientMultiApp' or "
77  "'SamplerFullSolveMultiApp' object.");
78 
79  if ((ptr_transient && &(ptr_transient->getSampler("sampler")) != _sampler_ptr) ||
80  (ptr_fullsolve && &(ptr_fullsolve->getSampler("sampler")) != _sampler_ptr))
81  mooseError("The supplied 'multi_app' must have the same Sampler object as this Transfer.");
82  }
83 
84  else
85  {
86  paramWarning("sampler",
87  "Support for the 'StochasticToolsTransfer' objects without the 'sampler' input "
88  "parameter is being removed, please update your input file(s).");
89 
90  std::shared_ptr<SamplerTransientMultiApp> ptr_transient =
91  std::dynamic_pointer_cast<SamplerTransientMultiApp>(_multi_app);
92  std::shared_ptr<SamplerFullSolveMultiApp> ptr_fullsolve =
93  std::dynamic_pointer_cast<SamplerFullSolveMultiApp>(_multi_app);
94 
95  if (!ptr_transient && !ptr_fullsolve)
96  mooseError("The 'multi_app' parameter must provide either a 'SamplerTransientMultiApp' or "
97  "'SamplerFullSolveMultiApp' object.");
98 
99  if (ptr_transient)
100  _sampler_ptr = &(ptr_transient->getSampler("sampler"));
101  else
102  _sampler_ptr = &(ptr_fullsolve->getSampler("sampler"));
103  }
104 }

Member Function Documentation

◆ executeFromMultiapp()

void StochasticToolsTransfer::executeFromMultiapp ( )
virtual

Reimplemented in SamplerPostprocessorTransfer.

Definition at line 112 of file StochasticToolsTransfer.C.

113 {
114 }

◆ executeToMultiapp()

void StochasticToolsTransfer::executeToMultiapp ( )
virtual

Reimplemented in SamplerParameterTransfer.

Definition at line 127 of file StochasticToolsTransfer.C.

128 {
129 }

◆ finalizeFromMultiapp()

void StochasticToolsTransfer::finalizeFromMultiapp ( )
virtual

Reimplemented in SamplerPostprocessorTransfer.

Definition at line 117 of file StochasticToolsTransfer.C.

118 {
119 }

◆ finalizeToMultiapp()

void StochasticToolsTransfer::finalizeToMultiapp ( )
virtual

Reimplemented in SamplerParameterTransfer.

Definition at line 132 of file StochasticToolsTransfer.C.

133 {
134 }

◆ initializeFromMultiapp()

void StochasticToolsTransfer::initializeFromMultiapp ( )
virtual

Methods for transferring data from sub-applications to the master application.

Reimplemented in SamplerPostprocessorTransfer.

Definition at line 107 of file StochasticToolsTransfer.C.

108 {
109 }

◆ initializeToMultiapp()

void StochasticToolsTransfer::initializeToMultiapp ( )
virtual

Methods for transferring data to sub-applications to the master application.

Reimplemented in SamplerParameterTransfer.

Definition at line 122 of file StochasticToolsTransfer.C.

123 {
124 }

◆ setGlobalMultiAppIndex()

void StochasticToolsTransfer::setGlobalMultiAppIndex ( dof_id_type  index)
inline

Method for keeping track of the global MultiApp index when running in batch mode.

See StochasticTools<FullSolve/Transient>MultiApp

Definition at line 54 of file StochasticToolsTransfer.h.

54 { _global_index = index; }

◆ validParams()

InputParameters StochasticToolsTransfer::validParams ( )
static

Definition at line 18 of file StochasticToolsTransfer.C.

19 {
20  InputParameters params = MultiAppTransfer::validParams();
21  params.set<bool>("check_multiapp_execute_on", true) = false; // see comments in constructor
22  params.addParam<SamplerName>("sampler", "A the Sampler object that Transfer is associated..");
23  return params;
24 }

Referenced by SamplerParameterTransfer::validParams(), and SamplerPostprocessorTransfer::validParams().

Member Data Documentation

◆ _global_index

dof_id_type StochasticToolsTransfer::_global_index = 0
protected

Index for tracking the global index when using batch mode operation.

Definition at line 58 of file StochasticToolsTransfer.h.

Referenced by setGlobalMultiAppIndex().

◆ _sampler_ptr

Sampler* StochasticToolsTransfer::_sampler_ptr
protected

The documentation for this class was generated from the following files:
SamplerTransientMultiApp
Definition: SamplerTransientMultiApp.h:25
SamplerFullSolveMultiApp
Definition: SamplerFullSolveMultiApp.h:25
StochasticToolsTransfer::_sampler_ptr
Sampler * _sampler_ptr
Pointer to the Sampler object used by the SamplerTransientMultiApp or SamplerFullSolveMultiApp.
Definition: StochasticToolsTransfer.h:61
validParams
InputParameters validParams()
name
const std::string name
Definition: Setup.h:21
StochasticToolsTransfer::_global_index
dof_id_type _global_index
Index for tracking the global index when using batch mode operation.
Definition: StochasticToolsTransfer.h:58