130 mooseError(
"This method should be overridden in adaptive sampling classes.");
194 uint32_t
getRandl(
unsigned int index, uint32_t lower, uint32_t upper);
256 template <
typename T>
257 void shuffle(std::vector<T> & data,
258 const std::size_t seed_index = 0,
310 const std::string &
name,
320 friend void FEProblemBase::objectExecuteHelper<Sampler>(
const std::vector<Sampler *> & objects);
385 template <
typename T>
390 MooseUtils::shuffle<T>(data,
_generator, seed_index,
nullptr);
391 else if (method == CommMethod::LOCAL)
393 else if (method == CommMethod::SEMI_LOCAL)
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...
void init()
Functions called by MOOSE to setup the Sampler for use.
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.
void advanceGeneratorsInternal(const dof_id_type count)
Advance method for internal use that considers the auto advance flag.
DenseMatrix< Real > getLocalSamples()
dof_id_type _local_row_begin
Global row index for start of data for this processor.
void shuffle(std::vector< T > &data, const std::size_t seed_index=0, const CommMethod method=CommMethod::LOCAL)
Helper for shuffling a vector of data in-place; the default assumes data is distributed.
uint32_t getRandl(unsigned int index, uint32_t lower, uint32_t upper)
Get the next random integer from the generator within the specified range [lower, upper) ...
MooseRandom _generator
Random number generator, don't give users access. Control it via the interface from this class...
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.
static InputParameters validParams()
virtual void advanceGenerators(const dof_id_type count)
Method for advancing the random number generator(s) by the supplied number or calls to rand()...
This is the base class for Samplers as used within the Stochastic Tools module.
dof_id_type _n_local_rows
Number of rows for this processor.
virtual void executeSetUp()
Callbacks for before and after execute.
void saveState()
This method saves the current state of all generators which can be restored at a later time (i...
DenseMatrix< Real > getGlobalSamples()
Return the sampled complete or distributed sample data.
Interface for objects that need to use samplers.
virtual void advanceGenerator(const unsigned int seed_index, const dof_id_type count)
std::vector< Real > getNextLocalRow()
Return the "next" local row.
virtual void sampleTearDown(const SampleMode)
dof_id_type getLocalRowBegin() const
Return the beginning/end local row index for this processor.
void checkReinitStatus() const
Helper function for reinit() errors.
const Parallel::Communicator & _communicator
virtual void computeLocalSampleMatrix(DenseMatrix< Real > &matrix)
const dof_id_type _max_procs_per_row
The maximum number of processors that are associated with a set of rows.
void restoreGeneratorState()
virtual void computeSampleMatrix(DenseMatrix< Real > &matrix)
Methods to populate the global or local sample matrix.
const dof_id_type _limit_get_next_local_row
Max number of entries for matrix returned by getNextLocalRow.
dof_id_type getNumberOfLocalRows() const
Real getRand(unsigned int index=0)
Get the next random number from the generator.
virtual const std::string & name() const
Get the name of the class.
Sampler(const InputParameters ¶meters)
virtual void computeSampleRow(dof_id_type i, std::vector< Real > &data)
Method to populate a complete row of sample data.
virtual bool isAdaptiveSamplingCompleted() const
Returns true if the adaptive sampling is completed.
bool _needs_reinit
Flag to indicate if the reinit method should be called during execute.
libMesh::Parallel::Communicator & getLocalComm()
Return the parallel communicator.
const dof_id_type _limit_get_global_samples
Max number of entries for matrix returned by getGlobalSamples.
Every object that can be built by the factory should be derived from this class.
const dof_id_type _limit_get_local_samples
Max number of entries for matrix returned by getLocalSamples.
Interface for objects that need to use distributions.
Interface to allow object to consume Reporter values.
const std::string & type() const
Get the type of this class.
void saveGeneratorState()
Here we save/restore generator states.
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::size_t _n_seeds
Number of seeds.
const LocalRankConfig & getRankConfig(bool batch_mode) const
Reference to rank configuration defining the partitioning of the sampler matrix This is primarily use...
void restoreState()
This method restores the last saved generator state.
bool _has_executed
Flag for initial execute to allow the first set of random numbers to be always be the same...
Interface for objects interacting with the PerfGraph.
virtual LocalRankConfig constructRankConfig(bool batch_mode) const
This is where the sampler partitioning is defined.
dof_id_type getLocalRowEnd() const
const dof_id_type _min_procs_per_row
The minimum number of processors that are associated with a set of rows.
libMesh::Parallel::Communicator _local_comm
Communicator that was split based on samples that have rows.
dof_id_type _local_row_end
Global row index for end of data for this processor.
dof_id_type getNumberOfRows() const
Return the number of samples.
virtual void sampleSetUp(const SampleMode)
Setup method called prior and after looping through distributions.
void setAutoAdvanceGenerators(const bool state)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void setNumberOfCols(dof_id_type n_cols)
virtual void executeTearDown()
bool _initialized
Flag to indicate if the init method for this class was called.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const InputParameters & parameters() const
Get the parameters of the object.
bool _auto_advance_generators
Flag for disabling automatic generator advancing.
bool _next_local_row_requires_state_restore
Flag for restoring state during getNextLocalRow iteration.
Holds app partitioning information relevant to the a particular rank for a multiapp scenario...
dof_id_type _n_rows
Total number of rows in the sample matrix.
void execute()
Store the state of the MooseRandom generator so that new calls to getGlobalSamples/getLocalSamples me...
dof_id_type _n_cols
Total number of columns in the sample matrix.
CommMethod
Enum describing the type of parallel communication to perform.
dof_id_type getNumberOfCols() const
This class encapsulates a useful, consistent, cross-platform random number generator with multiple ut...
void setNumberOfRandomSeeds(std::size_t number)
Set the number of seeds required by the sampler.
dof_id_type _next_local_row
Iterator index for getNextLocalRow method.