Commit e3adc1f9 authored by Christopher Subich's avatar Christopher Subich
Browse files

Move BC-parsing helper to BaseCase

This commit moves the helper function that process
expansion/boundary conditions ("FOURIER" -> PERIODIC, etc)
to BaseCase.cpp, from Options.

This change should be invisible to most case files, which
habitually include BaseCase for helper functions as-is, but
it allows Options to once again be independent of
NSIntegrator.  This improves modularity for other uses of
the code, such as a hypothetical SPINSoff (get it?  it's a
pun) that would like to do some spectral voodoo with an
option file but doesn't need the full Navier-Stokes
machinery.
parent b5470525
......@@ -366,3 +366,37 @@ void BaseCase::successful_dump(int plot_number, double final_time, double plot_i
fclose(dump_file);
}
}
// 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);
}
}
......@@ -163,6 +163,10 @@ class BaseCase {
Array<double,1> *xx=0, Array<double,1> *yy=0, Array<double,1> *zz=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);
extern template class FluidEvolve<BaseCase>;
typedef FluidEvolve<BaseCase> EasyFlow; // Explicit template instantiation
#endif
......@@ -227,35 +227,3 @@ 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,9 +5,6 @@
#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>
......@@ -70,7 +67,4 @@ 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
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