WebServerControl

The WebServerControl object is designed to allow an external process to control a MOOSE solve. It works by starting up a webserver on the chosen "port" and exposing a REST API. As with all REST APIs the input and output are both JSON.

It can then be managed via the MooseControl python utility.

API

The WebServerControl presents REST endpoints to help control the solve.

For the endpoints that follow, if the HTTP status code received is a non-successful code, there may be a response of type application/json of the form:


{
  "error": "<ERROR>"
}

where <ERROR> is a useful error message pertaining to the error that was encountered. The response is not guaranteed to contain application/json data, but it will when more context is available.

The REST endpoints are as follows:

check

Used to determine if the MOOSE webserver is currently listening. This doesn't necessarily mean that it is waiting for input.

Interact with this endpoint by a GET request to /check. On success, the status code will be 200.

waiting

Used to determine of MOOSE is currently waiting within the WebServerControl, i.e., that Control is waiting for external input. The rest of the endpoints that follow require that the control is currently waiting for input.

Interact with this endpoint by a GET request to /waiting without any data. If the control is currently waiting, the response will be of type application/json of the form:


{
  "waiting": True
  "execute_on_flag": "<EXEC_ON_FLAG>"
}

where <EXEC_ON_FLAG> is the current execution flag. If the control is not currently waiting, the response will be a response of type application/json of the form:


{
  "waiting": False
}

This endpoint can be accessed via the MooseControl python utility via the following methods:

  • wait(): Waits for the control to be waiting

  • getWaitingFlag(): Gets the current flag that the control is waiting on, if any

  • isWaiting(): Whether or not the control is currently waiting

get/postprocessor

Used to obtain the value of a postprocessor. The control must be waiting in order to access this endpoint.

Interact with this endpoint by a POST request to /get/postprocessor with the following application/json data:


{
  "name": "<NAME>"
}

where <NAME> is the name of the postprocessor whose value you wish to receive. The response will be of the form:


{
  "value": <VALUE>
}

set/controllable

Used to change a controllable parameter in the simulation. The control must be waiting in order to access this endpoint.

The following parameter types are currently supported by the endpoint:

  • bool

  • Real

  • std::string

  • std::vector<Real>

  • std::vector<std::string>

These types can be extended by the registerWebServerControl[Scalar/Vector][BoolNumberString] registration methods in the source for the WebServerControl.

Interact with this endpoint by a POST request to /set/controllable with the following application/json data:


{
  "name": "<NAME>",
  "type" "<TYPE>",
  "value": <VALUE>
}

where <NAME> is the string path to the controllable parameter, <TYPE> is the string version of the C++ parameter type, and <VALUE> is the value to set the parameter to. The type of <VALUE> depends on the controllable parameter type.

On success, the response will be empty with a status code of 201.

This endpoint can be accessed via the MooseControl python utility via the following methods:

  • setControllableBool(): Sets a controllable bool parameter

  • setControllableReal(): Sets a controllable Real parameter

  • setControllableVectorReal(): Sets a controllable std::vector<Real> parameter

  • setControllableString(): Sets a controllable std::string parameter

  • setControllableVectorString(): Sets a controllable std::vector<std::string> parameter

continue

Tells a waiting control to continue with the execution. The control must be waiting in order to access this endpoint.

Interact with this endpoint by a GET request to /continue. On success, the response will be empty with a status code of 200.

Input Parameters

  • portThe port to utilize. Note that normally you don't have access to ports lower than 1024

    C++ Type:unsigned int

    Controllable:No

    Description:The port to utilize. Note that normally you don't have access to ports lower than 1024

Required Parameters

  • depends_onThe Controls that this control relies upon (i.e. must execute before this one)

    C++ Type:std::vector<std::string>

    Controllable:No

    Description:The Controls that this control relies upon (i.e. must execute before this one)

  • execute_onINITIAL TIMESTEP_ENDThe list of flag(s) indicating when this object should be executed, the available options include NONE, INITIAL, LINEAR, NONLINEAR, POSTCHECK, TIMESTEP_END, TIMESTEP_BEGIN, MULTIAPP_FIXED_POINT_END, MULTIAPP_FIXED_POINT_BEGIN, FINAL, CUSTOM.

    Default:INITIAL TIMESTEP_END

    C++ Type:ExecFlagEnum

    Options:NONE, INITIAL, LINEAR, NONLINEAR, POSTCHECK, TIMESTEP_END, TIMESTEP_BEGIN, MULTIAPP_FIXED_POINT_END, MULTIAPP_FIXED_POINT_BEGIN, FINAL, CUSTOM, PRE_MULTIAPP_SETUP

    Controllable:No

    Description:The list of flag(s) indicating when this object should be executed, the available options include NONE, INITIAL, LINEAR, NONLINEAR, POSTCHECK, TIMESTEP_END, TIMESTEP_BEGIN, MULTIAPP_FIXED_POINT_END, MULTIAPP_FIXED_POINT_BEGIN, FINAL, CUSTOM.

Optional Parameters

  • control_tagsAdds user-defined labels for accessing object parameters via control logic.

    C++ Type:std::vector<std::string>

    Controllable:No

    Description:Adds user-defined labels for accessing object parameters via control logic.

  • enableTrueSet the enabled status of the MooseObject.

    Default:True

    C++ Type:bool

    Controllable:No

    Description:Set the enabled status of the MooseObject.

  • implicitTrueDetermines whether this object is calculated using an implicit or explicit form

    Default:True

    C++ Type:bool

    Controllable:No

    Description:Determines whether this object is calculated using an implicit or explicit form

Advanced Parameters