Line data Source code
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 : // Stocastic Tools Includes 11 : #include "GaussianProcessData.h" 12 : 13 : registerMooseObject("StochasticToolsApp", GaussianProcessData); 14 : 15 : InputParameters 16 420 : GaussianProcessData::validParams() 17 : { 18 420 : InputParameters params = GeneralVectorPostprocessor::validParams(); 19 420 : params += SurrogateModelInterface::validParams(); 20 420 : params.addClassDescription( 21 : "Tool for extracting hyperparameter data from gaussian process user object and " 22 : "storing in VectorPostprocessor vectors."); 23 840 : params.addRequiredParam<UserObjectName>("gp_name", "Name of GaussianProcess."); 24 420 : return params; 25 0 : } 26 : 27 208 : GaussianProcessData::GaussianProcessData(const InputParameters & parameters) 28 : : GeneralVectorPostprocessor(parameters), 29 : SurrogateModelInterface(this), 30 208 : _gp_surrogate(getSurrogateModel<GaussianProcessSurrogate>("gp_name")) 31 : { 32 208 : } 33 : 34 : void 35 208 : GaussianProcessData::initialize() 36 : { 37 : const std::unordered_map<std::string, Real> & _hyperparam_map = 38 416 : _gp_surrogate.getGP().getHyperParamMap(); 39 : const std::unordered_map<std::string, std::vector<Real>> & _hyperparam_vec_map = 40 : _gp_surrogate.getGP().getHyperParamVectorMap(); 41 : 42 704 : for (auto iter = _hyperparam_map.begin(); iter != _hyperparam_map.end(); ++iter) 43 : { 44 496 : _hp_vector.push_back(&declareVector(iter->first)); 45 496 : _hp_vector.back()->push_back(iter->second); 46 : } 47 512 : for (auto iter = _hyperparam_vec_map.begin(); iter != _hyperparam_vec_map.end(); ++iter) 48 : { 49 304 : std::vector<Real> vec = iter->second; 50 896 : for (unsigned int ii = 0; ii < vec.size(); ++ii) 51 : { 52 1184 : _hp_vector.push_back(&declareVector(iter->first + std::to_string(ii))); 53 592 : _hp_vector.back()->push_back(vec[ii]); 54 : } 55 : } 56 208 : }