Question about class ProgressBar(object):

18 views
Skip to first unread message

Kiny Wan

unread,
Jun 26, 2020, 11:11:11 PM6/26/20
to PyFR Mailing List
Dear all, I find that the variable 'self.stelap' in progress_bar.py means the elapsed simulation times, however,  'self.stelap = self.stcurr - self.strtrt' is confused. Is ''self.strtrt' should be replaced with 'self.ststrt'?

 class ProgressBar(object):
def __init__(self, start, curr, end, dps=2):
        self.ststrt = start
        self.strtrt = curr
        self.stend = end
        self.dps = dps
        self._wstart = time.time()
        self._last_wallt = 0.0
        self._ncol = shutil.get_terminal_size()[0] or 80
        self._nbarcol = self._ncol - 24 - 2*len('{:.{}f}'.format(end, dps))
        self.advance_to(curr)
    def advance_to(self, t):
        self.stcurr = min(t, self.stend)
        self.stelap = self.stcurr - self.strtrt

Kiny Wan

unread,
Jun 26, 2020, 11:20:06 PM6/26/20
to PyFR Mailing List
I highlighted the keywords as follow:
 
Dear all, the variable 'self.stelap' in progress_bar.py means the elapsed simulation times, however,  'self.stelap = self.stcurr - self.strtrt' is confused. Is ''self.strtrt' should be replaced with 'self.ststrt'?

Freddie Witherden

unread,
Jun 26, 2020, 11:21:59 PM6/26/20
to PyFR Mailing List

No, the code is correct as-is.  This is needed to handle the case where one is restarting a simulation.  Here, the elapsed progress is the difference between where we currently are (self.stcurr) and where we are restarting from (st.rtrt).  This enables the progress bar to differentiate between progress which was made before the current restart action and that which has been made since we restarted; the former is signified by a + whilst the latter is signified by a =.

Regards, Freddie.

On 26 Jun 2020, at 22:11, Kiny Wan <wlc...@gmail.com> wrote:


Dear all, I find that the variable 'self.stelap' in progress_bar.py means the elapsed simulation times, however,  'self.stelap = self.stcurr - self.strtrt' is confused. Is ''self.strtrt' should be replaced with 'self.ststrt'?

--
You received this message because you are subscribed to the Google Groups "PyFR Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyfrmailingli...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pyfrmailinglist/724f722b-da6c-4852-b5eb-098577160594o%40googlegroups.com.

Kiny Wan

unread,
Jun 27, 2020, 8:35:53 AM6/27/20
to PyFR Mailing List
Hi Freddie, 
    Thanks for your kind reply.
Regards 
Kiny.
Reply all
Reply to author
Forward
0 new messages