18#include "libmesh/meshfree_interpolation.h"
19#include "libmesh/system.h"
28 "Transfers postprocessor data between the master application and sub-application(s).");
31 "The name of the Postprocessor in the Master to transfer the value from.");
34 "The name of the Postprocessor in the MultiApp to transfer the value to. "
35 " This should most likely be a Reporter Postprocessor.");
36 MooseEnum reduction_type(
"average sum maximum minimum");
39 "The type of reduction to perform to reduce postprocessor "
40 "values from multiple SubApps to a single value");
48 _from_pp_name(getParam<PostprocessorName>(
"from_postprocessor")),
49 _to_pp_name(getParam<PostprocessorName>(
"to_postprocessor")),
50 _reduction_type(getParam<
MooseEnum>(
"reduction_type"))
53 paramError(
"direction",
"This transfer is only unidirectional");
58 "In MultiAppPostprocessorTransfer, must specify 'reduction_type' if "
59 "'from_multi_app' is set");
63 paramError(
"reduction_type",
"Reduction is not supported for transfer from parent application");
67 paramError(
"reduction_type",
"Reductions are not supported for multiapp sibling transfers");
73 TIME_SECTION(
"MultiAppPostprocessorTransfer::execute()", 5,
"Transferring a postprocessor");
96 Real pp_value = std::numeric_limits<Real>::max();
107 mooseAssert(pp_value != std::numeric_limits<Real>::max() ||
109 "Source and target app parallel distribution must be the same");
114 for (
const auto j : make_range(
getToMultiApp()->numGlobalApps()))
132 for (
unsigned int i = 0; i <
getToMultiApp()->numGlobalApps(); i++)
141 Real reduced_pp_value;
146 reduced_pp_value = 0;
149 reduced_pp_value = -std::numeric_limits<Real>::max();
152 reduced_pp_value = std::numeric_limits<Real>::max();
156 "Can't get here unless someone adds a new enum and fails to add it to this switch");
161 for (
unsigned int i = 0; i < multi_app->numGlobalApps(); i++)
163 if (multi_app->hasLocalApp(i) && multi_app->isRootProcessor())
165 const Real & curr_pp_value =
166 multi_app->appProblemBase(i).getPostprocessorValueByName(
_from_pp_name);
171 reduced_pp_value += curr_pp_value;
174 reduced_pp_value = std::max(curr_pp_value, reduced_pp_value);
177 reduced_pp_value = std::min(curr_pp_value, reduced_pp_value);
180 mooseError(
"Can't get here unless someone adds a new enum and fails to add it to "
190 reduced_pp_value /=
static_cast<Real
>(multi_app->numGlobalApps());
203 "Can't get here unless someone adds a new enum and fails to add it to this switch");
220 for (
const auto i : make_range(
getToMultiApp()->numGlobalApps()))
222 mooseError(
"Child application allocation on parallel processes must be the same to support "
223 "siblings postprocessor transfer");
229 mooseError(
"Number of source and target child apps must either match or only a single source "
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
const ExecFlagType EXEC_TRANSFER
registerMooseObject("MooseApp", MultiAppPostprocessorTransfer)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name, std::size_t t_index=0) const
Get a read-only reference to the value associated with a Postprocessor that exists.
virtual void computeUserObjectByName(const ExecFlagType &type, const Moose::AuxGroup &group, const std::string &name)
Compute an user object with the given name.
void setPostprocessorValueByName(const PostprocessorName &name, const PostprocessorValue &value, std::size_t t_index=0)
Set the value of a PostprocessorValue.
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.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Copies the value of a Postprocessor either:
static InputParameters validParams()
MooseEnum _reduction_type
Reduction operation to perform when transferring from multiple child apps to the parent app.
virtual void execute() override
Execute the transfer.
PostprocessorName _to_pp_name
Name of the postprocessor to transfer data to.
PostprocessorName _from_pp_name
Name of the postprocessor to transfer data from.
virtual void checkSiblingsTransferSupported() const override
Siblings transfers only supported for a single origin app.
MultiAppPostprocessorTransfer(const InputParameters ¶meters)
Base class for all MultiAppTransfer objects.
void errorIfObjectExecutesOnTransferInSourceApp(const std::string &object_name) const
Error if executing this MooseObject on EXEC_TRANSFER in a source multiapp (from_multiapp,...
static void addUserObjectExecutionCheckParam(InputParameters ¶ms)
Add the execution order check parameter (to skip the warning if needed)
void checkParentAppUserObjectExecuteOn(const std::string &object_name) const
Checks the execute_on flags for user object transfers with user objects on the source app which is al...
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.
unsigned int size() const
Return the number of active items in the MultiMooseEnum.
void max(const T &r, T &o, Request &req) const
void min(const T &r, T &o, Request &req) const
MultiMooseEnum _directions
The directions this Transfer is to be executed on.
FEProblemBase & _fe_problem
MooseEnum _current_direction
const Parallel::Communicator & _communicator