https://mooseframework.inl.gov
LibtorchControlValuePostprocessor.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 #ifdef MOOSE_LIBTORCH_ENABLED
11 
13 
15 
18 {
20 
21  params.addClassDescription("Reports the value stored in given controlled parameters.");
22 
23  params.addRequiredParam<std::string>("control_name",
24  "The name of the LibtorchNeuralNetControl object.");
25  params.addParam<unsigned int>("signal_index",
26  0,
27  "The index of the signal from the LibtorchNeuralNetControl object. "
28  "This assumes indexing between [0,num_signals).");
29  return params;
30 }
31 
33  : GeneralPostprocessor(params), _signal_index(getParam<unsigned int>("signal_index"))
34 
35 {
36 }
37 
38 void
40 {
42 
45  .getActiveObject(getParam<std::string>("control_name"))
46  .get());
48  paramError("control_name",
49  "The supplied control object is not derived from LibtorchNeuralNetControl!");
50 
52  paramError("signal_index",
53  "The given control object only has ",
55  " control signals!");
56 }
57 
58 Real
60 {
61  // Return the value of the control signal
63 }
64 
65 #endif
unsigned int numberOfControlSignals() const
Get the number of controls this object is computing.
A time-dependent, neural network-based control of multiple input parameters.
LibtorchControlValuePostprocessor(const InputParameters &parameters)
Class constructor.
Real getSignal(const unsigned int signal_index) const
Get the (signal_index)-th signal of the control neural net.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
static InputParameters validParams()
std::shared_ptr< T > getActiveObject(const std::string &name, THREAD_ID tid=0) const
const LibtorchNeuralNetControl * _libtorch_nn_control
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
registerMooseObject("MooseApp", LibtorchControlValuePostprocessor)
A class for querying output signals from LibtorchNeuralNetControl and derived objects.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:211
void initialSetup() override
We override this to setup the linking withthe control object.
virtual Real getValue() const override
Returns the value of the latest response of a neural-network-based controller.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
ExecuteMooseObjectWarehouse< Control > & getControlWarehouse()
Reference to the control logic warehouse.
virtual void initialSetup()
Gets called at the beginning of the simulation before this object is asked to do its job...
void ErrorVector unsigned int