Skip to content

Commit

Permalink
prints all inputs to output parameters file
Browse files Browse the repository at this point in the history
  • Loading branch information
James committed May 31, 2018
1 parent fb58971 commit bc5c7a0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
16 changes: 16 additions & 0 deletions src/Mesher_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,21 @@ int main(int argc, char* argv[])
// Put together parameters
std::map<std::string, std::string> parameters;

// Add all options to the parameter map

for (auto elem : options )
{
//cout << elem.first << " " << elem.second << endl; // print the parameters and the values
//parameters[elem.first] = to_string(elem.second);

// make the stream object - this makes nicer strings that to_string (although that might be because I dont know how to use it well)
std::ostringstream currentVal;
currentVal << elem.second;
parameters[elem.first] = currentVal.str(); // save into the parameters map

}


parameters["ground.hsquared"] = string("1.5e-5");

// Need to convert double to string before adding to parameter map
Expand All @@ -223,6 +238,7 @@ int main(int argc, char* argv[])
parameters["groundposition.y"] = gndposy.str();
parameters["groundposition.z"] = gndposz.str();


// Base filenames for electrode positions and parameters
output_base_file = output_dir + output_mesh_name;

Expand Down
35 changes: 29 additions & 6 deletions src/save_dgf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,40 @@ void save_parameters(map<string, string> parameters, string output_file)
cout << "Writing parameter file: " << output_file << '\n';

// Use stream for writing output file, easier to use with map data structure that fprintf
fstream parameter_file;
parameter_file.open(output_file.c_str(), fstream::out);
ofstream parameter_file;
parameter_file.open(output_file.c_str());

map<string, string>::iterator it;
if (parameter_file.is_open())
{
parameter_file << "# Mesher parameters" << endl ;

//map<string, string>::iterator it;

/*
for (it = parameters.begin(); it != parameters.end(); it++)
{
//parameter_file << it->first << ": " << it->second << endl;
//cout << it->first << ": " << it->second << endl;
}
*/

for (auto param_elem : parameters)
{
//cout << elem.first << ": " << elem.second << endl; // print the parameters and the values
parameter_file << param_elem.first << ": " << param_elem.second << endl; // print the parameters and the values
}

for (it = parameters.begin(); it != parameters.end(); it++)
parameter_file.close();
}
else
{
parameter_file << it->first << ": " << it->second << endl << endl;
cout << "Unable to open parameter file";
}

parameter_file.close();





}

Expand Down

0 comments on commit bc5c7a0

Please sign in to comment.