https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Times.h
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#pragma once
11
12// Moose includes
13#include "GeneralReporter.h"
14
18class Times : public GeneralReporter
19{
20public:
23 virtual ~Times() = default;
24
26 const std::vector<Real> & getTimes() const;
27
29 const std::set<Real> getUniqueTimes() const
30 {
31 return std::set<Real>(_times.begin(), _times.end());
32 };
33
35 Real getCurrentTime() const { return _fe_problem.time(); }
36
38 Real getTimeAtIndex(unsigned int index) const;
39
43 Real getPreviousTime(const Real current_time) const;
44
50 Real getNextTime(const Real current_time, const bool error_if_no_next) const;
51
53
54protected:
57 virtual void initialize() override = 0;
58
60 virtual void execute() override { initialize(); }
61
63 virtual void finalize() override;
64
66 virtual void timestepSetup() override {}
67 virtual void residualSetup() override {}
68 virtual void jacobianSetup() override {}
69
71 void clearTimes();
72
74 std::vector<Real> & _times;
75
77 const bool _need_broadcast;
79 const bool _need_sort;
81 const bool _need_unique;
83 const Real _unique_tol;
84
87};
virtual Real & time() const
Reporter object that has a single execution of the "execute" method for each execute flag.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
Times objects are under the hood Reporters, but limited to a vector of Real.
Definition Times.h:19
void clearTimes()
Clear the times vector.
Definition Times.C:118
Real getCurrentTime() const
Get the current time.
Definition Times.h:35
const Real _unique_tol
Absolute tolerance for performing duplication checks to make the times vector unique.
Definition Times.h:83
static InputParameters validParams()
Definition Times.C:14
const bool _need_broadcast
Whether generation of times is distributed or not (and therefore needs a broadcast)
Definition Times.h:77
const std::vector< Real > & getTimes() const
Getter for the full times vector.
Definition Times.C:107
virtual void finalize() override
In charge of reduction across all ranks.
Definition Times.C:124
virtual void residualSetup() override
Gets called just before the residual is computed and before this object is asked to do its job.
Definition Times.h:67
virtual void execute() override
By default, we wont execute often but "executing" will mean loading the times.
Definition Times.h:60
Real getNextTime(const Real current_time, const bool error_if_no_next) const
Find the next time in the times vector for a given time If current_time is also in the times vector w...
Definition Times.C:87
const bool _need_sort
Whether times should be sorted, because they come from different sources for example.
Definition Times.h:79
const bool _dynamic_time_sequence
whether the time sequence is set dynamically
Definition Times.h:86
virtual void timestepSetup() override
By default, Times will not be modified very regularly.
Definition Times.h:66
bool isDynamicTimeSequence() const
Definition Times.h:52
virtual void jacobianSetup() override
Gets called just before the Jacobian is computed and before this object is asked to do its job.
Definition Times.h:68
std::vector< Real > & _times
The vector holding the times.
Definition Times.h:74
Real getTimeAtIndex(unsigned int index) const
Getter for a single time at a known index.
Definition Times.C:57
Real getPreviousTime(const Real current_time) const
Find the previous time in the times vector for a given time If current_time is also in the times vect...
Definition Times.C:69
virtual ~Times()=default
const std::set< Real > getUniqueTimes() const
Getter for a set of the full times.
Definition Times.h:29
virtual void initialize() override=0
In charge of computing / loading the times, unless all that could be done there is done in the constr...
const bool _need_unique
Whether duplicate times should be removed.
Definition Times.h:81
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.