24 "List of the reporter names (object_name/value_name) to transfer the value from.");
27 "List of the reporter names (object_name/value_name) to transfer the value to.");
30 std::numeric_limits<unsigned int>::max(),
31 "The MultiApp object sub-application index to use when transferring to/from the "
32 "sub-application. If unset and transferring to the sub-applications then all "
33 "sub-applications will receive data. The value must be set when transferring from a "
36 "distribute_reporter_vector",
38 "Transfer to/from a vector reporter from/to reporters on child applications. N "
39 "to 1 or 1 to N type of transfer. The number of child applications must "
40 "match the size of the vector reporter");
47 _from_reporter_names(getParam<
std::vector<
ReporterName>>(
"from_reporters")),
48 _to_reporter_names(getParam<
std::vector<
ReporterName>>(
"to_reporters")),
49 _subapp_index(getParam<unsigned
int>(
"subapp_index")),
50 _distribute_reporter_vector(getParam<bool>(
"distribute_reporter_vector"))
53 paramError(
"to_reporters",
"from_reporters and to_reporters must be the same size.");
56 paramError(
"direction",
"This transfer only supports a single direction.");
61 "The subapp_index parameter is not supported for transfers between two multiapps");
67 if (
_subapp_index != std::numeric_limits<unsigned int>::max() &&
71 "The supplied sub-application index is greater than the number of sub-applications.");
76 "subapp_index must be provided when more than one subapp is present.");
81 if (
_subapp_index != std::numeric_limits<unsigned int>::max() &&
85 "The supplied sub-application index is greater than the number of sub-applications.");
100 else if (
_subapp_index == std::numeric_limits<unsigned int>::max() &&
127 std::vector<unsigned int> indices;
128 if (
_subapp_index == std::numeric_limits<unsigned int>::max())
131 std::iota(indices.begin(), indices.end(), 0);
136 for (
const auto & ind : indices)
163 std::vector<unsigned int> indices;
168 std::iota(indices.begin(), indices.end(), 0);
170 else if (
_subapp_index == std::numeric_limits<unsigned int>::max())
190 for (
const auto ind : indices)
224 TIME_SECTION(
"MultiAppReporterTransfer::execute()", 5,
"Transferring reporters");
238 "Distributing reporter vectors is not implemented with sibling transfers.");
244 for (
const auto i : make_range(
getToMultiApp()->numGlobalApps()))
246 mooseError(
"Child application allocation on parallel processes must be the same to support "
247 "siblings reporter transfer");
250 mooseError(
"Number of source and target child apps must match for siblings transfer");
256 const std::shared_ptr<MultiApp> & main_app,
257 const std::vector<ReporterName> & main_app_rep_names,
258 const std::vector<ReporterName> & sub_app_rep_names)
261 for (
const auto & rn : main_app_rep_names)
264 std::vector<unsigned int> indices(main_app->numGlobalApps());
265 std::iota(indices.begin(), indices.end(), 0);
270 for (
const auto & ind : indices)
271 if (main_app->hasLocalApp(ind))
272 for (
const auto & rn : sub_app_rep_names)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
registerMooseObject("MooseApp", MultiAppReporterTransfer)
const ReporterMode REPORTER_MODE_REPLICATED
const ReporterMode REPORTER_MODE_ROOT
void ErrorVector unsigned int
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Transfer for migrating reporter values between the main and sub-application(s).
virtual void executeToMultiapp()
void setVectorReporterTransferModes(const std::shared_ptr< MultiApp > &main_app, const std::vector< ReporterName > &main_app_rep_names, const std::vector< ReporterName > &sub_app_rep_names)
Sets transfer modes for reporters when distributing.
virtual void execute() override
Execute the transfer.
bool _distribute_reporter_vector
determines transfer type
MultiAppReporterTransfer(const InputParameters ¶meters)
const std::vector< ReporterName > & _to_reporter_names
Vector of reporters to transfer data to.
static InputParameters validParams()
virtual void initialSetup() override
Method called at the beginning of the simulation for checking integrity or doing one-time setup.
virtual void checkSiblingsTransferSupported() const override
Whether the transfer supports siblings transfer.
virtual void executeFromMultiapp()
const std::vector< ReporterName > & _from_reporter_names
Vector of reporters to transfer data from.
const unsigned int & _subapp_index
If set, indicates a particular subapp to transfer the reporter to/from.
Base class for all MultiAppTransfer objects.
void initialSetup() override
Method called at the beginning of the simulation for checking integrity or doing one-time setup.
bool hasToMultiApp() const
Whether the transfer owns a non-null to_multi_app.
const std::shared_ptr< MultiApp > getToMultiApp() const
Get the MultiApp to transfer data to.
static InputParameters validParams()
const std::shared_ptr< MultiApp > getFromMultiApp() const
Get the MultiApp to transfer data from.
bool hasFromMultiApp() const
Whether the transfer owns a non-null from_multi_app.
bool isValueSet(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
unsigned int size() const
Return the number of active items in the MultiMooseEnum.
The Reporter system is comprised of objects that can contain any number of data values.
void transferToVectorReporter(const ReporterName &from_reporter, const ReporterName &to_reporter, const FEProblemBase &from_problem, FEProblemBase &to_problem, dof_id_type index, unsigned int time_index=0)
void transferReporter(const ReporterName &from_reporter, const ReporterName &to_reporter, const FEProblemBase &from_problem, FEProblemBase &to_problem, unsigned int time_index=0)
void resizeReporter(const ReporterName &name, FEProblemBase &problem, dof_id_type n)
void clearVectorReporter(const ReporterName &name, FEProblemBase &problem)
void addReporterTransferMode(const ReporterName &name, const ReporterMode &mode, FEProblemBase &problem)
void transferFromVectorReporter(const ReporterName &from_reporter, const ReporterName &to_reporter, const FEProblemBase &from_problem, FEProblemBase &to_problem, dof_id_type index, unsigned int time_index=0)
static InputParameters validParams()
void sumVectorReporter(const ReporterName &name, FEProblemBase &problem)
MultiMooseEnum _directions
The directions this Transfer is to be executed on.
MooseEnum _current_direction