diff --git a/framework/src/controls/WebServerControl.C b/framework/src/controls/WebServerControl.C index ad0e102ebb05..3758142025bb 100644 --- a/framework/src/controls/WebServerControl.C +++ b/framework/src/controls/WebServerControl.C @@ -35,8 +35,10 @@ registerMooseObject("MooseApp", WebServerControl); // Registration of the types that we can accept in the web server for controlling parameters registerWebServerControlScalarBool(bool); registerWebServerControlScalarNumber(Real); +registerWebServerControlScalarNumber(int); registerWebServerControlScalarString(std::string); registerWebServerControlVectorNumber(Real); +registerWebServerControlVectorNumber(int); registerWebServerControlVectorString(std::string); InputParameters diff --git a/python/MooseControl/MooseControl.py b/python/MooseControl/MooseControl.py index 1b241d28f605..a686793f2a39 100644 --- a/python/MooseControl/MooseControl.py +++ b/python/MooseControl/MooseControl.py @@ -458,6 +458,18 @@ def setControllableReal(self, path: str, value: float): self._requireNumeric(value) self._setControllable(path, 'Real', float(value)) + def setControllableInt(self, path: str, value: int): + """Sets a controllable int-valued parameter + + The provided value must be numeric + + Parameters: + path (str): The path of the controllable value + value (int): The value to set + """ + self._requireNumeric(value) + self._setControllable(path, 'int', int(value)) + def setControllableVectorReal(self, path: str, value: list[float]): """Sets a controllable vector-of-Real parameter @@ -474,6 +486,22 @@ def setControllableVectorReal(self, path: str, value: list[float]): value_list.append(entry) self._setControllable(path, 'std::vector', value_list) + def setControllableVectorInt(self, path: str, value: list[int]): + """Sets a controllable vector-of-int parameter + + The provided value must be a list of numeric values + + Parameters: + path (str): The path of the controllable value + value (list): The value to set + """ + self._requireType(value, list) + value_list = [] + for entry in value: + self._requireNumeric(entry) + value_list.append(int(entry)) + self._setControllable(path, 'std::vector', value_list) + def setControllableString(self, path: str, value: str): """Sets a controllable string parameter diff --git a/test/src/reporters/WebServerControlTestReporter.C b/test/src/reporters/WebServerControlTestReporter.C index 4d90bcbb6fba..bf25954d8515 100644 --- a/test/src/reporters/WebServerControlTestReporter.C +++ b/test/src/reporters/WebServerControlTestReporter.C @@ -17,10 +17,13 @@ WebServerControlTestReporter::validParams() auto params = GeneralReporter::validParams(); params.addParam("bool_value", "Test bool value"); params.addParam("real_value", "Test Real value"); + params.addParam("int_value", "Test int value"); params.addParam>("vec_real_value", "Test vector Real value"); + params.addParam>("vec_int_value", "Test vector int value"); params.addParam("string_value", "Test string value"); params.addParam>("vec_string_value", "Test vector string value"); - params.declareControllable("bool_value real_value vec_real_value string_value vec_string_value"); + params.declareControllable( + "bool_value real_value int_value vec_real_value vec_int_value string_value vec_string_value"); return params; } @@ -29,7 +32,9 @@ WebServerControlTestReporter::WebServerControlTestReporter(const InputParameters { declare("bool_value"); declare("real_value"); + declare("int_value"); declare>("vec_real_value"); + declare>("vec_int_value"); declare("string_value"); declare>("vec_string_value"); } diff --git a/test/tests/controls/web_server_control/control_reporter.py b/test/tests/controls/web_server_control/control_reporter.py index cc44ac113a54..20942e053921 100755 --- a/test/tests/controls/web_server_control/control_reporter.py +++ b/test/tests/controls/web_server_control/control_reporter.py @@ -21,9 +21,15 @@ elif value == 'real_value': values = [1.5, 3.2] set_name = 'setControllableReal' + elif value == 'int_value': + values = [-5000, 1] + set_name = 'setControllableInt' elif value == 'vec_real_value': values = [[1, 2, 3, 4, 5], [6, 100]] set_name = 'setControllableVectorReal' + elif value == 'vec_int_value': + values = [[-1, -2, -3, 4, 5], [888, -1000]] + set_name = 'setControllableVectorInt' elif value == 'string_value': values = ['foo', 'bar'] set_name = 'setControllableString' diff --git a/test/tests/controls/web_server_control/gold/control_reporter_int.json b/test/tests/controls/web_server_control/gold/control_reporter_int.json new file mode 100644 index 000000000000..36fc236b51f2 --- /dev/null +++ b/test/tests/controls/web_server_control/gold/control_reporter_int.json @@ -0,0 +1,35 @@ +{ + "reporters": { + "test": { + "type": "WebServerControlTestReporter", + "values": { + "int_value": { + "type": "int" + } + } + } + }, + "time_steps": [ + { + "test": { + "int_value": -1234 + }, + "time": 0.0, + "time_step": 0 + }, + { + "test": { + "int_value": -5000 + }, + "time": 1.0, + "time_step": 1 + }, + { + "test": { + "int_value": 1 + }, + "time": 2.0, + "time_step": 2 + } + ] +} diff --git a/test/tests/controls/web_server_control/gold/control_reporter_vec_int.json b/test/tests/controls/web_server_control/gold/control_reporter_vec_int.json new file mode 100644 index 000000000000..a0286b5b0680 --- /dev/null +++ b/test/tests/controls/web_server_control/gold/control_reporter_vec_int.json @@ -0,0 +1,48 @@ +{ + "reporters": { + "test": { + "type": "WebServerControlTestReporter", + "values": { + "vec_int_value": { + "type": "std::vector" + } + } + } + }, + "time_steps": [ + { + "test": { + "vec_int_value": [ + 0, + -100, + 12345 + ] + }, + "time": 0.0, + "time_step": 0 + }, + { + "test": { + "vec_int_value": [ + -1, + -2, + -3, + 4, + 5 + ] + }, + "time": 1.0, + "time_step": 1 + }, + { + "test": { + "vec_int_value": [ + 888, + -1000 + ] + }, + "time": 2.0, + "time_step": 2 + } + ] +} diff --git a/test/tests/controls/web_server_control/tests b/test/tests/controls/web_server_control/tests index 6ce3190ea71a..222004ec1d91 100644 --- a/test/tests/controls/web_server_control/tests +++ b/test/tests/controls/web_server_control/tests @@ -29,6 +29,17 @@ recover = false detail = 'double precision number' [] + [int] + type = JSONDiff + input = control_reporter.i + jsondiff = 'control_reporter_int.json' + skip_keys = 'number_of_parts part' + cli_args = 'Outputs/json/file_base=control_reporter_int + Reporters/test/int_value=-1234' + command_proxy = 'control_reporter.py int_value' + recover = false + detail = 'integer' + [] [string] type = JSONDiff input = control_reporter.i @@ -51,6 +62,17 @@ recover = false detail = 'vector of double precision numbers' [] + [vec_int] + type = JSONDiff + input = control_reporter.i + jsondiff = 'control_reporter_vec_int.json' + skip_keys = 'number_of_parts part' + cli_args = 'Outputs/json/file_base=control_reporter_vec_int + Reporters/test/vec_int_value="0 -100 12345"' + command_proxy = 'control_reporter.py vec_int_value' + recover = false + detail = 'vector of integers' + [] [vec_string] type = JSONDiff input = control_reporter.i