From e97bfac7466c284338fd4fa7c33e678cb7ad17ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Skrzy=C5=84ski?= Date: Thu, 8 Aug 2024 20:44:36 +0200 Subject: [PATCH] avoid redundant initialization --- src/inputFile.h | 43 ++++++++++++++++++++++------------------- src/inputFile_impl.h | 46 +------------------------------------------- 2 files changed, 24 insertions(+), 65 deletions(-) diff --git a/src/inputFile.h b/src/inputFile.h index 16e9019..10503eb 100644 --- a/src/inputFile.h +++ b/src/inputFile.h @@ -58,6 +58,7 @@ #include #include +#include #include #include @@ -149,18 +150,20 @@ template class InputFile { private: - bool timestepflag; // input timestep? + bool timestepflag = false; // input timestep? public: InputCL commandline; t_System *system; bool _print_rank; - int units_style; - int lattice_style; - double lattice_constant, lattice_offset_x, lattice_offset_y, - lattice_offset_z; + + // defaults match ExaMiniMD LJ example + int units_style = UNITS_LJ; + int lattice_style = LATTICE_FCC; + double lattice_constant = 0.8442, lattice_offset_x = 0.0, + lattice_offset_y = 0.0, lattice_offset_z = 0.0; int lattice_nx, lattice_ny, lattice_nz; - int box[6]; + std::array box = { 0, 40, 0, 40, 0, 40 }; char *data_file; int data_file_type; @@ -168,33 +171,33 @@ class InputFile std::string output_file; std::string error_file; - double temperature_target; - int temperature_seed; + double temperature_target = 1.4; + int temperature_seed = 87287; - int integrator_type; - int nsteps; + int integrator_type = INTEGRATOR_NVE; + int nsteps = 100; - int binning_type; + int binning_type = BINNING_LINKEDCELL; - int comm_type; - int comm_exchange_rate; + int comm_type = COMM_MPI; + int comm_exchange_rate = 20; - int force_type; + int force_type = FORCE_LJ; int force_iteration_type; int force_neigh_parallel_type; - T_F_FLOAT force_cutoff; + T_F_FLOAT force_cutoff = 2.5; std::vector> force_coeff_lines; - T_F_FLOAT neighbor_skin; - int neighbor_type; - T_INT max_neigh_guess; + T_F_FLOAT neighbor_skin = 0.0; + int neighbor_type = NEIGH_VERLET_2D; + T_INT max_neigh_guess = 50; int layout_type; int nnp_layout_type; - int thermo_rate, dumpbinary_rate, correctness_rate; - bool dumpbinaryflag, correctnessflag; + int thermo_rate = 10, dumpbinary_rate = 0, correctness_rate = 0; + bool dumpbinaryflag = false, correctnessflag = false; char *dumpbinary_path, *reference_path, *correctness_file; std::string input_data_file; std::string output_data_file; diff --git a/src/inputFile_impl.h b/src/inputFile_impl.h index f4edc44..93fcf9b 100644 --- a/src/inputFile_impl.h +++ b/src/inputFile_impl.h @@ -49,7 +49,7 @@ #include #include -#include +#include #include std::vector split( const std::string &line ) @@ -71,56 +71,12 @@ InputFile::InputFile( InputCL commandline_, t_System *system_ ) : commandline( commandline_ ) , system( system_ ) { - comm_type = COMM_MPI; - integrator_type = INTEGRATOR_NVE; - neighbor_type = NEIGH_VERLET_2D; - force_type = FORCE_LJ; - binning_type = BINNING_LINKEDCELL; - neighbor_type = commandline.neighbor_type; force_iteration_type = commandline.force_iteration_type; force_neigh_parallel_type = commandline.force_neigh_parallel_type; output_file = commandline.output_file; error_file = commandline.error_file; - - // set defaults (matches ExaMiniMD LJ example) - - nsteps = 0; - - thermo_rate = 0; - dumpbinary_rate = 0; - correctness_rate = 0; - dumpbinaryflag = false; - correctnessflag = false; - timestepflag = false; - - lattice_offset_x = 0.0; - lattice_offset_y = 0.0; - lattice_offset_z = 0.0; - box[0] = 0; - box[2] = 0; - box[4] = 0; - box[1] = 40; - box[3] = 40; - box[5] = 40; - - units_style = UNITS_LJ; - lattice_style = LATTICE_FCC; - lattice_constant = 0.8442; - - temperature_target = 1.4; - temperature_seed = 87287; - - nsteps = 100; - thermo_rate = 10; - - neighbor_skin = 0.3; - neighbor_skin = 0.0; // for metal and real units - max_neigh_guess = 50; - comm_exchange_rate = 20; - - force_cutoff = 2.5; } template