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)
216 mooseAssert(indices.size() == 1,
"Expected a single sub-app index when not distributing");
218 bool all_own_app = owns_app;
222 processor_id_type root =
223 owns_app ?
processor_id() : std::numeric_limits<processor_id_type>::max();
242 TIME_SECTION(
"MultiAppReporterTransfer::execute()", 5,
"Transferring reporters");
256 "Distributing reporter vectors is not implemented with sibling transfers.");
262 for (
const auto i : make_range(
getToMultiApp()->numGlobalApps()))
264 mooseError(
"Child application allocation on parallel processes must be the same to support "
265 "siblings reporter transfer",
266 ((
getToMultiApp()->problemBase().numConcurrentMultiApps() == 1 ||
268 getToMultiApp()->getParam<unsigned int>(
"execution_order_group"))
270 :
"\nConcurrent execution of the target and source multiapps is preventing "
271 "rank assignments to match. You will have to separate the "
272 "'execution_order_group' of the two applications, or have this feature "
276 mooseError(
"Number of source and target child apps must match for siblings transfer");
282 const std::shared_ptr<MultiApp> & main_app,
283 const std::vector<ReporterName> & main_app_rep_names,
284 const std::vector<ReporterName> & sub_app_rep_names)
287 for (
const auto & rn : main_app_rep_names)
290 std::vector<unsigned int> indices(main_app->numGlobalApps());
291 std::iota(indices.begin(), indices.end(), 0);
296 for (
const auto & ind : indices)
297 if (main_app->hasLocalApp(ind))
298 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 broadcastReporter(const ReporterName &name, FEProblemBase &problem, processor_id_type root)
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)
void min(const T &r, T &o, Request &req) const
MultiMooseEnum _directions
The directions this Transfer is to be executed on.
MooseEnum _current_direction
const Parallel::Communicator & _communicator
processor_id_type processor_id() const