Skip to content

Commit

Permalink
Add and use const getters (#22906)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Sep 20, 2023
1 parent 44ef55e commit 85c3576
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions framework/doc/content/source/outputs/ProgressOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ The Progress output displays an ASCII art progress bar at the end of each timest
+--------------------------------------------------+
```

!syntax parameters /Outputs/DOFMap
!syntax parameters /Outputs/Progress

!syntax inputs /Outputs/DOFMap
!syntax inputs /Outputs/Progress

!syntax children /Outputs/DOFMap
!syntax children /Outputs/Progress
13 changes: 10 additions & 3 deletions framework/include/executioners/Transient.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Transient : public Executioner
/**
* Get the current time.
*/
virtual Real getTime() { return _time; };
virtual Real getTime() const { return _time; };

/**
* Get the current target time
Expand Down Expand Up @@ -120,6 +120,7 @@ class Transient : public Executioner
* @return Pointer to the time stepper for this Executioner
*/
TimeStepper * getTimeStepper() { return _time_stepper; }
const TimeStepper * getTimeStepper() const { return _time_stepper; }

/**
* Set the timestepper to use.
Expand All @@ -143,7 +144,7 @@ class Transient : public Executioner
* Get the time scheme used
* @return MooseEnum with the time scheme
*/
Moose::TimeIntegratorType getTimeScheme() { return _time_scheme; }
Moose::TimeIntegratorType getTimeScheme() const { return _time_scheme; }

/**
* Get the set of sync times
Expand All @@ -167,12 +168,18 @@ class Transient : public Executioner
* Return the start time
* @return The start time
*/
Real getStartTime() { return _start_time; }
Real getStartTime() const { return _start_time; }

/**
* Get the end time
* @return The end time
*/
Real getEndTime() const { return _end_time; }

/**
* Get a modifiable reference to the end time
* @return The end time
*/
Real & endTime() { return _end_time; }

/**
Expand Down
5 changes: 4 additions & 1 deletion framework/include/outputs/ProgressOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

class Transient;

/**
* Output a simulation time progress bar on the console
*/
class ProgressOutput : public Output
{
public:
Expand All @@ -23,7 +26,7 @@ class ProgressOutput : public Output
protected:
void output() override;

Transient * _transient_executioner;
const Transient * const _transient_executioner;

/// display input file name in the progress bar title
const bool _use_filename;
Expand Down
5 changes: 2 additions & 3 deletions framework/src/outputs/ProgressOutput.C
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ ProgressOutput::ProgressOutput(const InputParameters & parameters)
void
ProgressOutput::output()
{
if (_transient_executioner == nullptr || _current_execute_flag != EXEC_TIMESTEP_END ||
!_transient)
if (_transient_executioner == nullptr || _current_execute_flag != EXEC_TIMESTEP_END)
return;

const auto passed = _transient_executioner->getTime() - _transient_executioner->getStartTime();
const auto total = _transient_executioner->endTime() - _transient_executioner->getStartTime();
const auto total = _transient_executioner->getEndTime() - _transient_executioner->getStartTime();
if (total == 0)
return;

Expand Down

0 comments on commit 85c3576

Please sign in to comment.