Commit 3035b35a authored by David Deepwell's avatar David Deepwell
Browse files

Move expansion parsing into Options.cpp

Parsing of expansion types in gravity_current.cpp moved to
Options.cpp. This is a general procedure that other case files
will and should make use of. It also simplifies the case file
to the specific set-up of that case.
parent 46ca2c72
......@@ -227,3 +227,35 @@ void adjust_for_dump(bool & restarting, double & restart_time, int & restart_seq
avg_write_time = max(write_time_per_G*Num_fields*Nx*Ny*Nz/pow(512.0,3), 20.0);
}
}
// parse expansion types
void parse_boundary_conditions(const string xgrid_type, const string ygrid_type,
const string zgrid_type, DIMTYPE & intype_x, DIMTYPE & intype_y, DIMTYPE & intype_z) {
// x
if (xgrid_type == "FOURIER") { intype_x = PERIODIC; }
else if (xgrid_type == "FREE_SLIP") { intype_x = FREE_SLIP; }
else if (xgrid_type == "NO_SLIP") { intype_x = NO_SLIP; }
else {
if (master())
fprintf(stderr,"Invalid option %s received for type_x\n",xgrid_type.c_str());
MPI_Finalize(); exit(1);
}
// y
if (ygrid_type == "FOURIER") { intype_y = PERIODIC; }
else if (ygrid_type == "FREE_SLIP") { intype_y = FREE_SLIP; }
else {
if (master())
fprintf(stderr,"Invalid option %s received for type_y\n",ygrid_type.c_str());
MPI_Finalize(); exit(1);
}
// z
if (zgrid_type == "FOURIER") { intype_z = PERIODIC; }
else if (zgrid_type == "FREE_SLIP") { intype_z = FREE_SLIP; }
else if (zgrid_type == "NO_SLIP") { intype_z = NO_SLIP; }
else {
if (master())
fprintf(stderr,"Invalid option %s received for type_z\n",zgrid_type.c_str());
MPI_Finalize(); exit(1);
}
}
......@@ -5,6 +5,9 @@
#define OPTIONS_HPP
#include <vector> // Vector
#include "NSIntegrator.hpp" // For Dim types
using namespace NSIntegrator;
// Include boost program options library
#include <boost/program_options.hpp>
......@@ -67,4 +70,7 @@ void options_parse(int argc, char ** argv);
void adjust_for_dump(bool & restarting, double & restart_time, int & restart_sequence,
const double final_time, const double compute_time, double & avg_write_time,
const int Num_tracers, const int Nx, const int Ny, const int Nz);
// parse expansion types
void parse_boundary_conditions(const string xgrid_type, const string ygrid_type,
const string zgrid_type, DIMTYPE & intype_x, DIMTYPE & intype_y, DIMTYPE & intype_z);
#endif
......@@ -286,7 +286,7 @@ class userControl : public BaseCase {
next_plot = next_plot + plot_interval;
// Find average time to write (for dump)
clock_time = MPI_Wtime(); // time just afer write
clock_time = MPI_Wtime(); // time just after write
avg_write_time = (avg_write_time*(plot_number-restart_sequence-1)
+ (clock_time - comp_duration))/(plot_number-restart_sequence);
// Print information about plot outputs
......@@ -409,38 +409,8 @@ int main(int argc, char ** argv) {
final_time, compute_time, avg_write_time, Num_tracers, Nx, Ny, Nz);
}
// Grid types:
if (xgrid_type == "FOURIER") {
intype_x = PERIODIC;
} else if (xgrid_type == "FREE_SLIP") {
intype_x = FREE_SLIP;
} else if (xgrid_type == "NO_SLIP") {
intype_x = NO_SLIP;
} else {
if (master())
fprintf(stderr,"Invalid option %s received for type_x\n",xgrid_type.c_str());
MPI_Finalize(); exit(1);
}
if (ygrid_type == "FOURIER") {
intype_y = PERIODIC;
} else if (ygrid_type == "FREE_SLIP") {
intype_y = FREE_SLIP;
} else {
if (master())
fprintf(stderr,"Invalid option %s received for type_y\n",ygrid_type.c_str());
MPI_Finalize(); exit(1);
}
if (zgrid_type == "FOURIER") {
intype_z = PERIODIC;
} else if (zgrid_type == "FREE_SLIP") {
intype_z = FREE_SLIP;
} else if (zgrid_type == "NO_SLIP") {
intype_z = NO_SLIP;
} else {
if (master())
fprintf(stderr,"Invalid option %s received for type_z\n",zgrid_type.c_str());
MPI_Finalize(); exit(1);
}
// parse expansion types
parse_boundary_conditions(xgrid_type, ygrid_type, zgrid_type, intype_x, intype_y, intype_z);
// adjust Ly for 2D
if (Ny==1 and Ly!=1.0) {
......
Supports Markdown
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