From 15252383d962fc2298ee9b3d34fa7e700c4bfe5b Mon Sep 17 00:00:00 2001 From: psakiev Date: Sat, 22 Jul 2023 23:29:25 -0600 Subject: [PATCH] WIP: Get test case working --- .gitignore | 3 +++ app/exawind/exawind.cpp | 38 ++++++++++++++++++++++++-------------- src/NaluWind.h | 7 +++---- test/CMakeLists.txt | 1 + 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index e43b0f9..06b3fdb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .DS_Store +spack* +compile_commands.json +.cache diff --git a/app/exawind/exawind.cpp b/app/exawind/exawind.cpp index 4d041b0..488af9f 100644 --- a/app/exawind/exawind.cpp +++ b/app/exawind/exawind.cpp @@ -89,9 +89,9 @@ int main(int argc, char** argv) #endif std::ofstream out; - const auto nalu_node = node["nalu_wind_inp"]; + YAML::Node nalu_node = node["nalu_wind_inp"]; // make sure it is a list for now - assert(nalu_node.IsSequence); + assert(nalu_node.IsSequence()); const int num_nwsolvers = nalu_node.size(); if (num_nwind_ranks < num_nwsolvers) { throw std::runtime_error( @@ -184,28 +184,29 @@ int main(int argc, char** argv) ? node["nonlinear_iterations"].as() : 1; - const auto yaml_replace_all = node["nalu_replace_all"]; + const YAML::Node yaml_replace_all = node["nalu_replace_all"]; for (int i = 0; i < num_nwsolvers; i++) { if (nalu_comms.at(i) != MPI_COMM_NULL) { YAML::Node yaml_replace_instance; std::string nalu_inpfile, logfile; - if (nalu_node[i].IsMap()) { - yaml_replace_instance = nalu_node["replace"]; - nalu_inpfile = nalu_node["input_file"].as(); + YAML::Node this_instance = nalu_node[i]; + if (this_instance.IsMap()) { + yaml_replace_instance = this_instance["replace"]; + nalu_inpfile = this_instance["base_input_file"].as(); // deal with the logfile name - if (nalu_node["logfile"]) { - logfile = nalu_node["logfile"].as(); + if (this_instance["logfile"]) { + logfile = this_instance["logfile"].as(); } else { - logfile = exawind::NaluWind::logfile_from_input_file_name( - nalu_inpfile, i); + logfile = exawind::NaluWind::change_file_name_suffix( + nalu_inpfile, ".log", i); } } else { - nalu_inpfile = nalu_node[i].as(); - logfile = exawind::NaluWind::logfile_from_input_file_name( - nalu_inpfile); + nalu_inpfile = this_instance.as(); + logfile = exawind::NaluWind::change_file_name_suffix( + nalu_inpfile, ".log"); } - auto nalu_yaml = YAML::Load(nalu_inpfile); + YAML::Node nalu_yaml = YAML::LoadFile(nalu_inpfile); // replace in order so instance can overwrite all if (yaml_replace_all) { YEDIT::find_and_replace(nalu_yaml, yaml_replace_all); @@ -214,6 +215,15 @@ int main(int argc, char** argv) YEDIT::find_and_replace(nalu_yaml, yaml_replace_instance); } + if (nalu_node["write_final_yaml_to_disk"]) { + auto new_ifile_name = + exawind::NaluWind::change_file_name_suffix( + logfile, ".yaml"); + std::ofstream fout(new_ifile_name); + fout << nalu_yaml; + fout.close(); + } + sim.register_solver( i + 1, nalu_comms.at(i), nalu_yaml, logfile, nalu_vars); } diff --git a/src/NaluWind.h b/src/NaluWind.h index 14f9a00..7faff21 100644 --- a/src/NaluWind.h +++ b/src/NaluWind.h @@ -28,16 +28,15 @@ class NaluWind : public ExawindSolver static void initialize(); static void finalize(); static std::string - logfile_from_input_file_name(std::string inpfile, int index = -1) + change_file_name_suffix(std::string inpfile, std::string suffix, int index = -1) { int extloc = inpfile.rfind("."); std::string logfile = inpfile; - std::string tail = ".log"; if (index >= 0) { - tail = "_" + std::to_string(index) + tail; + suffix = "_" + std::to_string(index) + suffix; } if (extloc != std::string::npos) { - logfile = inpfile.substr(0, extloc) + tail; + logfile = inpfile.substr(0, extloc) + suffix; } return logfile; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fa68c7f..abdd174 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -61,3 +61,4 @@ add_test_r(nalu-nalu-cylinder) add_test_r(amr-nalu-cylinder) add_test_r(nalu-nalu-cylinder-motion) add_test_r(amr-nalu-cylinder-motion) +add_test_r(hybrid-multi-cylinder)