Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use for/else loop in fixed_point_iteration methods #60

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading