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);