LCOV - code coverage report
Current view: top level - src/controls - TimePeriod.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 26 27 96.3 %
Date: 2025-07-17 01:28:37 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       14969 : TimePeriod::validParams()
      20             : {
      21       14969 :   InputParameters params = TimePeriodBase::validParams();
      22             : 
      23       14969 :   params.addClassDescription("Control the enabled/disabled state of objects with time.");
      24             : 
      25       14969 :   params.addParam<std::vector<Real>>("start_time",
      26             :                                      "The time at which the objects are to be enabled/disabled.");
      27       14969 :   params.addParam<std::vector<Real>>("end_time",
      28             :                                      "The time at which the objects are to be enable/disabled.");
      29       44907 :   params.addParam<bool>(
      30       29938 :       "set_sync_times", false, "Set the start and end time as execute sync times.");
      31             : 
      32       14969 :   return params;
      33           0 : }
      34             : 
      35         360 : TimePeriod::TimePeriod(const InputParameters & parameters) : TimePeriodBase(parameters)
      36             : {
      37             :   // Set start time
      38         352 :   if (isParamValid("start_time"))
      39         340 :     _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         352 :   if (isParamValid("end_time"))
      45         280 :     _end_time = getParam<std::vector<Real>>("end_time");
      46             :   else
      47          72 :     _end_time = std::vector<Real>(_start_time.size(), std::numeric_limits<Real>::max());
      48             : 
      49             :   // Call base method to populate control times.
      50         352 :   TimePeriodBase::setupTimes();
      51         340 : }
      52             : 
      53             : void
      54         316 : TimePeriod::initialSetup()
      55             : {
      56         316 :   if (getParam<bool>("set_sync_times"))
      57             :   {
      58          12 :     std::set<Real> & sync_times = _app.getOutputWarehouse().getSyncTimes();
      59          12 :     sync_times.insert(_start_time.begin(), _start_time.end());
      60          12 :     sync_times.insert(_end_time.begin(), _end_time.end());
      61             :   }
      62         316 : }
      63             : 
      64             : bool
      65        6507 : TimePeriod::conditionMet(const unsigned int & i)
      66             : {
      67       11513 :   return MooseUtils::absoluteFuzzyGreaterEqual(_t, _start_time[i]) &&
      68       11513 :          MooseUtils::absoluteFuzzyLessThan(_t, _end_time[i]);
      69             : }

Generated by: LCOV version 1.14