www.mooseframework.org
TimePeriod.C
Go to the documentation of this file.
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 "TimePeriod.h"
12 #include "Function.h"
13 #include "Transient.h"
14 #include "MooseUtils.h"
15 
16 registerMooseObject("MooseApp", TimePeriod);
17 
20 {
22 
23  params.addClassDescription("Control the enabled/disabled state of objects with time.");
24 
25  params.addParam<std::vector<Real>>("start_time",
26  "The time at which the objects are to be enabled/disabled.");
27  params.addParam<std::vector<Real>>("end_time",
28  "The time at which the objects are to be enable/disabled.");
29  params.addParam<bool>(
30  "set_sync_times", false, "Set the start and end time as execute sync times.");
31 
32  return params;
33 }
34 
35 TimePeriod::TimePeriod(const InputParameters & parameters) : TimePeriodBase(parameters)
36 {
37  // Set start time
38  if (isParamValid("start_time"))
39  _start_time = getParam<std::vector<Real>>("start_time");
40  else
41  _start_time = {_app.getExecutioner()->getParam<Real>("start_time")};
42 
43  // Set end time
44  if (isParamValid("end_time"))
45  _end_time = getParam<std::vector<Real>>("end_time");
46  else
47  _end_time = std::vector<Real>(_start_time.size(), std::numeric_limits<Real>::max());
48 
49  // Call base method to populate control times.
51 }
52 
53 void
55 {
56  if (getParam<bool>("set_sync_times"))
57  {
58  std::set<Real> & sync_times = _app.getOutputWarehouse().getSyncTimes();
59  sync_times.insert(_start_time.begin(), _start_time.end());
60  sync_times.insert(_end_time.begin(), _end_time.end());
61  }
62 }
63 
64 bool
65 TimePeriod::conditionMet(const unsigned int & i)
66 {
69 }
registerMooseObject("MooseApp", TimePeriod)
virtual bool conditionMet(const unsigned int &i) override
Condition that must be true for an entry of the "enable" list to be enabled and/or an entry of the "d...
Definition: TimePeriod.C:65
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
Class constructor.
auto max(const L &left, const R &right)
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
A basic control for disabling objects for a portion of the simulation.
Definition: TimePeriod.h:18
bool absoluteFuzzyLessThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is less than another variable within an absolute tolerance...
Definition: MooseUtils.h:437
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
std::vector< Real > _start_time
The time to begin enabling the supplied object tags (defaults to the simulation start time) ...
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:69
static InputParameters validParams()
Class constructor.
Definition: TimePeriod.C:19
TimePeriod(const InputParameters &parameters)
Definition: TimePeriod.C:35
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition: MooseApp.C:1482
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool absoluteFuzzyGreaterEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether a variable is greater than or equal to another variable within an absolute ...
Definition: MooseUtils.h:369
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
void initialSetup() override
If enabled, this injects the start/end times into the TimeStepper sync times.
Definition: TimePeriod.C:54
Base class for basic control for disabling objects for a portion of the simulation.
std::set< Real > & getSyncTimes()
Return the sync times for all objects.
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:1772
void setupTimes()
Helper base method to set start and end times for controls.
std::vector< Real > _end_time
The time to stop enabling the supplied object tags (defaults to the end of the simulation) ...