LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - GaussianProcessData.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: #31405 (292dce) with base fef103 Lines: 21 22 95.5 %
Date: 2025-09-04 07:57:52 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          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         446 : GaussianProcessData::validParams()
      17             : {
      18         446 :   InputParameters params = GeneralVectorPostprocessor::validParams();
      19         446 :   params += SurrogateModelInterface::validParams();
      20         446 :   params.addClassDescription(
      21             :       "Tool for extracting hyperparameter data from gaussian process user object and "
      22             :       "storing in VectorPostprocessor vectors.");
      23         892 :   params.addRequiredParam<UserObjectName>("gp_name", "Name of GaussianProcess.");
      24         446 :   return params;
      25           0 : }
      26             : 
      27         221 : GaussianProcessData::GaussianProcessData(const InputParameters & parameters)
      28             :   : GeneralVectorPostprocessor(parameters),
      29             :     SurrogateModelInterface(this),
      30         221 :     _gp_surrogate(getSurrogateModel<GaussianProcessSurrogate>("gp_name"))
      31             : {
      32         221 : }
      33             : 
      34             : void
      35         221 : GaussianProcessData::initialize()
      36             : {
      37             :   const std::unordered_map<std::string, Real> & _hyperparam_map =
      38         442 :       _gp_surrogate.getGP().getHyperParamMap();
      39             :   const std::unordered_map<std::string, std::vector<Real>> & _hyperparam_vec_map =
      40             :       _gp_surrogate.getGP().getHyperParamVectorMap();
      41             : 
      42         748 :   for (auto iter = _hyperparam_map.begin(); iter != _hyperparam_map.end(); ++iter)
      43             :   {
      44         527 :     _hp_vector.push_back(&declareVector(iter->first));
      45         527 :     _hp_vector.back()->push_back(iter->second);
      46             :   }
      47         544 :   for (auto iter = _hyperparam_vec_map.begin(); iter != _hyperparam_vec_map.end(); ++iter)
      48             :   {
      49         323 :     std::vector<Real> vec = iter->second;
      50         952 :     for (unsigned int ii = 0; ii < vec.size(); ++ii)
      51             :     {
      52        1887 :       _hp_vector.push_back(&declareVector(iter->first + std::to_string(ii)));
      53         629 :       _hp_vector.back()->push_back(vec[ii]);
      54             :     }
      55         323 :   }
      56         221 : }

Generated by: LCOV version 1.14