132 mooseError(
"This method should be overridden in adaptive sampling classes.");
170 Real
getRand(std::size_t n,
unsigned int index = 0)
const;
183 getRandl(std::size_t n,
unsigned int lower,
unsigned int upper,
unsigned int index = 0)
const;
191 virtual Real
computeSample(dof_id_type row_index, dof_id_type col_index) = 0;
267 const std::string &
name,
274 friend void FEProblemBase::objectExecuteHelper<Sampler>(
const std::vector<Sampler *> & objects);
Interface for objects that need to use distributions.
virtual void addSampler(const std::string &type, const std::string &name, InputParameters ¶meters)
The following functions will enable MOOSE to have the capability to import Samplers.
const InputParameters & parameters() const
Get the parameters of the object.
const std::string & type() const
Get the type of this class.
const std::string & name() const
Get the name of the class.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Every object that can be built by the factory should be derived from this class.
Interface for objects interacting with the PerfGraph.
Interface to allow object to consume Reporter values.
Interface for objects that need to use samplers.
This is the base class for Samplers as used within the Stochastic Tools module.
virtual void advanceGenerator(const unsigned int seed_index, const dof_id_type count)
void checkReinitStatus() const
Helper function for reinit() errors.
void setNumberOfCols(dof_id_type n_cols)
const dof_id_type _limit_get_local_samples
Max number of entries for matrix returned by getLocalSamples.
dof_id_type _next_local_row
Iterator index for getNextLocalRow method.
dof_id_type _local_row_begin
Global row index for start of data for this processor.
std::pair< LocalRankConfig, LocalRankConfig > _rank_config
The partitioning of the sampler matrix, built in reinit() first is for normal mode and send is for ba...
std::vector< Real > getNextLocalRow()
Return the "next" local row.
Real getRand(std::size_t n, unsigned int index=0) const
Get nth random number from the generator.
const dof_id_type _limit_get_global_samples
Max number of entries for matrix returned by getGlobalSamples.
std::vector< std::unique_ptr< MooseRandomStateless > > _generators
Random number generators, don't give users access. Control it via the interface from this class.
void advanceGeneratorsInternal(const dof_id_type count)
Advance method for internal use that considers the auto advance flag.
bool _initialized
Flag to indicate if the init method for this class was called.
DenseMatrix< Real > getLocalSamples()
dof_id_type getNumberOfLocalRows() const
const dof_id_type _max_procs_per_row
The maximum number of processors that are associated with a set of rows.
void execute()
Advance MooseRandomStateless generators so that new calls to sample methods will create new numbers.
bool _has_executed
Flag for initial execute to allow the first set of random numbers to be always be the same.
dof_id_type _n_rows
Total number of rows in the sample matrix.
unsigned int getRandl(std::size_t n, unsigned int lower, unsigned int upper, unsigned int index=0) const
Get nth random integer from the generator within the specified range [lower, upper)
dof_id_type _n_cols
Total number of columns in the sample matrix.
dof_id_type _n_local_rows
Number of rows for this processor.
dof_id_type getLocalRowEnd() const
const dof_id_type _limit_get_next_local_row
Max number of entries for matrix returned by getNextLocalRow.
void init()
Functions called by MOOSE to setup the Sampler for use.
dof_id_type getLocalRowBegin() const
Return the beginning/end local row index for this processor.
bool _auto_advance_generators
Flag for disabling automatic generator advancing.
virtual Real computeSample(dof_id_type row_index, dof_id_type col_index)=0
Base class must override this method to supply the sample distribution data.
libMesh::Parallel::Communicator _local_comm
Communicator that was split based on samples that have rows.
virtual void executeSetUp()
Callbacks for before and after execute.
virtual LocalRankConfig constructRankConfig(bool batch_mode) const
This is where the sampler partitioning is defined.
dof_id_type getNumberOfRows() const
Return the number of samples.
const LocalRankConfig & getRankConfig(bool batch_mode) const
Reference to rank configuration defining the partitioning of the sampler matrix This is primarily use...
virtual void advanceGenerators(const dof_id_type count)
Method for advancing the random number generator(s) by the supplied number or calls to rand().
virtual void executeTearDown()
virtual void computeSampleMatrix(DenseMatrix< Real > &matrix)
Methods to populate the global or local sample matrix.
void setAutoAdvanceGenerators(const bool state)
bool _needs_reinit
Flag to indicate if the reinit method should be called during execute.
static InputParameters validParams()
virtual void computeLocalSampleMatrix(DenseMatrix< Real > &matrix)
std::size_t _n_seeds
Number of seeds.
libMesh::Parallel::Communicator & getLocalComm()
Return the parallel communicator.
dof_id_type getNumberOfCols() const
dof_id_type _local_row_end
Global row index for end of data for this processor.
void setNumberOfRows(dof_id_type n_rows)
These methods must be called within the constructor of child classes to define the size of the matrix...
bool _next_local_row_requires_state_restore
Flag for restoring state during getNextLocalRow iteration.
const dof_id_type _min_procs_per_row
The minimum number of processors that are associated with a set of rows.
virtual void computeSampleRow(dof_id_type i, std::vector< Real > &data)
Method to populate a complete row of sample data.
void setNumberOfRandomSeeds(std::size_t number)
Set the number of seeds required by the sampler.
DenseMatrix< Real > getGlobalSamples()
Return the sampled complete or distributed sample data.
virtual bool isAdaptiveSamplingCompleted() const
Returns true if the adaptive sampling is completed.
Holds app partitioning information relevant to the a particular rank for a multiapp scenario.