Skip to content
Snippets Groups Projects
Commit 6963f6e8 authored by jonathan.froehlich's avatar jonathan.froehlich
Browse files

simplified progress output

parent b8e13c84
No related branches found
No related tags found
3 merge requests!153Local add output info,!144Debug cardmech,!122Resolve "Electrocute geometries"
Pipeline #123711 passed
# Print iterations progress
def printProgressBar(iteration, total, prefix='', suffix='', decimals=1, length=50, fill='', printEnd="\r"):
def print_progress(iteration, total, prefix='', suffix='', decimals=1, length=50, fill='', printEnd="\r"):
"""
Call in a loop to create terminal progress bar
@params:
......
......@@ -2,7 +2,7 @@ from vtkmodules.util.numpy_support import vtk_to_numpy
from vtkmodules.vtkIOXML import vtkXMLUnstructuredGridReader
from utility.mesh import Mesh
from utility.progress import printProgressBar
from utility.progress import print_progress
class VtuMesh:
......@@ -28,14 +28,14 @@ class VtuMesh:
def add_points(self, nodes):
l = len(nodes)
printProgressBar(0, l, prefix='Reading Nodes:', suffix='Complete')
print_progress(0, l, prefix='Reading Nodes:\t\t', suffix='')
for i, node in enumerate(nodes):
self.geo.add_point([p * self.scale for p in node])
printProgressBar(i + 1, l, prefix='Reading Nodes:', suffix='Complete')
print_progress(i + 1, l, prefix='Reading Nodes:\t\t', suffix='')
def add_cells(self, cells):
t = cells.size
printProgressBar(0, t, prefix='Reading Cells:', suffix='Complete')
print_progress(0, t, prefix='Reading Cells:\t\t', suffix='')
j, k = 0, 0
while j < t:
i = cells[j]
......@@ -44,22 +44,22 @@ class VtuMesh:
elif i == 3:
self.bnd_data.append([p for p in cells[j + 1:j + i + 1]])
j += i + 1
printProgressBar(j, t, prefix='Reading Cells:', suffix='Complete')
print_progress(j, t, prefix='Reading Cells:\t\t', suffix='')
def set_boundary_data(self, bnd_function):
l = len(self.geo.bnd_faces())
printProgressBar(0, l, prefix='Setting Boundary:', suffix='Complete')
print_progress(0, l, prefix='Setting Boundary:\t', suffix='')
for i, bnd_face in enumerate(self.geo.bnd_faces()):
indices = bnd_face.corners()
points = self.geo.corners(bnd_face)
bnd_face.bnd = bnd_function({indices[i]: points[i] for i in range(len(indices))})
printProgressBar(i + 1, l, prefix='Setting Boundary:', suffix='Complete')
print_progress(i + 1, l, prefix='Setting Boundary:\t', suffix='')
def electrocute(self, elphy_function, elphy_data=None):
if elphy_data is None:
elphy_data = [0.0, 0.003, 30.0]
l = len(self.geo.bnd_faces())
printProgressBar(0, l, prefix='Setting Activation:', suffix='Complete')
print_progress(0, l, prefix='Setting Activation:\t', suffix='')
for i, bnd_face in enumerate(self.geo.bnd_faces()):
if bnd_face.bnd != 230:
continue
......@@ -69,7 +69,7 @@ class VtuMesh:
for j in range(len(points)):
if elphy_function(points[j]):
self.geo.set_vdata(indices[j], elphy_data)
printProgressBar(i + 1, l, prefix='Setting Activation:', suffix='Complete')
print_progress(i + 1, l, prefix='Setting Activation:\t', suffix='')
def read_celldata(self, cell_indices):
for ci in cell_indices:
......@@ -102,11 +102,11 @@ class VtuMesh:
def overwrite_subdomains(self, othergeo):
cell_size = len(self.geo.cells)
printProgressBar(0, cell_size, prefix='Overwriting subdomains:', suffix='Complete')
print_progress(0, cell_size, prefix='Overwriting subdomains:', suffix='')
for i, c in self.geo.cells.items():
nearest_c = othergeo.nearest_cell(self.geo.center(c))
c.subdomain = nearest_c.subdomain
printProgressBar(i + 1, cell_size, prefix='Overwriting subdomains:', suffix='Complete')
print_progress(i + 1, cell_size, prefix='Overwriting subdomains:', suffix='')
quarter_ellipsoid_endocard = (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment