Skip to content

Commit

Permalink
Added 'value' to some input instances
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloseleson committed Nov 15, 2023
1 parent 7034979 commit 114e97d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/CabanaPD_Input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ class Inputs
double tf = inputs["final_time"]["value"];
double dt = inputs["timestep"]["value"];
int num_steps = tf / dt;
inputs["num_steps"] = num_steps;
inputs["num_steps"]["value"] = num_steps;

// Output files.
if ( !inputs.contains( "output_file" ) )
inputs["output_file"] = "cabanaPD.out";
inputs["output_file"]["value"] = "cabanaPD.out";
if ( !inputs.contains( "error_file" ) )
inputs["error_file"] = "cabanaPD.err";
inputs["input_file"] = filename;
inputs["error_file"]["value"] = "cabanaPD.err";
inputs["input_file"]["value"] = filename;

// Save inputs (including derived) to new file.
std::string input_file = "cabanaPD.in.json";
if ( !inputs.contains( "exported_input_file" ) )
inputs["exported_input_file"] = input_file;
inputs["exported_input_file"]["value"] = input_file;
std::ofstream in( input_file );
in << inputs;

if ( !inputs.contains( "output_reference" ) )
inputs["output_reference"] = true;
inputs["output_reference"]["value"] = true;

// Not yet a user option.
inputs["half_neigh"] = false;
inputs["half_neigh"]["value"] = false;
}
~Inputs() {}

Expand All @@ -72,7 +72,7 @@ class Inputs
}

// Get a single input.
auto operator[]( std::string label ) { return inputs[label]; }
auto operator[]( std::string label ) { return inputs[label]["value"]; }

// Check a key exists.
bool contains( std::string label ) { return inputs.contains( label ); }
Expand Down
10 changes: 5 additions & 5 deletions src/CabanaPD_Solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class SolverElastic
total_timer.reset();
init_timer.reset();

num_steps = inputs["num_steps"];
num_steps = inputs["num_steps"]["value"];
output_frequency = inputs["output_frequency"]["value"];
output_reference = inputs["output_reference"]["value"];

Expand All @@ -150,8 +150,8 @@ class SolverElastic
int max_neighbors =
Cabana::NeighborList<neighbor_type>::maxNeighbor( *neighbors );

force =
std::make_shared<force_type>( inputs["half_neigh"], force_model );
force = std::make_shared<force_type>( inputs["half_neigh"]["value"],
force_model );

print = print_rank();
if ( print )
Expand All @@ -160,9 +160,9 @@ class SolverElastic
", Maximum local neighbors: ", max_neighbors );
log( std::cout, "#Timestep/Total-steps Simulation-time" );

output_file = inputs["output_file"];
output_file = inputs["output_file"]["value"];
std::ofstream out( output_file, std::ofstream::app );
error_file = inputs["error_file"];
error_file = inputs["error_file"]["value"];
std::ofstream err( error_file, std::ofstream::app );

auto time = std::chrono::system_clock::to_time_t(
Expand Down

0 comments on commit 114e97d

Please sign in to comment.