LCOV - code coverage report
Current view: top level - src/controls - TimePeriodBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 22 23 95.7 %
Date: 2026-05-29 20:35:17 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 "TimePeriodBase.h"
      11             : #include "Function.h"
      12             : #include "Transient.h"
      13             : #include "MooseUtils.h"
      14             : #include "FEProblemBase.h"
      15             : 
      16             : InputParameters
      17        3753 : TimePeriodBase::validParams()
      18             : {
      19        3753 :   InputParameters params = ConditionalEnableControl::validParams();
      20        3753 :   params.addClassDescription(
      21             :       "Base class for controlling the enabled/disabled state of objects with time.");
      22        3753 :   return params;
      23           0 : }
      24             : 
      25         352 : TimePeriodBase::TimePeriodBase(const InputParameters & parameters)
      26         352 :   : ConditionalEnableControl(parameters)
      27             : {
      28             :   // Error if not a transient problem
      29         349 :   if (!_fe_problem.isTransient())
      30           3 :     mooseError("TimePeriodBase objects only operate on transient problems.");
      31         346 : }
      32             : 
      33             : void
      34         346 : TimePeriodBase::setupTimes()
      35             : {
      36             :   // Check that start/end time are the same length
      37         346 :   if (_end_time.size() != _start_time.size())
      38           3 :     mooseError("The end time and start time vectors must be the same length.");
      39             : 
      40             :   // Resize the start/end times if only a single value given
      41         343 :   if (_end_time.size() == 1 && (_disable.size() > 1 || _enable.size() > 1))
      42             :   {
      43          50 :     unsigned int size = std::max(_disable.size(), _enable.size());
      44         100 :     _end_time = std::vector<Real>(size, _end_time[0]);
      45         100 :     _start_time = std::vector<Real>(size, _start_time[0]);
      46             :   }
      47         293 :   else if (_end_time.size() != _disable.size() && _end_time.size() != _enable.size())
      48           3 :     mooseError("The start/end time input must be a scalar or the same length as the enable/disable "
      49             :                "lists.");
      50             : 
      51             :   // Test that start and end times are in proper order
      52         799 :   for (unsigned int i = 0; i < _start_time.size(); ++i)
      53         462 :     if (_start_time[i] >= _end_time[i])
      54           3 :       mooseError("The start time(s) must be less than the end time(s).");
      55         337 : }

Generated by: LCOV version 1.14