Skip to content

Commit

Permalink
Add window rdim/ef file option to parametric_tw
Browse files Browse the repository at this point in the history
  • Loading branch information
ckendrick committed Apr 25, 2024
1 parent 1f5aba8 commit 5ce9d42
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions examples/dmd/parametric_tw_csv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -494,6 +497,48 @@ int main(int argc, char *argv[])
}
}

// Load window RDIM/EF file if given
vector<string> window_str_list;
vector<double> 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<int> windowDim;
if (useWindowDims)
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5ce9d42

Please sign in to comment.