https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
38void
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
58Real
60{
61 // Return the value of the control signal
63}
64
65#endif
registerMooseObject("MooseApp", LibtorchControlValuePostprocessor)
void ErrorVector unsigned int
ExecuteMooseObjectWarehouse< Control > & getControlWarehouse()
Reference to the control logic warehouse.
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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...
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.
A class for querying output signals from LibtorchNeuralNetControl and derived objects.
const LibtorchNeuralNetControl * _libtorch_nn_control
LibtorchControlValuePostprocessor(const InputParameters &parameters)
Class constructor.
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.
A time-dependent, neural network-based control of multiple input parameters.
Real getSignal(const unsigned int signal_index) const
Get the (signal_index)-th signal of the control neural net.
unsigned int numberOfControlSignals() const
Get the number of controls this object is computing.
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 ...
Definition MooseBase.h:457
std::shared_ptr< T > getActiveObject(const std::string &name, THREAD_ID tid=0) const
virtual void initialSetup()
Gets called at the beginning of the simulation before this object is asked to do its job.
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.