Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input file #44

Merged
merged 20 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]; }
streeve marked this conversation as resolved.
Show resolved Hide resolved

// 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
Loading