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

added check for nan value in the newtonsolver #100

Merged
merged 2 commits into from
Nov 5, 2023
Merged
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
5 changes: 3 additions & 2 deletions turtleFSI/modules/newtonsolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# PURPOSE.

from dolfin import assemble, derivative, TrialFunction, Matrix, norm, MPI, PETScOptions
from numpy import isnan

PETScOptions.set("mat_mumps_icntl_4", 1) # If negatvie or zero, MUMPS will suppress diagnositc printining, statistics, and warning messages.
PETScOptions.set("mat_mumps_icntl_14", 400) # allocate more memory to mumps
Expand Down Expand Up @@ -103,8 +104,8 @@ def newtonsolver(F, J_nonlinear, A_pre, A, b, bcs, lmbda, recompute, recompute_t
# Check residual
residual = b.norm('l2')
rel_res = norm(dvp_res, 'l2')
if rel_res > 1E20 or residual > 1E20:
raise RuntimeError("Error: The simulation has diverged during the Newton solve.")
if rel_res > 1E20 or residual > 1E20 or isnan(rel_res) or isnan(residual):
raise RuntimeError("Error: The simulation has diverged during the Newton solve with residual = %.3e and relative residual = %.3e" % (residual, rel_res))

if MPI.rank(MPI.comm_world) == 0 and verbose:
print("Newton iteration %d: r (atol) = %.3e (tol = %.3e), r (rel) = %.3e (tol = %.3e) "
Expand Down
Loading