https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
17
18class Sampler;
20
22 public SamplerInterface,
24{
25public:
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
72protected:
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
88private:
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 InputParameters & parameters() const
Sampler & _sampler
Sampler to utilize for creating MultiApps.
bool solveStepBatch(Real dt, Real target_time, bool auto_advance=true)
Helper method for running in mode='batch'.
virtual void showStatusMessage(unsigned int i) const override
Override to avoid 'solve converged' message and print when processors are finished.
void updateRowData(dof_id_type local_index)
Helper function for updating _row_data and _local_row_index.
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 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
const std::vector< bool > * _should_run
Reporter value determining whether the sub-app should be run for a certain sample.
virtual bool solveStep(Real dt, Real target_time, bool auto_advance=true) override
std::vector< std::shared_ptr< StochasticToolsTransfer > > getActiveStochasticToolsTransfers(Transfer::DIRECTION direction)
Helper for getting StochasticToolsTransfer objects.
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 std::vector< std::string > getCommandLineArgs(const unsigned int local_app) override
Override to allow for batch mode to get correct cli_args.
std::vector< Real > _row_data
Current row of data updated by updateRowData. Used by transfers and setting command line args.
static InputParameters validParams()
dof_id_type _local_row_index
Current local index representing _row_data.
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.
The class creates an additional API to allow Transfers to work when running the StochasticTools<FullS...