Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 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 "StepPeriod.h" 12 : #include "StepUserObject.h" 13 : #include "Function.h" 14 : #include "Transient.h" 15 : #include "MooseUtils.h" 16 : 17 : registerMooseObject("TensorMechanicsApp", StepPeriod); 18 : 19 : InputParameters 20 60 : StepPeriod::validParams() 21 : { 22 60 : InputParameters params = TimePeriodBase::validParams(); 23 60 : params.addClassDescription( 24 : "Control the enabled/disabled state of objects with user-provided simulation steps."); 25 120 : params.addParam<bool>( 26 120 : "set_sync_times", true, "Set the start and end time as execute sync times."); 27 120 : params.addParam<UserObjectName>( 28 : "step_user_object", "The StepUserObject that provides times from simulation loading steps."); 29 120 : params.addRequiredParam<unsigned int>("step_number", 30 : "Step number on which this control object applies."); 31 60 : return params; 32 0 : } 33 : 34 30 : StepPeriod::StepPeriod(const InputParameters & parameters) : TimePeriodBase(parameters) {} 35 : 36 : void 37 30 : StepPeriod::initialSetup() 38 : { 39 : // Let's automatically detect uos and identify the one we are interested in. 40 : // If there is more than one, we assume something is off and error out. 41 60 : if (!isParamSetByUser("step_user_object")) 42 0 : getStepUserObject(_fe_problem, _step_user_object, name()); 43 : else 44 30 : _step_user_object = &getUserObject<StepUserObject>("step_user_object"); 45 : 46 30 : _start_time.resize(1); 47 30 : _end_time.resize(1); 48 : 49 : // Set start time 50 60 : _start_time[0] = _step_user_object->getStartTime(getParam<unsigned int>("step_number")); 51 : 52 : // Set end time 53 60 : _end_time[0] = _step_user_object->getEndTime(getParam<unsigned int>("step_number")); 54 : 55 : // Call base method to populate control times. 56 30 : TimePeriodBase::setupTimes(); 57 : 58 60 : if (getParam<bool>("set_sync_times")) 59 : { 60 30 : std::set<Real> & sync_times = _app.getOutputWarehouse().getSyncTimes(); 61 30 : sync_times.insert(_start_time.begin(), _start_time.end()); 62 30 : sync_times.insert(_end_time.begin(), _end_time.end()); 63 : } 64 30 : } 65 : 66 : bool 67 660 : StepPeriod::conditionMet(const unsigned int & /*i*/) 68 : { 69 660 : return MooseUtils::absoluteFuzzyGreaterEqual(_t, _start_time[0]) && 70 660 : MooseUtils::absoluteFuzzyLessThan(_t, _end_time[0]); 71 : }