https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AnalysisStepPeriod.C
Go to the documentation of this file.
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"
13#include "Function.h"
14#include "Transient.h"
15#include "MooseUtils.h"
16
18
21{
24 "Control the enabled/disabled state of objects with user-provided analysis steps.");
25 params.addParam<bool>(
26 "set_sync_times", true, "Set the start and end time as execute sync times.");
27 params.addParam<UserObjectName>(
28 "analysis_step_user_object",
29 "The AnalysisStepUserObject that provides times from analysis steps.");
30 params.addRequiredParam<unsigned int>("step_number",
31 "Step number on which this control object applies.");
32 return params;
33}
34
36 : TimePeriodBase(parameters)
37{
38}
39
40void
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 if (!isParamSetByUser("step_user_object"))
47 else
48 _step_user_object = &getUserObject<AnalysisStepUserObject>("analysis_step_user_object");
49
50 _start_time.resize(1);
51 _end_time.resize(1);
52
53 // Set start time
54 _start_time[0] = _step_user_object->getStartTime(getParam<unsigned int>("step_number"));
55
56 // Set end time
57 _end_time[0] = _step_user_object->getEndTime(getParam<unsigned int>("step_number"));
58
59 // Call base method to populate control times.
61
62 if (getParam<bool>("set_sync_times"))
63 {
64 std::set<Real> & sync_times = _app.getOutputWarehouse().getSyncTimes();
65 sync_times.insert(_start_time.begin(), _start_time.end());
66 sync_times.insert(_end_time.begin(), _end_time.end());
67 }
68}
69
70bool
71AnalysisStepPeriod::conditionMet(const unsigned int & /*i*/)
72{
73 return MooseUtils::absoluteFuzzyGreaterEqual(_t, _start_time[0]) &&
74 MooseUtils::absoluteFuzzyLessThan(_t, _end_time[0]);
75}
registerMooseObject("SolidMechanicsApp", AnalysisStepPeriod)
A basic control for disabling objects for a portion of the simulation based on the analysis step conc...
virtual bool conditionMet(const unsigned int &i) override
const AnalysisStepUserObject * _step_user_object
static InputParameters validParams()
Class constructor.
AnalysisStepPeriod(const InputParameters &parameters)
void initialSetup() override
If enabled, this injects the start/end times into the TimeStepper sync times.
virtual void getAnalysisStepUserObject(const FEProblemBase &fe_problem, const AnalysisStepUserObject *&step_user_object, const std::string &name)
Real getEndTime(const unsigned int &step) const
Real getStartTime(const unsigned int &step) const
FEProblemBase & _fe_problem
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
OutputWarehouse & getOutputWarehouse()
const std::string & name() const
bool isParamSetByUser(const std::string &name) const
MooseApp & _app
std::set< Real > & getSyncTimes()
std::vector< Real > _end_time
std::vector< Real > _start_time
static InputParameters validParams()