From 3efdbf4451f416219d72791471ab0f1cdef3b674 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Tue, 10 Oct 2023 10:43:24 -0400 Subject: [PATCH] Abort on nan --- src/navier-stokes.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/navier-stokes.c b/src/navier-stokes.c index 6c59f4e..77f6d99 100644 --- a/src/navier-stokes.c +++ b/src/navier-stokes.c @@ -226,6 +226,12 @@ int enstrophy( alpha=compute_alpha(u, K1, K2, g, L); enstrophy=compute_enstrophy(u, K1, K2, L); + // check that anything is nan + if(isnan(alpha) || isnan(enstrophy)){ + fprintf(stderr,"nan encountered, aborting.\n"); + break; + } + // add to running averages (estimate the total duration of interval as print_freq, will be adjusted later) avg_a+=alpha*(step/print_freq); avg_en+=enstrophy*(step/print_freq);