Skip to content

Commit

Permalink
Merge pull request #60 from pyroteus/59_for_else
Browse files Browse the repository at this point in the history
Use for/else loop in `fixed_point_iteration` methods
  • Loading branch information
jwallwork23 authored Oct 26, 2023
2 parents a08b9b0 + d8547af commit d9ddc0b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
25 changes: 11 additions & 14 deletions goalie/go_mesh_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ def fixed_point_iteration(
self.vertex_counts = [self.count_vertices()]
self.qoi_values = []
self.estimator_values = []
converged = False
self.converged[:] = False
self.check_convergence[:] = True

Expand Down Expand Up @@ -320,20 +319,18 @@ def fixed_point_iteration(
break

# Convergence check for 'all' mode
converged = qoi_converged and ee_converged and elem_converged
if converged:
if qoi_converged and ee_converged and elem_converged:
break

if self.params.convergence_criteria == "all":
if not converged:
self.converged[:] = False
pyrint(f"Failed to converge in {self.params.maxiter} iterations.")
else:
for i, conv in enumerate(self.converged):
if not conv:
pyrint(
f"Failed to converge on subinterval {i} in {self.params.maxiter}"
" iterations."
)
if self.params.convergence_criteria == "all":
pyrint(f"Failed to converge in {self.params.maxiter} iterations.")
self.converged[:] = False
else:
for i, conv in enumerate(self.converged):
if not conv:
pyrint(
f"Failed to converge on subinterval {i} in"
f" {self.params.maxiter} iterations."
)

return sols, indicators
14 changes: 7 additions & 7 deletions goalie/mesh_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,12 +678,12 @@ def fixed_point_iteration(
self.converged[:] = self.check_element_count_convergence()
if self.converged.all():
break

for i, conv in enumerate(self.converged):
if not conv:
pyrint(
f"Failed to converge on subinterval {i} in {self.params.maxiter}"
" iterations."
)
else:
for i, conv in enumerate(self.converged):
if not conv:
pyrint(
f"Failed to converge on subinterval {i} in"
f" {self.params.maxiter} iterations."
)

return sols

0 comments on commit d9ddc0b

Please sign in to comment.