https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SurrogateTrainerOutput.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// Moose includes
12#include "SurrogateTrainer.h"
13#include "FEProblem.h"
15
17
20{
22 params.addClassDescription("Output for trained surrogate model data.");
23 params.addRequiredParam<std::vector<UserObjectName>>(
24 "trainers", "A list of SurrogateTrainer objects to output.");
25 return params;
26}
27
29 : FileOutput(parameters),
31 _trainers(getParam<std::vector<UserObjectName>>("trainers"))
32{
33}
34
35void
37{
38 if (processor_id() == 0)
39 for (const auto & surrogate_name : _trainers)
40 {
41 const SurrogateTrainerBase & trainer = getSurrogateTrainerByName(surrogate_name);
42 const auto filename =
43 RestartableDataIO::restartableDataFolder(this->filename() + "_" + surrogate_name);
45
46 RestartableDataWriter writer(_app, meta_data);
47 writer.write(filename);
48 }
49}
registerMooseObject("StochasticToolsApp", SurrogateTrainerOutput)
virtual std::string filename()
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
RestartableDataMap & getRestartableDataMap(const RestartableDataMapName &name)
MooseApp & _app
static std::filesystem::path restartableDataFolder(const std::filesystem::path &folder_base)
void write(std::ostream &header_stream, std::ostream &data_stream)
const std::string & modelMetaDataName() const
Accessor for the name of the model meta data.
Interface for objects that need to use samplers.
T & getSurrogateTrainerByName(const UserObjectName &name) const
This is the base trainer class whose main functionality is the API for declaring model data.
Output object for saving SurrorateModel data to a file.
static InputParameters validParams()
virtual void output() override
const std::vector< UserObjectName > & _trainers
List of supplied SurrogateModel objects.
SurrogateTrainerOutput(const InputParameters &parameters)
processor_id_type processor_id() const