https://mooseframework.inl.gov
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 
13 registerMooseObject("ThermalHydraulicsApp", TerminateControl);
14 
17 {
19  params.addClassDescription(
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 
38 void
40 {
41  if (_terminate)
42  {
43  if (_throw_error)
45  else
46  {
47  _console << _termination_message << std::endl;
49  }
50  }
51 }
TerminateControl(const InputParameters &parameters)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
Definition: THMControl.C:13
virtual void terminateSolve()
FEProblemBase & _fe_problem
const bool & _terminate
The control data that indicates if the simulation should be terminated.
const bool _throw_error
Flag to throw an error if the terminate condition is met.
static InputParameters validParams()
const std::string & _termination_message
Message to use if termination occurs.
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
const ConsoleStream _console
This control block will terminate a run if its input indicates so.
registerMooseObject("ThermalHydraulicsApp", TerminateControl)
virtual void execute()