https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TerminateControl.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#include "TerminateControl.h"
11#include "Function.h"
12
13registerMooseObject("ThermalHydraulicsApp", TerminateControl);
14
17{
20 "Terminates the simulation when a THMControl boolean data becomes true");
21 params.addRequiredParam<std::string>(
22 "input", "The name of boolean control data indicating if simulation should be terminated.");
23 params.addParam<bool>("throw_error", false, "Flag to throw an error on termination");
24 params.addRequiredParam<std::string>("termination_message",
25 "Message to use if termination occurs");
26 return params;
27}
28
30 : THMControl(parameters),
31
32 _throw_error(getParam<bool>("throw_error")),
33 _termination_message(getParam<std::string>("termination_message")),
34 _terminate(getControlData<bool>("input"))
35{
36}
37
38void
40{
41 if (_terminate)
42 {
43 if (_throw_error)
45 else
46 {
47 _console << _termination_message << std::endl;
49 }
50 }
51}
registerMooseObject("ThermalHydraulicsApp", TerminateControl)
const ConsoleStream _console
FEProblemBase & _fe_problem
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
virtual void terminateSolve()
static InputParameters validParams()
Definition THMControl.C:13
This control block will terminate a run if its input indicates so.
static InputParameters validParams()
const std::string & _termination_message
Message to use if termination occurs.
const bool & _terminate
The control data that indicates if the simulation should be terminated.
TerminateControl(const InputParameters &parameters)
virtual void execute()
const bool _throw_error
Flag to throw an error if the terminate condition is met.