22 "Serializes and transfers solution vectors for given variables from sub-applications.");
24 "The name of the parallel storage reporter.");
26 "The name of the solution container on the subapp.");
29 "The names of the variables which should be serialized and transferred to this application.");
30 params.
addParam<
bool>(
"serialize_on_root",
32 "If we want to gather the solution fields only on the root processors of "
33 "the subapps before transfering to the main app.");
39 _variable_names(getParam<
std::vector<VariableName>>(
"variables")),
40 _serialize_on_root(getParam<bool>(
"serialize_on_root"))
43 paramError(
"to_multi_app",
"To and between multiapp directions are not implemented");
51 getParam<std::string>(
"parallel_storage"));
59 const auto & serialized_solution_reporter = getParam<std::string>(
"solution_container");
61 for (MooseIndex(n) i = 0; i < n; i++)
90 for (MooseIndex(n) i = 0; i < n; i++)
132 const dof_id_type global_i)
150 dof_id_type new_local_entries_begin;
151 dof_id_type new_local_entries_end;
152 dof_id_type num_new_local_entries;
157 num_new_local_entries,
158 new_local_entries_begin,
159 new_local_entries_end);
164 for (
const auto & snapshot : solution_container.
getSnapshots())
166 DenseVector<Real> serialized_solution;
171 serialized_solution.get_values(),
172 (local_app_index >= new_local_entries_begin && local_app_index < new_local_entries_end)
174 : std::vector<dof_id_type>());
176 if (local_app_index >= new_local_entries_begin && local_app_index < new_local_entries_end)
185 const dof_id_type global_i)
195 for (
const auto & snapshot : solution_container.
getSnapshots())
197 DenseVector<Real> serialized_solution;
200 snapshot.localize(serialized_solution.get_values(),
202 : std::vector<dof_id_type>());
214 return variable.
sys();
registerMooseObject("StochasticToolsApp", SerializedSolutionTransfer)
T & getUserObject(const std::string &name, unsigned int tid=0) const
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
void paramError(const std::string ¶m, Args... args) const
bool hasToMultiApp() const
const std::shared_ptr< MultiApp > getFromMultiApp() const
A Reporter which stores serialized solution fields for given variables in a distributed fashion.
void addEntry(const VariableName &vname, unsigned int global_i, const DenseVector< Real > &solution)
Add a new solution entry to the container.
dof_id_type getNumberOfLocalRows() const
dof_id_type getLocalRowBegin() const
This class is responsible for serializing solutions coming from subapps on specific processors.
SerializedSolutionTransfer(const InputParameters ¶meters)
virtual void execute() override
std::vector< SolutionContainer * > _solution_container
Link to the storage spaces on the subapplications (will only hold one in batch mode)
SystemBase & getSystem(FEProblemBase &app_problem, const VariableName &vname)
Return the system which contains the given variable.
virtual void initialSetup() override
void transferToSubAppRoot(FEProblemBase &app_problem, SolutionContainer &solution_container, const dof_id_type global_i)
Serialize on the root processor of the subapplication and transfer the result to the main application...
const bool _serialize_on_root
User-selected switch that determines if we want to serialize on the root of the subapp only or distri...
std::vector< VariableName > _variable_names
The names of the variables which should be extracted from the solution vector.
void transferInParallel(FEProblemBase &app_problem, SolutionContainer &solution_container, const dof_id_type global_i)
Serialize on methodically determined rank of the subapp and transfer to the main application.
static InputParameters validParams()
void initializeInBatchMode()
This routine queries the solution container addresses from the subapps.
ParallelSolutionStorage * _parallel_storage
The storage on the main application where the serialized solutions should be transferred.
void initializeInNormalMode()
Initializes the solution container if the multiapp is run in normal mode.
void executeFromMultiapp() override
const Snapshots & getSnapshots() const
Return the whole snapshot container.
This class is responsible for collecting solution vectors in one place.
const std::vector< dof_id_type > & getVariableGlobalDoFs()
void setVariableGlobalDoFs(const std::string &var_name)
processor_id_type size() const
processor_id_type rank() const
FEProblemBase & _fe_problem
const Parallel::Communicator & comm() const
void linearPartitionItems(dof_id_type num_items, dof_id_type num_chunks, dof_id_type chunk_id, dof_id_type &num_local_items, dof_id_type &local_items_begin, dof_id_type &local_items_end)