www.mooseframework.org
MonteCarloSampler.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #include "MonteCarloSampler.h"
11 #include "Distribution.h"
12 
13 registerMooseObjectAliased("StochasticToolsApp", MonteCarloSampler, "MonteCarlo");
14 registerMooseObjectReplaced("StochasticToolsApp",
16  "07/01/2020 00:00",
17  MonteCarlo);
18 
21 {
23  params.addClassDescription("Monte Carlo Sampler.");
24  params.addRequiredParam<dof_id_type>("num_rows", "The number of rows per matrix to generate.");
25  params.addRequiredParam<std::vector<DistributionName>>(
26  "distributions",
27  "The distribution names to be sampled, the number of distributions provided defines the "
28  "number of columns per matrix.");
29  return params;
30 }
31 
33  : Sampler(parameters),
34  _distribution_names(getParam<std::vector<DistributionName>>("distributions"))
35 {
36  for (const DistributionName & name : _distribution_names)
38 
39  setNumberOfRows(getParam<dof_id_type>("num_rows"));
41 }
42 
43 Real
45 {
46  return _distributions[col_index]->quantile(getRand());
47 }
void setNumberOfRows(dof_id_type n_rows)
registerMooseObjectAliased("StochasticToolsApp", MonteCarloSampler, "MonteCarlo")
std::vector< Distribution const * > _distributions
Storage for distribution objects to be utilized.
A class used to perform Monte Carlo Sampling.
static InputParameters validParams()
virtual Real computeSample(dof_id_type row_index, dof_id_type col_index) override
Return the sample for the given row and column.
Real getRand(unsigned int index=0)
virtual const std::string & name() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
const Distribution & getDistributionByName(const DistributionName &name) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void setNumberOfCols(dof_id_type n_cols)
MonteCarloSampler(const InputParameters &parameters)
void addClassDescription(const std::string &doc_string)
const std::vector< DistributionName > & _distribution_names
Distribution names.
registerMooseObjectReplaced("StochasticToolsApp", MonteCarloSampler, "07/01/2020 00:00", MonteCarlo)
uint8_t dof_id_type