LCOV - code coverage report
Current view: top level - src/functions - TimeRampFunction.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 23 26 88.5 %
Date: 2025-07-30 13:02:48 Functions: 3 4 75.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 "TimeRampFunction.h"
      11             : 
      12             : registerMooseObject("ThermalHydraulicsApp", TimeRampFunction);
      13             : 
      14             : InputParameters
      15         157 : TimeRampFunction::validParams()
      16             : {
      17         157 :   InputParameters params = Function::validParams();
      18             : 
      19         314 :   params.addRequiredParam<Real>("initial_value", "Initial value");
      20         314 :   params.addRequiredParam<Real>("final_value", "Final value");
      21         314 :   params.addRequiredParam<Real>("ramp_duration", "Duration, in seconds, of the ramp");
      22         314 :   params.addParam<Real>("initial_time", 0, "Initial time (necessary if not equal to zero)");
      23             : 
      24         157 :   params.addClassDescription("Ramps up to a value from another value over time.");
      25             : 
      26         157 :   return params;
      27           0 : }
      28             : 
      29          88 : TimeRampFunction::TimeRampFunction(const InputParameters & parameters)
      30             :   : Function(parameters),
      31             : 
      32          88 :     _initial_value(getParam<Real>("initial_value")),
      33         176 :     _final_value(getParam<Real>("final_value")),
      34         176 :     _ramp_duration(getParam<Real>("ramp_duration")),
      35         176 :     _initial_time(getParam<Real>("initial_time")),
      36             : 
      37          88 :     _ramp_end_time(_initial_time + _ramp_duration),
      38          88 :     _ramp_slope((_final_value - _initial_value) / _ramp_duration)
      39             : {
      40          88 : }
      41             : 
      42             : Real
      43         662 : TimeRampFunction::value(Real t, const Point & /*p*/) const
      44             : {
      45         662 :   const Real elapsed_time = t - _initial_time;
      46             : 
      47         662 :   if (t < _initial_time)
      48         364 :     return _initial_value;
      49         298 :   else if (t > _ramp_end_time)
      50         209 :     return _final_value;
      51             :   else
      52          89 :     return _initial_value + _ramp_slope * elapsed_time;
      53             : }
      54             : 
      55             : RealVectorValue
      56           0 : TimeRampFunction::gradient(Real /*t*/, const Point & /*p*/) const
      57             : {
      58           0 :   mooseError("TimeRampFunction::gradient() is not implemented!");
      59             : }

Generated by: LCOV version 1.14