25 "Creates a full-solve type sub-application for each row of a Sampler matrix. "
26 "On second call, this object creates residuals for a PODReducedBasisTrainer with given basis "
29 "trainer_name",
"Trainer object that contains the solutions for different samples.");
38 _snapshot_generation(true)
40 if (getParam<unsigned int>(
"max_procs_per_app") != 1)
41 paramError(
"max_procs_per_app",
" does not support more than one processors per subapp!");
45 " needs to be run with fewer processors (detected ",
47 ") than samples (detected ",
61 "There are no basis vectors available for residual generation."
62 " This indicates that the bases have not been created yet."
63 " The most common cause of this error is the wrong setting"
64 " of the 'execute_on' flags in the PODFullSolveMultiApp and/or PODReducedBasisTrainer.");
79 bool last_solve_converged =
true;
97 return last_solve_converged;
113 mooseCheckMPIErr(ierr);
125 std::set<TagID> tags_to_compute;
126 for (
auto & tag_name : trainer_tags)
141 dof_id_type local_base_begin;
142 dof_id_type local_base_end;
143 dof_id_type n_local_bases;
148 std::vector<std::shared_ptr<PODSamplerSolutionTransfer>> to_transfers =
150 std::vector<std::shared_ptr<PODResidualTransfer>> from_transfers =
154 for (
auto transfer : to_transfers)
155 transfer->initializeToMultiapp();
157 for (
auto transfer : from_transfers)
158 transfer->initializeFromMultiapp();
165 for (dof_id_type i = local_base_begin; i < local_base_end; ++i)
167 for (
auto & transfer : to_transfers)
169 transfer->setGlobalMultiAppIndex(i);
170 transfer->executeToMultiapp();
175 for (
auto & transfer : from_transfers)
177 transfer->setGlobalMultiAppIndex(i);
178 transfer->executeFromMultiapp();
196 for (
auto transfer : to_transfers)
197 transfer->finalizeToMultiapp();
198 for (
auto transfer : from_transfers)
199 transfer->finalizeFromMultiapp();
202std::vector<std::shared_ptr<PODSamplerSolutionTransfer>>
205 std::vector<std::shared_ptr<PODSamplerSolutionTransfer>> output;
210 auto ptr = std::dynamic_pointer_cast<PODSamplerSolutionTransfer>(transfer);
212 output.push_back(ptr);
217std::vector<std::shared_ptr<PODResidualTransfer>>
220 std::vector<std::shared_ptr<PODResidualTransfer>> output;
225 auto ptr = std::dynamic_pointer_cast<PODResidualTransfer>(transfer);
227 output.push_back(ptr);
registerMooseObject("StochasticToolsApp", PODFullSolveMultiApp)
virtual void computeResidualTags(const std::set< TagID > &tags)
const ExecuteMooseObjectWarehouse< Transfer > & getMultiAppTransferWarehouse(Transfer::DIRECTION direction) const
void setCurrentNonlinearSystem(const unsigned int nl_sys_num)
virtual void initialSetup() override
virtual void restore(bool force=true) override
const std::string & type() const
void paramError(const std::string ¶m, Args... args) const
void mooseError(Args &&... args) const
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
virtual void resetApp(unsigned int global_app, Real time=0.0)
void init(unsigned int num_apps, bool batch_mode=false)
FEProblemBase & _fe_problem
std::vector< std::shared_ptr< MooseApp > > _apps
unsigned int _my_num_apps
void computeResidual()
Evaluating the residuals for every tag in the trainer.
std::vector< std::shared_ptr< PODSamplerSolutionTransfer > > getActiveSolutionTransfers(Transfer::DIRECTION direction)
Returning pointers to the solution transfers. Used in batch mode.
PODReducedBasisTrainer & _trainer
Pointer to the trainer object itself.
bool _snapshot_generation
Switch used to differentiate between snapshot generation and residual computation.
virtual bool solveStep(Real dt, Real target_time, bool auto_advance=true) override
PODFullSolveMultiApp(const InputParameters ¶meters)
std::vector< std::shared_ptr< PODResidualTransfer > > getActiveResidualTransfers(Transfer::DIRECTION direction)
Returning pointers to the solution transfers. Used in batch mode.
virtual void preTransfer(Real dt, Real target_time) override
Overriding preTransfer to reinit the subappliations if the object needs to be executed twice.
static InputParameters validParams()
void computeResidualBatch(Real target_time)
Evaluating the residuals for every tag in the trainer in batch mode.
unsigned int getSumBaseSize() const
Getting the overall base size, which is the sum of the individual bases.
const std::vector< std::string > & getTagNames() const
Sampler & _sampler
Sampler to utilize for creating MultiApps.
virtual void backup() override
This method is overridden so that we only store the initial state and not on any other timestep when ...
virtual void preTransfer(Real dt, Real target_time) override
virtual bool solveStep(Real dt, Real target_time, bool auto_advance=true) override
static InputParameters validParams()
dof_id_type _local_batch_app_index
Counter for extracting command line arguments in batch mode.
const StochasticTools::MultiAppMode _mode
The Sup-application solve mode.
dof_id_type getLocalRowEnd() const
dof_id_type getNumberOfRows() const
const LocalRankConfig & getRankConfig(bool batch_mode) const
virtual TagID getVectorTagID(const TagName &tag_name) const
Interface for objects that need to use samplers.
const Parallel::Communicator & _communicator
processor_id_type processor_id() const
processor_id_type n_processors() 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)