https://mooseframework.inl.gov
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"
12 #include "AnalysisStepUserObject.h"
13 #include "Function.h"
14 #include "Transient.h"
15 #include "MooseUtils.h"
16 
17 registerMooseObject("SolidMechanicsApp", AnalysisStepPeriod);
18 
21 {
23  params.addClassDescription(
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 
40 void
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 
70 bool
71 AnalysisStepPeriod::conditionMet(const unsigned int & /*i*/)
72 {
75 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
Real getEndTime(const unsigned int &step) const
static InputParameters validParams()
Class constructor.
virtual const std::string & name() const
AnalysisStepPeriod(const InputParameters &parameters)
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
Real getStartTime(const unsigned int &step) const
void initialSetup() override
If enabled, this injects the start/end times into the TimeStepper sync times.
virtual bool conditionMet(const unsigned int &i) override
FEProblemBase & _fe_problem
bool absoluteFuzzyLessThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
virtual void getAnalysisStepUserObject(const FEProblemBase &fe_problem, const AnalysisStepUserObject *&step_user_object, const std::string &name)
std::vector< Real > _start_time
bool isParamSetByUser(const std::string &nm) const
MooseApp & _app
A basic control for disabling objects for a portion of the simulation based on the analysis step conc...
bool absoluteFuzzyGreaterEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
void addClassDescription(const std::string &doc_string)
const AnalysisStepUserObject * _step_user_object
registerMooseObject("SolidMechanicsApp", AnalysisStepPeriod)
std::set< Real > & getSyncTimes()
OutputWarehouse & getOutputWarehouse()
std::vector< Real > _end_time