https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
16class ReporterName;
17
19{
20public:
22
24
25 virtual void act() override;
26
28 static MooseEnum samplingTypes();
31
32protected:
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
138private:
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
178template <typename T>
179T
180ParameterStudyAction::getDistributionParam(std::string param, unsigned int count) const
181{
182 const auto & val = getParam<std::vector<T>>(param);
183 return val[count];
184}
185
189class AreParametersControllableWalker : public hit::Walker
190{
191public:
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
197private:
199 std::vector<bool> _is_controllable;
200 std::vector<std::pair<std::string, std::string>> _pars;
201};
202
206class ExecutionTypeWalker : public hit::Walker
207{
208public:
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
214private:
215 unsigned int _exec_type;
217};
const double T
unsigned int count
This class is a hit walker used to see if a list of parameters are all controllable.
std::vector< std::pair< std::string, std::string > > _pars
void walk(const std::string &fullpath, const std::string &nodename, hit::Node *n) override
This class is a hit walker used to see what type of execution the input is doing.
unsigned int getExecutionType() const
void walk(const std::string &fullpath, const std::string &nodename, hit::Node *n) override
const std::string & type() const
const std::string & name() const
OutputName outputName(std::string type) const
The perscribed name of the output objects created in this action.
DistributionName distributionName(unsigned int count) const
The perscribed name of the distribution.
static InputParameters validParams()
std::string stochasticReporterName() const
The perscribed name of the QoI storage object created in this action.
std::vector< DistributionName > distributionNames(unsigned int full_count) const
static MultiMooseEnum distributionTypes()
Return an enum of available distributions for the study.
ReporterName quantityOfInterestName(const ReporterName &qoi) const
The name of the reporter values in the StochasticReporter representing the QoIs.
const unsigned int _multiapp_mode
The multiapp mode.
SamplerName samplerName() const
The perscribed name of the sampler created in this action.
std::string statisticsName() const
The perscribed name of the statistics object created in this action.
unsigned int inferMultiAppMode()
This function will infer the best way to run the multiapps.
std::string multiappControlName() const
The perscribed name of the command-line control created in this action.
const std::vector< std::string > & _parameters
The inputted parameter vector.
virtual void act() override
const unsigned int _sampling_type
The sampling type.
MultiAppName multiappName() const
The perscribed name of the multiapp created in this action.
std::string samplerReceiverName() const
The perscribed name of the control given to the sub-app for parameter transfer.
void showObject(std::string type, std::string name, const InputParameters &params) const
Helper function to show the object being built.
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.
static std::vector< std::vector< std::string > > distributionParameters()
This is a vector associating the distribution type and a list of parameters that are needed.
const MultiMooseEnum _distributions
The distributions.
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...
std::string parameterTransferName() const
The perscribed name of the parameter transfer created in this action.
std::string reporterTransferName() const
The perscribed name of the reporter transfer created in this action.
const bool _compute_stats
Whether or not we are computing statistics.
static MooseEnum samplingTypes()
Return an enum of available sampling types for the study.
const bool _show_objects
Switch to show the objects being built on console.