[skip ci] print estimated remaining processing time for postResults
This commit is contained in:
parent
a852729d4d
commit
b5d62c8e29
|
@ -134,7 +134,7 @@ class extendableOption(Option):
|
|||
|
||||
# Print iterations progress
|
||||
# from https://gist.github.com/aubricus/f91fb55dc6ba5557fbab06119420dd6a
|
||||
def progressBar(iteration, total, prefix='', suffix='', decimals=1, bar_length=100):
|
||||
def progressBar(iteration, total, start=None, prefix='', suffix='', decimals=1, bar_length=50):
|
||||
"""
|
||||
Call in a loop to create terminal progress bar
|
||||
|
||||
|
@ -146,12 +146,19 @@ def progressBar(iteration, total, prefix='', suffix='', decimals=1, bar_length=1
|
|||
decimals - Optional : positive number of decimals in percent complete (Int)
|
||||
bar_length - Optional : character length of bar (Int)
|
||||
"""
|
||||
str_format = "{0:." + str(decimals) + "f}"
|
||||
import time
|
||||
|
||||
if suffix == '' and start is not None and iteration > 0:
|
||||
remainder = (total - iteration) * (time.time()-start)/iteration
|
||||
suffix = '{: 3d}:'.format(int( remainder//3600)) + \
|
||||
'{:02d}:'.format(int((remainder//60)%60)) + \
|
||||
'{:02d}' .format(int( remainder %60))
|
||||
str_format = "{{0:{}.{}f}}".format(decimals+4,decimals)
|
||||
percents = str_format.format(100 * (iteration / float(total)))
|
||||
filled_length = int(round(bar_length * iteration / float(total)))
|
||||
bar = '█' * filled_length + '-' * (bar_length - filled_length)
|
||||
|
||||
sys.stderr.write('\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix)),
|
||||
sys.stderr.write('\r%s |%s| %s %s' % (prefix, bar, percents+'%', suffix)),
|
||||
|
||||
if iteration == total: sys.stderr.write('\n\n')
|
||||
sys.stderr.flush()
|
||||
|
|
|
@ -830,9 +830,10 @@ if options.info:
|
|||
|
||||
elementsOfNode = {}
|
||||
Nelems = stat['NumberOfElements']
|
||||
starttime = time.time()
|
||||
for e in range(Nelems):
|
||||
if options.verbose and Nelems > 100 and e%(Nelems//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
damask.util.progressBar(iteration=e,total=Nelems,prefix='1/3: connecting elements')
|
||||
damask.util.progressBar(iteration=e,total=Nelems,start=starttime,prefix='1/3: connecting elements')
|
||||
for n in map(p.node_sequence,p.element(e).items):
|
||||
if n not in elementsOfNode:
|
||||
elementsOfNode[n] = [p.element_id(e)]
|
||||
|
@ -855,9 +856,10 @@ damask.util.progressBar(iteration=1,total=1,prefix='1/3: connecting elements')
|
|||
|
||||
if options.nodalScalar:
|
||||
Npoints = stat['NumberOfNodes']
|
||||
starttime = time.time()
|
||||
for n in range(Npoints):
|
||||
if options.verbose and Npoints > 100 and e%(Npoints//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
damask.util.progressBar(iteration=n,total=Npoints,prefix='2/3: scanning nodes ')
|
||||
damask.util.progressBar(iteration=n,total=Npoints,start=starttime,prefix='2/3: scanning nodes ')
|
||||
myNodeID = p.node_id(n)
|
||||
myNodeCoordinates = [p.node(n).x, p.node(n).y, p.node(n).z]
|
||||
myElemID = 0
|
||||
|
@ -892,9 +894,10 @@ if options.nodalScalar:
|
|||
|
||||
else:
|
||||
Nelems = stat['NumberOfElements']
|
||||
starttime = time.time()
|
||||
for e in range(Nelems):
|
||||
if options.verbose and Nelems > 100 and e%(Nelems//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
damask.util.progressBar(iteration=e,total=Nelems,prefix='2/3: scanning elements ')
|
||||
damask.util.progressBar(iteration=e,total=Nelems,start=starttime,prefix='2/3: scanning elements ')
|
||||
myElemID = p.element_id(e)
|
||||
myIpCoordinates = ipCoords(p.element(e).type, list(map(lambda node: [node.x, node.y, node.z],
|
||||
list(map(p.node, map(p.node_sequence, p.element(e).items))))))
|
||||
|
@ -1032,10 +1035,11 @@ for incCount,position in enumerate(locations): # walk through locations
|
|||
|
||||
member = 0
|
||||
Ngroups = len(groups)
|
||||
starttime = time.time()
|
||||
for j,group in enumerate(groups):
|
||||
f = incCount*Ngroups + j
|
||||
if options.verbose and (Ngroups*Nincs) > 100 and f%((Ngroups*Nincs)//100) == 0: # report in 1% steps if possible and avoid modulo by zero
|
||||
damask.util.progressBar(iteration=f,total=Ngroups*Nincs,prefix='3/3: processing points ')
|
||||
damask.util.progressBar(iteration=f,total=Ngroups*Nincs,start=starttime,prefix='3/3: processing points ')
|
||||
N = 0 # group member counter
|
||||
for (e,n,i,g,n_local) in group[1:]: # loop over group members
|
||||
member += 1
|
||||
|
|
Loading…
Reference in New Issue