From 5ce9d4272aa25717ff5a475a4288ff1c840d4b40 Mon Sep 17 00:00:00 2001 From: Cole Kendrick Date: Thu, 25 Apr 2024 08:27:49 -0700 Subject: [PATCH] Add window rdim/ef file option to parametric_tw --- examples/dmd/parametric_tw_csv.cpp | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/examples/dmd/parametric_tw_csv.cpp b/examples/dmd/parametric_tw_csv.cpp index db2e9c4fc..d34460f68 100644 --- a/examples/dmd/parametric_tw_csv.cpp +++ b/examples/dmd/parametric_tw_csv.cpp @@ -123,6 +123,7 @@ int main(int argc, char *argv[]) const char *test_list = "dmd_test"; const char *temporal_idx_list = "temporal_idx"; const char *spatial_idx_list = "spatial_idx"; + const char *window_file = "dmd_windows"; const char *hdf_name = "dmd"; const char *snap_pfx = "step"; const char *basename = ""; @@ -199,6 +200,8 @@ int main(int argc, char *argv[]) "Use CSV or HDF format for input files."); args.AddOption(&useWindowDims, "-wdim", "--wdim", "-no-wdim", "--no-wdim", "Use DMD dimensions for each window, input from a CSV file."); + args.AddOption(&window_file, "-window-set", "--window-set-name", + "Name of the file containing a rdim/ef list for each window within the list directory."); args.AddOption(&subsample, "-subs", "--subsample", "Subsampling factor for training snapshots."); args.AddOption(&eval_subsample, "-esubs", "--eval_subsample", @@ -494,6 +497,48 @@ int main(int argc, char *argv[]) } } + // Load window RDIM/EF file if given + vector window_str_list; + vector window_list; + bool use_rdim_windows = false; + csv_db.getStringVector(string(list_dir) + "/" + string(window_file) + ".csv", + window_str_list, false); + if (window_str_list.size() > 0) + { + if (numWindows > 0) + { + CAROM_VERIFY(numWindows == window_str_list.size() - 1); + } + + if (window_str_list[0] == "RDIM") + { + use_rdim_windows = true; + } + + CAROM_VERIFY(window_str_list[0] == "RDIM" || window_str_list[0] == "EF"); + + for (int i = 1; i < window_str_list.size(); i++) + { + std::string tmp; + std::stringstream window_ss(window_str_list[i]); + getline(window_ss, tmp, ','); + getline(window_ss, tmp, ','); + window_list.push_back(stod(tmp)); + } + + numWindows = window_list.size(); + + if (myid == 0) + { + std::cout << "Read window file with " << window_list.size() << " windows:\n"; + for (int i = 0; i < window_list.size(); i++) + { + std::cout << " Window " << i << ": " << (use_rdim_windows ? "RDIM = " : + "EF = ") << window_list[i] << "\n"; + } + } + } + vector windowDim; if (useWindowDims) { @@ -662,6 +707,15 @@ int main(int argc, char *argv[]) if (useWindowDims) rdim = windowDim[window]; + if (window_list.size() > 0) + { + if (use_rdim_windows) { + rdim = window_list[window]; + } else { + ef = window_list[window]; + } + } + if (rdim != -1) { if (myid == 0)