Skip to content

Commit

Permalink
avoid redundant initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed Sep 9, 2024
1 parent 6101e76 commit 6c2d117
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 65 deletions.
43 changes: 23 additions & 20 deletions src/inputFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include <system.h>
#include <types.h>

#include <array>
#include <fstream>
#include <vector>

Expand Down Expand Up @@ -149,52 +150,54 @@ template <class t_System>
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<int, 6> box = { 0, 40, 0, 40, 0, 40 };

char *data_file;
int data_file_type;

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<std::vector<std::string>> 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;
Expand Down
46 changes: 1 addition & 45 deletions src/inputFile_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include <inputFile.h>
#include <property_temperature.h>

#include <iostream>
#include <algorithm>
#include <regex>

std::vector<std::string> split( const std::string &line )
Expand All @@ -71,56 +71,12 @@ InputFile<t_System>::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 <class t_System>
Expand Down

0 comments on commit 6c2d117

Please sign in to comment.