50 std::string prefix =
"")
override;
124 params.
addRequiredParam<SamplerName>(
"sampler",
"The sampler used to produce data.");
131 _sampler(this->template getSampler<
Sampler>(
"sampler")),
132 _need_sample(this->template declareStochasticReporter<bool>(
"need_sample", _sampler))
141 if (_input_data_requested)
144 _input_data.resize(_sampler.getNumberOfRows());
145 for (
const auto i : make_range(_sampler.getNumberOfRows()))
146 _input_data[i] = _sampler.getSampleRow(i);
148 if (_output_data_requested)
151 mooseError(
"Output data has been requested, but none was declared in this object.");
152 _output_data = *_data;
153 _communicator.allgather(_output_data);
164 for (dof_id_type i = 0, global_i = _sampler.getLocalRowBegin();
165 i < _sampler.getNumberOfLocalRows();
168 needSample(_sampler.getSampleRow(global_i), i, global_i, (_data ? (*_data)[i] : dummy));
180 this->
mooseError(type(),
" can only declare a single reporter value.");
182 else if (sampler.
name() != _sampler.name())
183 this->paramError(
"sampler",
184 "Inputted sampler, ",
186 ", is not the same as the one producing data, ",
191 this->
mooseError(
"Reporter value ", from_reporter,
" has not been declared.");
195 type(),
" can only use reporter values of type ", MooseUtils::prettyCppType<T>(),
".");
197 std::string value_name = (prefix.empty() ?
"" : prefix +
":") + from_reporter.
getObjectName() +
199 _data = &this->declareStochasticReporter<T>(value_name, sampler);
200 return {
name(), value_name};
void mooseError(Args &&... args)
This is a base class for performing active learning routines, meant to be used in conjunction with Sa...
const std::vector< std::vector< Real > > & getGlobalInputData() const
const Sampler & sampler() const
Get a const reference to the sampler from the parameters.
static InputParameters validParams()
virtual void execute() override
Here we loop through the samples and call the needSample function to determine if the sample needs to...
bool _output_data_requested
Whether or not to gather global output data.
ActiveLearningReporterTempl(const InputParameters ¶meters)
virtual ReporterName declareStochasticReporterClone(const Sampler &sampler, const ReporterData &from_data, const ReporterName &from_reporter, std::string prefix="") override
This is overriden for the following reasons: 1) Only one vector can be declared and must match the ty...
std::vector< T > _output_data
Global output data from sampler.
bool _input_data_requested
Whether or not to gather global input data.
std::vector< bool > & _need_sample
Reporter value determining whether we need to evaluate the sample through a multiapp or other means.
virtual bool needSample(const std::vector< Real > &, dof_id_type, dof_id_type, T &)
This routine is called during the sampler loop in execute() and is meant to fill in the "need_sample"...
virtual void preNeedSample()
Optional virtual function that is called before the sampler loop calling needSample.
const std::vector< T > & getGlobalOutputData() const
Get a const reference to the output data.
Sampler & _sampler
Sampler given in the parameters, must match the one used to declare the transferred values.
std::vector< std::vector< Real > > _input_data
Global input data from sampler.
std::vector< T > * _data
Reporter value declared with the transfer.
const InputParameters & parameters() const
const std::string & name() const
bool hasReporterValue(const ReporterName &reporter_name) const
const std::string & getObjectName() const
const std::string & getValueName() const
static InputParameters validParams()