Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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 
18 class Times : public GeneralReporter
19 {
20 public:
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 
52 protected:
55  virtual void initialize() override = 0;
56 
58  virtual void execute() override { initialize(); }
59 
61  virtual void finalize() override;
62 
64  virtual void timestepSetup() override {}
65  virtual void residualSetup() override {}
66  virtual void jacobianSetup() override {}
67 
69  void clearTimes();
70 
72  std::vector<Real> & _times;
73 
75  const bool _need_broadcast;
77  const bool _need_sort;
79  const bool _need_unique;
82 };
virtual void timestepSetup() override
By default, Times will not be modified very regularly.
Definition: Times.h:64
const bool _need_unique
Whether duplicate times should be removed.
Definition: Times.h:79
virtual Real & time() const
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:82
Reporter object that has a single execution of the "execute" method for for each execute flag...
const std::vector< Real > & getTimes() const
Getter for the full times vector.
Definition: Times.C:102
virtual void execute() override
By default, we wont execute often but "executing" will mean loading the times.
Definition: Times.h:58
virtual void initialize() override=0
In charge of computing / loading the times, unless all that could be done there is done in the constr...
Times(const InputParameters &parameters)
Definition: Times.C:39
const bool _need_broadcast
Whether generation of times is distributed or not (and therefore needs a broadcast) ...
Definition: Times.h:75
Times objects are under the hood Reporters, but limited to a vector of Real.
Definition: Times.h:18
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const std::set< Real > getUniqueTimes() const
Getter for a set of the full times.
Definition: Times.h:29
void clearTimes()
Clear the times vector.
Definition: Times.C:111
static InputParameters validParams()
Definition: Times.C:14
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:64
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:65
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual ~Times()=default
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:209
Real getTimeAtIndex(unsigned int index) const
Getter for a single time at a known index.
Definition: Times.C:52
const Real _unique_tol
Absolute tolerance for performing duplication checks to make the times vector unique.
Definition: Times.h:81
const InputParameters & parameters() const
Get the parameters of the object.
virtual void finalize() override
In charge of reduction across all ranks.
Definition: Times.C:117
Real getCurrentTime() const
Get the current time.
Definition: Times.h:35
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:66
std::vector< Real > & _times
The vector holding the times.
Definition: Times.h:72
const bool _need_sort
Whether times should be sorted, because they come from different sources for example.
Definition: Times.h:77