LCOV - code coverage report
Current view: top level - src/controllogic - TerminateControl.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 19 20 95.0 %
Date: 2025-07-30 13:02:48 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      15             : InputParameters
      16          20 : TerminateControl::validParams()
      17             : {
      18          20 :   InputParameters params = THMControl::validParams();
      19          20 :   params.addClassDescription(
      20             :       "Terminates the simulation when a THMControl boolean data becomes true");
      21          40 :   params.addRequiredParam<std::string>(
      22             :       "input", "The name of boolean control data indicating if simulation should be terminated.");
      23          40 :   params.addParam<bool>("throw_error", false, "Flag to throw an error on termination");
      24          40 :   params.addRequiredParam<std::string>("termination_message",
      25             :                                        "Message to use if termination occurs");
      26          20 :   return params;
      27           0 : }
      28             : 
      29          10 : TerminateControl::TerminateControl(const InputParameters & parameters)
      30             :   : THMControl(parameters),
      31             : 
      32          10 :     _throw_error(getParam<bool>("throw_error")),
      33          20 :     _termination_message(getParam<std::string>("termination_message")),
      34          20 :     _terminate(getControlData<bool>("input"))
      35             : {
      36          10 : }
      37             : 
      38             : void
      39          88 : TerminateControl::execute()
      40             : {
      41          88 :   if (_terminate)
      42             :   {
      43          18 :     if (_throw_error)
      44           2 :       mooseError(_termination_message);
      45             :     else
      46             :     {
      47          16 :       _console << _termination_message << std::endl;
      48          16 :       _fe_problem.terminateSolve();
      49             :     }
      50             :   }
      51          86 : }

Generated by: LCOV version 1.14