LCOV - code coverage report
Current view: top level - src/outputs - SurrogateTrainerOutput.C (source / functions) Hit Total Coverage
Test: idaholab/moose stochastic_tools: f45d79 Lines: 17 18 94.4 %
Date: 2025-07-25 05:00:46 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             : // Moose includes
      11             : #include "SurrogateTrainerOutput.h"
      12             : #include "SurrogateTrainer.h"
      13             : #include "FEProblem.h"
      14             : #include "RestartableDataWriter.h"
      15             : 
      16             : registerMooseObject("StochasticToolsApp", SurrogateTrainerOutput);
      17             : 
      18             : InputParameters
      19         860 : SurrogateTrainerOutput::validParams()
      20             : {
      21         860 :   InputParameters params = FileOutput::validParams();
      22         860 :   params.addClassDescription("Output for trained surrogate model data.");
      23        1720 :   params.addRequiredParam<std::vector<UserObjectName>>(
      24             :       "trainers", "A list of SurrogateTrainer objects to output.");
      25         860 :   return params;
      26           0 : }
      27             : 
      28         418 : SurrogateTrainerOutput::SurrogateTrainerOutput(const InputParameters & parameters)
      29             :   : FileOutput(parameters),
      30             :     SurrogateModelInterface(this),
      31         836 :     _trainers(getParam<std::vector<UserObjectName>>("trainers"))
      32             : {
      33         418 : }
      34             : 
      35             : void
      36         426 : SurrogateTrainerOutput::output()
      37             : {
      38         426 :   if (processor_id() == 0)
      39         620 :     for (const auto & surrogate_name : _trainers)
      40             :     {
      41         365 :       const SurrogateTrainerBase & trainer = getSurrogateTrainerByName(surrogate_name);
      42             :       const auto filename =
      43         730 :           RestartableDataIO::restartableDataFolder(this->filename() + "_" + surrogate_name);
      44         365 :       RestartableDataMap & meta_data = _app.getRestartableDataMap(trainer.modelMetaDataName());
      45             : 
      46         365 :       RestartableDataWriter writer(_app, meta_data);
      47         365 :       writer.write(filename);
      48             :     }
      49         426 : }

Generated by: LCOV version 1.14