LCOV - code coverage report
Current view: top level - src/controls - TimePeriod.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 26 27 96.3 %
Date: 2025-08-08 20:01:16 Functions: 4 4 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             : // MOOSE includes
      11             : #include "TimePeriod.h"
      12             : #include "Function.h"
      13             : #include "Transient.h"
      14             : #include "MooseUtils.h"
      15             : 
      16             : registerMooseObject("MooseApp", TimePeriod);
      17             : 
      18             : InputParameters
      19       15021 : TimePeriod::validParams()
      20             : {
      21       15021 :   InputParameters params = TimePeriodBase::validParams();
      22             : 
      23       15021 :   params.addClassDescription("Control the enabled/disabled state of objects with time.");
      24             : 
      25       15021 :   params.addParam<std::vector<Real>>("start_time",
      26             :                                      "The time at which the objects are to be enabled/disabled.");
      27       15021 :   params.addParam<std::vector<Real>>("end_time",
      28             :                                      "The time at which the objects are to be enable/disabled.");
      29       45063 :   params.addParam<bool>(
      30       30042 :       "set_sync_times", false, "Set the start and end time as execute sync times.");
      31             : 
      32       15021 :   return params;
      33           0 : }
      34             : 
      35         386 : TimePeriod::TimePeriod(const InputParameters & parameters) : TimePeriodBase(parameters)
      36             : {
      37             :   // Set start time
      38         378 :   if (isParamValid("start_time"))
      39         366 :     _start_time = getParam<std::vector<Real>>("start_time");
      40             :   else
      41          12 :     _start_time = {_app.getExecutioner()->getParam<Real>("start_time")};
      42             : 
      43             :   // Set end time
      44         378 :   if (isParamValid("end_time"))
      45         287 :     _end_time = getParam<std::vector<Real>>("end_time");
      46             :   else
      47          91 :     _end_time = std::vector<Real>(_start_time.size(), std::numeric_limits<Real>::max());
      48             : 
      49             :   // Call base method to populate control times.
      50         378 :   TimePeriodBase::setupTimes();
      51         366 : }
      52             : 
      53             : void
      54         302 : TimePeriod::initialSetup()
      55             : {
      56         302 :   if (getParam<bool>("set_sync_times"))
      57             :   {
      58          13 :     std::set<Real> & sync_times = _app.getOutputWarehouse().getSyncTimes();
      59          13 :     sync_times.insert(_start_time.begin(), _start_time.end());
      60          13 :     sync_times.insert(_end_time.begin(), _end_time.end());
      61             :   }
      62         302 : }
      63             : 
      64             : bool
      65        7047 : TimePeriod::conditionMet(const unsigned int & i)
      66             : {
      67       12458 :   return MooseUtils::absoluteFuzzyGreaterEqual(_t, _start_time[i]) &&
      68       12458 :          MooseUtils::absoluteFuzzyLessThan(_t, _end_time[i]);
      69             : }

Generated by: LCOV version 1.14