Commit 8e790761 authored by David Deepwell's avatar David Deepwell
Browse files

Update wave_reader case

parent d21912d5
......@@ -319,6 +319,27 @@ void BaseCase::init_tracer_dump(const std::string & field, DTArray & the_tracer)
return;
}
/* Read field from input data type */
void BaseCase::init_field(const std::string & field,
const std::string & filename, DTArray & the_field, input_types input_data_type) {
if (input_data_type == MATLAB) {
// from matlab
if (master()) fprintf(stdout,"Reading MATLAB-format %s (%d x %d) from %s\n",
field.c_str(),size_x(),size_z(),filename.c_str());
read_2d_slice(the_field,filename.c_str(),size_x(),size_z());
} else if (input_data_type == CTYPE) {
// from 2D spins output (generally, to go to 3D)
if (master()) fprintf(stdout,"Reading CTYPE-format %s (%d x %d) from %s\n",
field.c_str(),size_x(),size_z(),filename.c_str());
read_2d_restart(the_field,filename.c_str(),size_x(),size_z());
} else {
// from full (2D or 3D) spins output
// only suitable for initializing the grid
if (master()) fprintf(stdout,"Reading %s from %s\n",field.c_str(),filename.c_str());
read_array(the_field,filename.c_str(),size_x(),size_y(),size_z());
}
}
/* write out vertical chain of data */
void BaseCase::write_chain(const char *filename, DTArray & val, int Iout, int Jout, double time) {
FILE *fid=fopen(filename,"a");
......@@ -441,6 +462,18 @@ void BaseCase::write_plot_times(double time, double clock_time, double comp_dura
}
}
// parse file types
void parse_datatype(const string datatype, input_types & input_data_type) {
if (datatype=="MATLAB") { input_data_type = MATLAB; }
else if (datatype == "CTYPE") { input_data_type = CTYPE; }
else if (datatype == "FULL") { input_data_type = FULL; }
else {
if (master())
fprintf(stderr,"Invalid option %s received for file_type\n",datatype.c_str());
MPI_Finalize(); exit(1);
}
}
// 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) {
......
......@@ -13,6 +13,13 @@ using namespace NSIntegrator;
using blitz::Array;
using std::vector;
// Possible input data types
static enum input_types {
MATLAB,
CTYPE,
FULL
} input_data_types;
class BaseCase {
/* To reduce boilerplate, wrap some of the long functions, only calling
them if actually used by usercode. For example, a tracer-free code
......@@ -98,6 +105,8 @@ class BaseCase {
virtual void init_vels_dump(DTArray & u, DTArray & v, DTArray & w);
virtual void init_tracer_restart(const std::string & field, DTArray & the_tracer);
virtual void init_tracer_dump(const std::string & field, DTArray & the_tracer);
virtual void init_field(const std::string & field, const std::string & filename,
DTArray & the_field, input_types input_data_type);
virtual void init_grid_restart(const std::string & component,
const std::string & filename, DTArray & grid);
......@@ -191,6 +200,8 @@ extern template void BaseCase::add_diagnostic<int>(const string str, const int v
extern template void BaseCase::add_diagnostic<double>(const string str, const double val,
string & header, string & line);
// parse for data type
void parse_datatype(const string datatype, input_types & input_data_type);
// 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);
......
## density wave reader configuration file
# Spatial Parameters
Lx = 1.0
Ly = 0.1
Lz = 0.5
Nx = 256
Ny = 1
Nz = 128
min_x = 0
min_y = 0
min_z = 0
# Expansion types
type_x = FREE_SLIP
type_y = FREE_SLIP
type_z = FREE_SLIP
mapped_grid = false
# Physical Parameters
g = 9.81
rot_f = 0.0e-3
rho_0 = 1000.0
visco = 2e-6
kappa_rho = 1e-6
# 2D Input Files
file_type = CTYPE
xgrid = x2d
zgrid = z2d
u_file = u2d
w_file = w2d
rho_file = rho2d
tracer_file = trc2d
# Tracer Parameters
enable_tracer = false
tracer_kappa = 1.0e-6
tracer_gravity = 0
# Temporal Parameters
final_time = 10
plot_interval = 1
#dt_max = 0.0
# Restart Options
restart = false
restart_time = 0.0
restart_sequence = 0
restart_from_dump = false
compute_time = -1
# Perturbation Parameter
perturb = 0e-3
# Filter Parameters
f_cutoff = 0.6
f_order = 2.0
f_strength = 20.0
# secondary diagnostics
#compute_enstrophy = true
#compute_dissipation = true
#compute_BPE = true
#compute_internal_to_BPE = true
#compute_stresses_top = false
#compute_stresses_bottom = false
This diff is collapsed.
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