https://mooseframework.inl.gov
SamplerFullSolveMultiApp.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // MOOSE includes
13 #include "FullSolveMultiApp.h"
14 #include "SamplerInterface.h"
15 
16 #include "StochasticToolsTypes.h"
17 
18 class Sampler;
20 
22  public SamplerInterface,
23  public ReporterInterface
24 {
25 public:
28  virtual bool solveStep(Real dt, Real target_time, bool auto_advance = true) override;
29  virtual void preTransfer(Real dt, Real target_time) override;
30 
43  static std::vector<std::string>
44  sampledCommandLineArgs(const std::vector<Real> & row,
45  const std::vector<std::string> & full_args_name);
46 
58  static void
59  execBatchTransfers(const std::vector<std::shared_ptr<StochasticToolsTransfer>> & transfers,
60  dof_id_type global_row_index,
61  const std::vector<Real> & row_data,
62  Transfer::DIRECTION direction,
63  bool verbose,
64  const ConsoleStream & console);
65 
66 protected:
68  virtual void showStatusMessage(unsigned int i) const override;
69 
72 
75 
78 
80  virtual std::vector<std::string> getCommandLineArgs(const unsigned int local_app) override;
81 
82 private:
86  bool solveStepBatch(Real dt, Real target_time, bool auto_advance = true);
87 
92  void updateRowData(dof_id_type local_index);
93 
97  std::vector<std::shared_ptr<StochasticToolsTransfer>>
99 
100  // Flag indicating a solve has occured
102 
103  // Sampler size, to test if the MultiApp object needs to be re-initialize
105 
107  std::vector<Real> _row_data;
109  dof_id_type _local_row_index = std::numeric_limits<dof_id_type>::max();
110 
112  const std::vector<bool> * _should_run = nullptr;
113 };
const StochasticTools::MultiAppMode _mode
The Sup-application solve mode.
bool solveStepBatch(Real dt, Real target_time, bool auto_advance=true)
Helper method for running in mode=&#39;batch&#39;.
std::vector< std::shared_ptr< StochasticToolsTransfer > > getActiveStochasticToolsTransfers(Transfer::DIRECTION direction)
Helper for getting StochasticToolsTransfer objects.
virtual bool solveStep(Real dt, Real target_time, bool auto_advance=true) override
SamplerFullSolveMultiApp(const InputParameters &parameters)
dof_id_type _local_batch_app_index
Counter for extracting command line arguments in batch mode.
The class creates an additional API to allow Transfers to work when running the StochasticTools<FullS...
static InputParameters validParams()
std::vector< Real > _row_data
Current row of data updated by updateRowData. Used by transfers and setting command line args...
dof_id_type _local_row_index
Current local index representing _row_data.
static std::vector< std::string > sampledCommandLineArgs(const std::vector< Real > &row, const std::vector< std::string > &full_args_name)
Helper for inserting row data into commandline arguments Used here and in SamplerTransientMultiApp.
virtual std::vector< std::string > getCommandLineArgs(const unsigned int local_app) override
Override to allow for batch mode to get correct cli_args.
Sampler & _sampler
Sampler to utilize for creating MultiApps.
virtual void showStatusMessage(unsigned int i) const override
Override to avoid &#39;solve converged&#39; message and print when processors are finished.
const std::vector< bool > * _should_run
Reporter value determining whether the sub-app should be run for a certain sample.
static void execBatchTransfers(const std::vector< std::shared_ptr< StochasticToolsTransfer >> &transfers, dof_id_type global_row_index, const std::vector< Real > &row_data, Transfer::DIRECTION direction, bool verbose, const ConsoleStream &console)
Helper for executing transfers when doing batch stochastic simulations.
virtual void preTransfer(Real dt, Real target_time) override
void updateRowData(dof_id_type local_index)
Helper function for updating _row_data and _local_row_index.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const InputParameters & parameters() const
uint8_t dof_id_type