From 519bb7272661ae4fb81a9c4851133cd8e7da1805 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Tue, 25 Apr 2023 16:38:25 -0400 Subject: running average in statistics file --- src/navier-stokes.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'src/navier-stokes.c') diff --git a/src/navier-stokes.c b/src/navier-stokes.c index a344ae4..153631b 100644 --- a/src/navier-stokes.c +++ b/src/navier-stokes.c @@ -1,5 +1,6 @@ -#include "navier-stokes.h" #include "io.h" +#include "navier-stokes.h" +#include "statistics.h" #include #include #include @@ -131,26 +132,10 @@ int eea( energy=compute_energy(u, K1, K2); alpha=compute_alpha(u, K1, K2, g, L); enstrophy=compute_enstrophy(u, K1, K2, L); - - // running average - // reset averages - if(t % print_freq == 1){ - avg_e=0; - avg_a=0; - avg_en=0; - } - // compute average - // different computationin first box if starting_time is not a multiple of print_freq - if(t < starting_time + first_box){ - avg_e+=energy/first_box; - avg_a+=alpha/first_box; - avg_en+=enstrophy/first_box; - } else { - avg_e+=energy/print_freq; - avg_a+=alpha/print_freq; - avg_en+=enstrophy/print_freq; - } + avg_e=average_step(energy, avg_e, t, starting_time, print_freq, first_box); + avg_a=average_step(alpha, avg_a, t, starting_time, print_freq, first_box); + avg_en=average_step(enstrophy, avg_en, t, starting_time, print_freq, first_box); if(t>starting_time && t%print_freq==0){ fprintf(stderr,"%lu % .8e % .8e % .8e % .8e % .8e % .8e % .8e\n",t,t*delta, avg_a, avg_e, avg_en, alpha, energy, enstrophy); -- cgit v1.2.3-54-g00ecf