https://mooseframework.inl.gov
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
11 #include "SurrogateTrainerOutput.h"
12 #include "SurrogateTrainer.h"
13 #include "FEProblem.h"
14 #include "RestartableDataWriter.h"
15 
16 registerMooseObject("StochasticToolsApp", SurrogateTrainerOutput);
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 
35 void
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 }
void write(std::ostream &header_stream, std::ostream &data_stream)
virtual std::string filename()
SurrogateTrainerOutput(const InputParameters &parameters)
virtual void output() override
const std::vector< UserObjectName > & _trainers
List of supplied SurrogateModel objects.
RestartableDataMap & getRestartableDataMap(const RestartableDataMapName &name)
void addRequiredParam(const std::string &name, const std::string &doc_string)
Output object for saving SurrorateModel data to a file.
static InputParameters validParams()
static InputParameters validParams()
static std::filesystem::path restartableDataFolder(const std::filesystem::path &folder_base)
const std::string & modelMetaDataName() const
Accessor for the name of the model meta data.
MooseApp & _app
Interface for objects that need to use samplers.
void addClassDescription(const std::string &doc_string)
T & getSurrogateTrainerByName(const UserObjectName &name) const
This is the base trainer class whose main functionality is the API for declaring model data...
processor_id_type processor_id() const
registerMooseObject("StochasticToolsApp", SurrogateTrainerOutput)