Skip to content

Commit

Permalink
use isnan instead of is
Browse files Browse the repository at this point in the history
  • Loading branch information
keiyamamo committed Nov 3, 2023
1 parent 295cf70 commit 0a43d45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions turtleFSI/modules/newtonsolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# PURPOSE.

from dolfin import assemble, derivative, TrialFunction, Matrix, norm, MPI, PETScOptions
from numpy import nan as np_nan
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 @@ -104,7 +104,7 @@ 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 or rel_res is np_nan or residual is np_nan:
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:
Expand Down

0 comments on commit 0a43d45

Please sign in to comment.