https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TestLikelihood.C
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#include "TestLikelihood.h"
11#include "Sampler.h"
12
13registerMooseObject("StochasticToolsTestApp", TestLikelihood);
14
17{
20 params.addClassDescription("Reporter to test a likelihood object.");
21 params.addParam<ReporterValueName>(
22 "function", "function", "Value of the density or mass function.");
23 params.addRequiredParam<std::vector<UserObjectName>>("likelihoods", "Names of likelihoods.");
24 params.addRequiredParam<ReporterName>("model_pred", "Reporter with the model predictions.");
25 params.addParam<ReporterValueName>(
26 "model_pred_required",
27 "model_pred_required",
28 "Modified value of the model output from this reporter class.");
29 params.addRequiredParam<SamplerName>("sampler", "The sampler object.");
30 return params;
31}
32
34 : GeneralReporter(parameters),
35 LikelihoodInterface(parameters),
36 _function(declareValue<std::vector<Real>>("function")),
37 _model_pred(getReporterValue<std::vector<Real>>("model_pred", REPORTER_MODE_DISTRIBUTED)),
38 _model_pred_required(declareValue<std::vector<Real>>("model_pred_required")),
39 _sampler(getSampler("sampler")),
40 _local_comm(_sampler.getLocalComm())
41{
42 for (const UserObjectName & name : getParam<std::vector<UserObjectName>>("likelihoods"))
44
45 _function.resize(_likelihoods.size());
46}
47
48void
const ReporterMode REPORTER_MODE_DISTRIBUTED
registerMooseObject("StochasticToolsTestApp", TestLikelihood)
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
LikelihoodFunctionBase * getLikelihoodFunctionByName(const UserObjectName &name) const
Lookup a LikelihoodFunction object by name and return pointer.
const std::string & name() const
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
TestLikelihood will help test new likelihood objects.
TestLikelihood(const InputParameters &parameters)
static InputParameters validParams()
std::vector< Real > & _function
Value of the density or mass function.
const std::vector< Real > & _model_pred
model prediction values
virtual void execute() override
std::vector< Real > & _model_pred_required
Transfer the right outputs to the file.
std::vector< const LikelihoodFunctionBase * > _likelihoods
Storage for the likelihood objects to be utilized.
libMesh::Parallel::Communicator & _local_comm
Communicator that was split based on samples that have rows.