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 
35  virtual void backup() override;
36 
49  static std::vector<std::string>
50  sampledCommandLineArgs(const std::vector<Real> & row,
51  const std::vector<std::string> & full_args_name);
52 
64  static void
65  execBatchTransfers(const std::vector<std::shared_ptr<StochasticToolsTransfer>> & transfers,
66  dof_id_type global_row_index,
67  const std::vector<Real> & row_data,
68  Transfer::DIRECTION direction,
69  bool verbose,
70  const ConsoleStream & console);
71 
72 protected:
74  virtual void showStatusMessage(unsigned int i) const override;
75 
78 
81 
84 
86  virtual std::vector<std::string> getCommandLineArgs(const unsigned int local_app) override;
87 
88 private:
92  bool solveStepBatch(Real dt, Real target_time, bool auto_advance = true);
93 
98  void updateRowData(dof_id_type local_index);
99 
103  std::vector<std::shared_ptr<StochasticToolsTransfer>>
105 
106  // Flag indicating a solve has occured
108 
109  // Sampler size, to test if the MultiApp object needs to be re-initialize
111 
113  std::vector<Real> _row_data;
115  dof_id_type _local_row_index = std::numeric_limits<dof_id_type>::max();
116 
118  const std::vector<bool> * _should_run = nullptr;
119 };
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 void backup() override
This method is overridden so that we only store the initial state and not on any other timestep when ...
virtual bool solveStep(Real dt, Real target_time, bool auto_advance=true) override
const InputParameters & parameters() const
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
uint8_t dof_id_type