Skip to content

Commit

Permalink
Updated deprecation notices and log file print
Browse files Browse the repository at this point in the history
  • Loading branch information
MattRolchigo committed Aug 26, 2024
1 parent 068ca46 commit 066aa03
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
48 changes: 33 additions & 15 deletions src/CAinputs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,26 +314,40 @@ struct Inputs {
((input_data["Substrate"].contains("MeanSize")) ||
(input_data["Substrate"].contains("MeanBaseplateGrainSize"))))
throw std::runtime_error(
"Error: only one of substrate grain size and substrate structure filename should "
"Error: only one of baseplate grain size and substrate structure filename should "
"be provided in the input file");
else if (input_data["Substrate"].contains("SubstrateFilename")) {
substrate.substrate_filename = input_data["Substrate"]["SubstrateFilename"];
if (substrate.substrate_filename.substr(substrate.substrate_filename.length() - 4) != ".vtk")
throw std::runtime_error("Error: Substrate filename must be a vtk file");
substrate.use_substrate_file = true;
}
else if (input_data["Substrate"].contains("MeanSize")) {
substrate.baseplate_grain_spacing = input_data["Substrate"]["MeanSize"];
substrate.use_substrate_file = false;
}
else if (input_data["Substrate"].contains("MeanBaseplateGrainSize")) {
substrate.baseplate_grain_spacing = input_data["Substrate"]["MeanBaseplateGrainSize"];
substrate.use_substrate_file = false;
// Warning for case where both the deprecated and new input were given
if ((input_data["Substrate"].contains("MeanSize")) && (id == 0))
std::cout << "Warning: redundant inputs MeanSize and MeanBaseplateGrainSize were given - "
"deprecated input MeanSize will be ignored"
<< std::endl;
else if (input_data["Substrate"].contains("MeanSize") ||
(input_data["Substrate"].contains("MeanBaseplateGrainSize"))) {
// Case where only the deprecated input MeanSize was given
if (!input_data["Substrate"].contains("MeanBaseplateGrainSize")) {
substrate.baseplate_grain_spacing = input_data["Substrate"]["MeanSize"];
substrate.use_substrate_file = false;
if (id == 0)
std::cout
<< "Warning: deprecated input MeanSize has been replaced with MeanBaseplateGrainSize, "
"compatibility with MeanSize input will be removed in a future release"
<< std::endl;
}
else {
// Case were the new input MeanBaseplateGrainSize was given
substrate.baseplate_grain_spacing = input_data["Substrate"]["MeanBaseplateGrainSize"];
substrate.use_substrate_file = false;
// Warning for case where both the deprecated and new input were given
if ((input_data["Substrate"].contains("MeanSize")) && (id == 0))
std::cout << "Warning: redundant inputs MeanSize and MeanBaseplateGrainSize were given - "
"deprecated input MeanSize will be ignored"
<< std::endl;
}
// Check that baseplate_grain_spacing is valid
if ((id == 0) && (substrate.baseplate_grain_spacing < domain.deltax))
throw std::runtime_error(
"Error: Input MeanBaseplateGrainSize must be no smaller than the CA cell size");
}
if (simulation_type == "Spot") {
// No powder for this problem type, baseplate top at Z = 0
Expand Down Expand Up @@ -746,8 +760,12 @@ struct Inputs {
if (substrate.use_substrate_file)
exaca_log << " \"SubstrateFilename\": "
<< "\"" << substrate.substrate_filename << "\"" << std::endl;
else
exaca_log << " \"MeanSize\": " << substrate.baseplate_grain_spacing << std::endl;
else {
exaca_log << " \"MeanSize\": " << substrate.baseplate_grain_spacing << "," << std::endl;
exaca_log << " \"MeanBaseplateGrainSize\": " << substrate.baseplate_grain_spacing << ","
<< std::endl;
exaca_log << " \"MeanPowderGrainSize\": " << substrate.powder_grain_spacing << std::endl;
}
}
exaca_log << " }," << std::endl;
exaca_log << " \"InterfacialResponse\": {" << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion unit_test/tstInputs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void writeTestData(std::string input_filename, int print_version) {
<< std::endl;
test_data_file << " }," << std::endl;
test_data_file << " \"Substrate\": {" << std::endl;
// Note: old input used here to check that the expected mean powder grain spacing ends up correct
// FIXME: old input PowderDensity used here to check that the expected mean powder grain spacing ends up correct,
// change this to MeanPowderGrainSize when deprecated input compatibility is removed
test_data_file << " \"SubstrateFilename\": \"DummySubstrate.vtk\"," << std::endl;
test_data_file << " \"PowderDensity\": 1000," << std::endl;
test_data_file << " \"BaseplateTopZ\": -0.00625" << std::endl;
Expand Down

0 comments on commit 066aa03

Please sign in to comment.