https://mooseframework.inl.gov
Loading...
Searching...
No Matches
TimePeriod.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 "TimePeriod.h"
12#include "Function.h"
13#include "Transient.h"
14#include "MooseUtils.h"
15
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
35TimePeriod::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 = std::vector<Real>(1, _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
53void
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
64bool
65TimePeriod::conditionMet(const unsigned int & i)
66{
67 return MooseUtils::absoluteFuzzyGreaterEqual(_t, _start_time[i]) &&
68 MooseUtils::absoluteFuzzyLessThan(_t, _end_time[i]);
69}
registerMooseObject("MooseApp", TimePeriod)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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.
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition MooseApp.C:2409
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition MooseApp.C:2015
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition MooseBase.h:406
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
std::set< Real > & getSyncTimes()
Return the sync times for all objects.
Base class for basic control for disabling objects for a portion of the simulation.
std::vector< Real > _end_time
The time to stop enabling the supplied object tags (defaults to the end of the simulation)
std::vector< Real > _start_time
The time to begin enabling the supplied object tags (defaults to the simulation start time)
static InputParameters validParams()
Class constructor.
void setupTimes()
Helper base method to set start and end times for controls.
A basic control for disabling objects for a portion of the simulation.
Definition TimePeriod.h:19
void initialSetup() override
If enabled, this injects the start/end times into the TimeStepper sync times.
Definition TimePeriod.C:54
TimePeriod(const InputParameters &parameters)
Definition TimePeriod.C:35
static InputParameters validParams()
Class constructor.
Definition TimePeriod.C:19
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