LCOV - code coverage report
Current view: top level - src/controls - AnalysisStepPeriod.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 27 29 93.1 %
Date: 2025-07-25 05:00:39 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 "AnalysisStepPeriod.h"
      12             : #include "AnalysisStepUserObject.h"
      13             : #include "Function.h"
      14             : #include "Transient.h"
      15             : #include "MooseUtils.h"
      16             : 
      17             : registerMooseObject("SolidMechanicsApp", AnalysisStepPeriod);
      18             : 
      19             : InputParameters
      20         144 : AnalysisStepPeriod::validParams()
      21             : {
      22         144 :   InputParameters params = TimePeriodBase::validParams();
      23         144 :   params.addClassDescription(
      24             :       "Control the enabled/disabled state of objects with user-provided analysis steps.");
      25         288 :   params.addParam<bool>(
      26         288 :       "set_sync_times", true, "Set the start and end time as execute sync times.");
      27         288 :   params.addParam<UserObjectName>(
      28             :       "analysis_step_user_object",
      29             :       "The AnalysisStepUserObject that provides times from analysis steps.");
      30         288 :   params.addRequiredParam<unsigned int>("step_number",
      31             :                                         "Step number on which this control object applies.");
      32         144 :   return params;
      33           0 : }
      34             : 
      35          72 : AnalysisStepPeriod::AnalysisStepPeriod(const InputParameters & parameters)
      36          72 :   : TimePeriodBase(parameters)
      37             : {
      38          72 : }
      39             : 
      40             : void
      41          72 : AnalysisStepPeriod::initialSetup()
      42             : {
      43             :   // Let's automatically detect uos and identify the one we are interested in.
      44             :   // If there is more than one, we assume something is off and error out.
      45         144 :   if (!isParamSetByUser("step_user_object"))
      46          72 :     getAnalysisStepUserObject(_fe_problem, _step_user_object, name());
      47             :   else
      48           0 :     _step_user_object = &getUserObject<AnalysisStepUserObject>("analysis_step_user_object");
      49             : 
      50          72 :   _start_time.resize(1);
      51          72 :   _end_time.resize(1);
      52             : 
      53             :   // Set start time
      54         144 :   _start_time[0] = _step_user_object->getStartTime(getParam<unsigned int>("step_number"));
      55             : 
      56             :   // Set end time
      57         144 :   _end_time[0] = _step_user_object->getEndTime(getParam<unsigned int>("step_number"));
      58             : 
      59             :   // Call base method to populate control times.
      60          72 :   TimePeriodBase::setupTimes();
      61             : 
      62         144 :   if (getParam<bool>("set_sync_times"))
      63             :   {
      64          72 :     std::set<Real> & sync_times = _app.getOutputWarehouse().getSyncTimes();
      65          72 :     sync_times.insert(_start_time.begin(), _start_time.end());
      66          72 :     sync_times.insert(_end_time.begin(), _end_time.end());
      67             :   }
      68          72 : }
      69             : 
      70             : bool
      71        1584 : AnalysisStepPeriod::conditionMet(const unsigned int & /*i*/)
      72             : {
      73        3168 :   return MooseUtils::absoluteFuzzyGreaterEqual(_t, _start_time[0]) &&
      74        1584 :          MooseUtils::absoluteFuzzyLessThan(_t, _end_time[0]);
      75             : }

Generated by: LCOV version 1.14