LCOV - code coverage report
Current view: top level - src/interfaces - SurrogateModelInterface.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: f45d79 Lines: 18 21 85.7 %
Date: 2025-07-25 05:00:46 Functions: 5 6 83.3 %
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             : #include "SurrogateModelInterface.h"
      11             : #include "SurrogateTrainer.h"
      12             : #include "SurrogateModel.h"
      13             : #include "SubProblem.h"
      14             : #include "MooseTypes.h"
      15             : 
      16             : InputParameters
      17       11858 : SurrogateModelInterface::validParams()
      18             : {
      19       11858 :   return emptyInputParameters();
      20             : }
      21             : 
      22        5162 : SurrogateModelInterface::SurrogateModelInterface(const MooseObject * moose_object)
      23        5162 :   : _smi_params(moose_object->parameters()),
      24        5162 :     _smi_feproblem(*_smi_params.get<FEProblemBase *>("_fe_problem_base")),
      25        5162 :     _smi_tid(_smi_params.have_parameter<THREAD_ID>("_tid") ? _smi_params.get<THREAD_ID>("_tid") : 0)
      26             : {
      27        5162 : }
      28             : 
      29             : template <>
      30             : SurrogateModel &
      31        1220 : SurrogateModelInterface::getSurrogateModelByName(const UserObjectName & name) const
      32             : {
      33             :   std::vector<SurrogateModel *> models;
      34        1220 :   _smi_feproblem.theWarehouse()
      35        1220 :       .query()
      36        1220 :       .condition<AttribName>(name)
      37        1220 :       .condition<AttribSystem>("SurrogateModel")
      38             :       .queryInto(models);
      39        1220 :   if (models.empty())
      40           0 :     mooseError("Unable to find a SurrogateModel object with the name '" + name + "'");
      41        1220 :   return *(models[0]);
      42             : }
      43             : 
      44             : template <>
      45             : SurrogateModel &
      46          56 : SurrogateModelInterface::getSurrogateModel(const std::string & name) const
      47             : {
      48          56 :   return getSurrogateModelByName<SurrogateModel>(_smi_params.get<UserObjectName>(name));
      49             : }
      50             : 
      51             : template <>
      52             : SurrogateTrainerBase &
      53        1179 : SurrogateModelInterface::getSurrogateTrainerByName(const UserObjectName & name) const
      54             : {
      55        1179 :   return _smi_feproblem.getUserObject<SurrogateTrainerBase>(name);
      56             : }
      57             : 
      58             : template <>
      59             : SurrogateTrainerBase &
      60           0 : SurrogateModelInterface::getSurrogateTrainer(const std::string & name) const
      61             : {
      62           0 :   return getSurrogateTrainerByName<SurrogateTrainerBase>(_smi_params.get<UserObjectName>(name));
      63             : }

Generated by: LCOV version 1.14