Commit f8e85580 authored by David Deepwell's avatar David Deepwell
Browse files

Shift iter counter to use 0 at initial time

The addition of an analysis call on the initial data resulted
in the Nth time step to correspond with iteration N+1. This isn't
a problem, just dissatisfying.
parent 42803c3b
...@@ -413,7 +413,7 @@ void BaseCase::write_diagnostics(string header, string line, ...@@ -413,7 +413,7 @@ void BaseCase::write_diagnostics(string header, string line,
FILE * diagnos_file = fopen("diagnostics.txt","a"); FILE * diagnos_file = fopen("diagnostics.txt","a");
assert(diagnos_file); assert(diagnos_file);
// print header // print header
if (iter == 1 and !restarting) { if (iter == 0 and !restarting) {
fprintf(diagnos_file,"%s\n",clean_header.c_str()); fprintf(diagnos_file,"%s\n",clean_header.c_str());
} }
// print the line of values // print the line of values
...@@ -487,7 +487,7 @@ void BaseCase::stresses_top(TArrayn::DTArray & u, TArrayn::DTArray & v, TArrayn: ...@@ -487,7 +487,7 @@ void BaseCase::stresses_top(TArrayn::DTArray & u, TArrayn::DTArray & v, TArrayn:
if (master()) { if (master()) {
FILE * stresses_file = fopen("stresses_top.txt","a"); FILE * stresses_file = fopen("stresses_top.txt","a");
assert(stresses_file); assert(stresses_file);
if ( itercount==1 and !restarting ) if ( itercount==0 and !restarting )
fprintf(stresses_file,"Time, " fprintf(stresses_file,"Time, "
"Top_tx_tot, Top_tx_abs, Top_ty_tot, Top_ty_abs, Top_ts\n"); "Top_tx_tot, Top_tx_abs, Top_ty_tot, Top_ty_abs, Top_ts\n");
fprintf(stresses_file,"%.17f, " fprintf(stresses_file,"%.17f, "
...@@ -533,7 +533,7 @@ void BaseCase::stresses_bottom(TArrayn::DTArray & u, TArrayn::DTArray & v, TArra ...@@ -533,7 +533,7 @@ void BaseCase::stresses_bottom(TArrayn::DTArray & u, TArrayn::DTArray & v, TArra
if (master()) { if (master()) {
FILE * stresses_file = fopen("stresses_bottom.txt","a"); FILE * stresses_file = fopen("stresses_bottom.txt","a");
assert(stresses_file); assert(stresses_file);
if ( itercount==1 and !restarting ) if ( itercount==0 and !restarting )
fprintf(stresses_file,"Time, " fprintf(stresses_file,"Time, "
"Bottom_tx_tot, Bottom_tx_abs, Bottom_ty_tot, Bottom_ty_abs, Bottom_ts\n"); "Bottom_tx_tot, Bottom_tx_abs, Bottom_ty_tot, Bottom_ty_abs, Bottom_ts\n");
fprintf(stresses_file,"%.17f, " fprintf(stresses_file,"%.17f, "
......
...@@ -35,6 +35,9 @@ namespace NSIntegrator { ...@@ -35,6 +35,9 @@ namespace NSIntegrator {
/* Control framework for a full run. At the first timestep(s), take /* Control framework for a full run. At the first timestep(s), take
fractional timesteps to start up. */ fractional timesteps to start up. */
// Analyze the initial conditions
usercode->analysis(times[0],us[0],vs[0],ws[0],tracers_now,pressure);
while (times[0] < (fintime - 1e-8*fabs(fintime))) { while (times[0] < (fintime - 1e-8*fabs(fintime))) {
// Since we're not done, we need to take a timestep. // Since we're not done, we need to take a timestep.
...@@ -84,9 +87,6 @@ namespace NSIntegrator { ...@@ -84,9 +87,6 @@ namespace NSIntegrator {
total time integration error. So, if we're starting up, total time integration error. So, if we're starting up,
we take a small timestep and progressively double it. */ we take a small timestep and progressively double it. */
if (times[-1] == times[-2]) { if (times[-1] == times[-2]) {
// Analyze the initial conditions
usercode->analysis(times[0],us[0],vs[0],ws[0],tracers_now,pressure);
/* Startup, so take a tiny timestep */ /* Startup, so take a tiny timestep */
my_step = the_timestep/64; my_step = the_timestep/64;
starting_step = true; starting_step = true;
......
...@@ -335,7 +335,7 @@ void compute_Background_PE(double & BPE_tot, TArrayn::DTArray & rho, ...@@ -335,7 +335,7 @@ void compute_Background_PE(double & BPE_tot, TArrayn::DTArray & rho,
static vector < pair<double, double> > height_width(Nx); static vector < pair<double, double> > height_width(Nx);
// Stuff to do once at the beginning // Stuff to do once at the beginning
if (iter == 1) { if (iter == 0) {
// create array of voxels // create array of voxels
quad3 = alloc_array(Nx,Ny,Nz); quad3 = alloc_array(Nx,Ny,Nz);
*quad3 = (*get_quad_x())(ii)*(*get_quad_y())(jj)*(*get_quad_z())(kk); *quad3 = (*get_quad_x())(ii)*(*get_quad_y())(jj)*(*get_quad_z())(kk);
......
...@@ -188,10 +188,8 @@ class userControl : public BaseCase { ...@@ -188,10 +188,8 @@ class userControl : public BaseCase {
/* Basic analysis: compute secondary variables, and save fields and diagnostics */ /* Basic analysis: compute secondary variables, and save fields and diagnostics */
void analysis(double time, DTArray & u, DTArray & v, DTArray & w, void analysis(double time, DTArray & u, DTArray & v, DTArray & w,
vector<DTArray *> & tracers, DTArray & pressure) { vector<DTArray *> & tracers, DTArray & pressure) {
// increase counter
iter++;
// Set-up // Set-up
if ( iter == 1 ) { if ( iter == 0 ) {
if ( compute_enstrophy or compute_dissipation or if ( compute_enstrophy or compute_dissipation or
compute_stresses_top or compute_stresses_bottom ) { compute_stresses_top or compute_stresses_bottom ) {
temp1 = alloc_array(Nx,Ny,Nz); temp1 = alloc_array(Nx,Ny,Nz);
...@@ -388,6 +386,8 @@ class userControl : public BaseCase { ...@@ -388,6 +386,8 @@ class userControl : public BaseCase {
plot_number, u, v, w, tracers); plot_number, u, v, w, tracers);
// Change dump log file if successfully reached final time // Change dump log file if successfully reached final time
successful_dump(plot_number, final_time, plot_interval); successful_dump(plot_number, final_time, plot_interval);
// increase counter
iter++;
} }
// User specified variables to dump // User specified variables to dump
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment