https://mooseframework.inl.gov
ParameterStudyAction.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 #include "Action.h"
13 #include "hit/hit.h"
14 
15 // Forward declarations
16 class ReporterName;
17 
19 {
20 public:
22 
23  ParameterStudyAction(const InputParameters & params);
24 
25  virtual void act() override;
26 
28  static MooseEnum samplingTypes();
31 
32 protected:
39  DistributionName distributionName(unsigned int count) const;
40  std::vector<DistributionName> distributionNames(unsigned int full_count) const;
41 
47  SamplerName samplerName() const { return "study_sampler"; }
48 
54  MultiAppName multiappName() const { return "study_app"; }
55 
61  std::string samplerReceiverName() const { return "study_receiver"; }
62 
68  std::string multiappControlName() const { return "study_multiapp_control"; }
69 
75  std::string parameterTransferName() const { return "study_parameter_transfer"; }
76 
82  std::string reporterTransferName() const { return "study_qoi_transfer"; }
83 
89  std::string stochasticReporterName() const { return "study_results"; }
90 
97  OutputName outputName(std::string type) const { return type; }
98 
106 
112  std::string statisticsName() const { return "study_statistics"; }
113 
122  template <typename T>
123  T getDistributionParam(std::string param, unsigned int count) const;
124 
136  void showObject(std::string type, std::string name, const InputParameters & params) const;
137 
138 private:
143  static std::vector<std::map<std::string, bool>> samplerParameters();
144 
148  static std::vector<std::vector<std::string>> distributionParameters();
149 
153  static std::set<std::string> statisticsParameters();
154 
161  unsigned int inferMultiAppMode();
162 
164  const std::vector<std::string> & _parameters;
166  const unsigned int _sampling_type;
171  const unsigned int _multiapp_mode;
173  const bool _compute_stats;
175  const bool _show_objects;
176 };
177 
178 template <typename T>
179 T
180 ParameterStudyAction::getDistributionParam(std::string param, unsigned int count) const
181 {
182  const auto & val = getParam<std::vector<T>>(param);
183  return val[count];
184 }
185 
189 class AreParametersControllableWalker : public hit::Walker
190 {
191 public:
192  AreParametersControllableWalker(const std::vector<std::string> & parameters, MooseApp & app);
193 
194  void walk(const std::string & fullpath, const std::string & nodename, hit::Node * n) override;
195  bool areControllable() const;
196 
197 private:
199  std::vector<bool> _is_controllable;
200  std::vector<std::pair<std::string, std::string>> _pars;
201 };
202 
206 class ExecutionTypeWalker : public hit::Walker
207 {
208 public:
210 
211  void walk(const std::string & fullpath, const std::string & nodename, hit::Node * n) override;
212  unsigned int getExecutionType() const { return _exec_type; }
213 
214 private:
215  unsigned int _exec_type;
217 };
SamplerName samplerName() const
The perscribed name of the sampler created in this action.
unsigned int getExecutionType() const
DistributionName distributionName(unsigned int count) const
The perscribed name of the distribution.
std::string statisticsName() const
The perscribed name of the statistics object created in this action.
This class is a hit walker used to see what type of execution the input is doing. ...
const unsigned int _sampling_type
The sampling type.
const unsigned int _multiapp_mode
The multiapp mode.
const bool _show_objects
Switch to show the objects being built on console.
virtual const std::string & name() const
std::string samplerReceiverName() const
The perscribed name of the control given to the sub-app for parameter transfer.
virtual void act() override
std::string multiappControlName() const
The perscribed name of the command-line control created in this action.
const MultiMooseEnum _distributions
The distributions.
std::vector< DistributionName > distributionNames(unsigned int full_count) const
std::string stochasticReporterName() const
The perscribed name of the QoI storage object created in this action.
static MooseEnum samplingTypes()
Return an enum of available sampling types for the study.
void walk(const std::string &fullpath, const std::string &nodename, hit::Node *n) override
ParameterStudyAction(const InputParameters &params)
std::string reporterTransferName() const
The perscribed name of the reporter transfer created in this action.
void walk(const std::string &fullpath, const std::string &nodename, hit::Node *n) override
void showObject(std::string type, std::string name, const InputParameters &params) const
Helper function to show the object being built.
const std::string & type() const
OutputName outputName(std::string type) const
The perscribed name of the output objects created in this action.
AreParametersControllableWalker(const std::vector< std::string > &parameters, MooseApp &app)
ReporterName quantityOfInterestName(const ReporterName &qoi) const
The name of the reporter values in the StochasticReporter representing the QoIs.
static std::set< std::string > statisticsParameters()
List of parameters that are only associated with computing statistics.
T getDistributionParam(std::string param, unsigned int count) const
Helper function for getting the param value for the distribution index.
std::vector< std::pair< std::string, std::string > > _pars
const std::vector< std::string > & _parameters
The inputted parameter vector.
static std::vector< std::map< std::string, bool > > samplerParameters()
This is a vector associating the sampling type with a list of associated parameters The list includes...
static std::vector< std::vector< std::string > > distributionParameters()
This is a vector associating the distribution type and a list of parameters that are needed...
std::string parameterTransferName() const
The perscribed name of the parameter transfer created in this action.
MultiAppName multiappName() const
The perscribed name of the multiapp created in this action.
unsigned int inferMultiAppMode()
This function will infer the best way to run the multiapps.
const bool _compute_stats
Whether or not we are computing statistics.
static InputParameters validParams()
static MultiMooseEnum distributionTypes()
Return an enum of available distributions for the study.
This class is a hit walker used to see if a list of parameters are all controllable.