Skip to content

Commit

Permalink
Add and use const getters (idaholab#22906)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Sep 20, 2023
1 parent f5d9da0 commit 02a050a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
14 changes: 10 additions & 4 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 All @@ -119,7 +119,7 @@ class Transient : public Executioner
* Pointer to the TimeStepper
* @return Pointer to the time stepper for this Executioner
*/
TimeStepper * getTimeStepper() { return _time_stepper; }
TimeStepper * getTimeStepper() const { return _time_stepper; }

/**
* Set the timestepper to use.
Expand All @@ -143,7 +143,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 +167,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 02a050a

Please sign in to comment.