From d7a8dfe59631f4c39f349a9649956cdc431922c9 Mon Sep 17 00:00:00 2001 From: Miroslav Stoyanov Date: Tue, 20 Aug 2024 19:51:11 -0400 Subject: [PATCH 1/2] fixes for two-stream and rieman problems --- infiles/landau1x3vasg.txt | 16 ++++++++-------- infiles/riemann1x3vmg.txt | 8 +++----- infiles/twostream2dasg.txt | 8 ++++---- python/asgard.py | 2 +- src/asgard_program_options.cpp | 14 +++++++++++++- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/infiles/landau1x3vasg.txt b/infiles/landau1x3vasg.txt index 5a5be4e84..fe008c390 100644 --- a/infiles/landau1x3vasg.txt +++ b/infiles/landau1x3vasg.txt @@ -1,5 +1,6 @@ -title : Landau 1x3v -subtitle : adaptive sparse grid, quadratic basis +# note: not ready yet # d_t f + v d_x f + E(f) d_v f= \nu C(f) # C(f) := d_v( (v-u)f + th d_v f )\ @@ -10,11 +11,10 @@ # mixed grid with level 7 full grid in x # and level 6 sparse grid in v. # quadratic basis --grid : adapt +-grid : sparse -start-levels : 5 4 4 4 --max_level : 5 --max_adapt_levels : 5 4 4 4 --thresh : 1e-8 +-max-levels : 5 4 4 4 +#-adapt : 1e-8 -degree : 2 # imex timestep @@ -24,10 +24,10 @@ # dt = 0.75*CFL # T = dt*250 = 0.05 -step-method : imex --dt : 1.308997e-2 --num-steps : 3820 +-dt : 1.308997e-3 +-num-steps : 38200 # solver -solver : gmres --inner_it : 25 --tol : 1e-10 \ No newline at end of file +-isolve-iter : 200 +-isolve-tol : 1e-10 diff --git a/infiles/riemann1x3vmg.txt b/infiles/riemann1x3vmg.txt index a70c19f3d..8141d4f24 100644 --- a/infiles/riemann1x3vmg.txt +++ b/infiles/riemann1x3vmg.txt @@ -9,10 +9,8 @@ # mixed grid with level 7 full grid in x # and level 6 sparse grid in v. # quadratic basis --grid : mixed --split : 1 +-grid : mixed 1 -start-levels : 6 6 6 6 --max_level : 6 -degree : 2 # imex timestep @@ -27,5 +25,5 @@ # solver -solver : gmres --inner_it : 50 --tol : 1e-8 \ No newline at end of file +-isolve-iter : 50 +-isolve-tol : 1e-8 diff --git a/infiles/twostream2dasg.txt b/infiles/twostream2dasg.txt index 7baef4363..10b294287 100644 --- a/infiles/twostream2dasg.txt +++ b/infiles/twostream2dasg.txt @@ -7,11 +7,11 @@ # disctretization in space # level 7 adaptive sparse grid and quadratic basis --grid : adapt +-grid : mixed 1 -start-levels : 7 --max_level : 7 +-max-levels : 7 -degree : 2 --thresh : 1.E-6 +-adapt : 1.E-6 # imex timestep # CFL = dx*(1/(2k+1))*(1/|v_max|) @@ -21,4 +21,4 @@ # T = dt*19200 = 45.0 -step-method : imex -dt : 2.34375E-3 --num-steps : 19200 \ No newline at end of file +-num-steps : 19200 diff --git a/python/asgard.py b/python/asgard.py index 239e0674b..d68810dc7 100644 --- a/python/asgard.py +++ b/python/asgard.py @@ -285,7 +285,7 @@ def __str__(self): else: plist = [(), ()] for i in range(2, shot.num_dimensions): - plit.append(0.49 * (shot.dimension_max[i] + shot.dimension_min[i])) + plist.append(0.49 * (shot.dimension_max[i] + shot.dimension_min[i])) z, x, y = shot.plot_data2d(plist, num_points = 256) diff --git a/src/asgard_program_options.cpp b/src/asgard_program_options.cpp index 0e6ebc38d..6f301071e 100644 --- a/src/asgard_program_options.cpp +++ b/src/asgard_program_options.cpp @@ -296,7 +296,7 @@ void prog_opts::process_inputs(std::vector const &argv, { auto s2 = move_process_next(); if (not s2) - throw std::runtime_error(report_no_value()); + throw std::runtime_error("missing mixed grid number"); try { grid = grid_type::mixed; mgrid_group = std::stoi(s2->data()); @@ -306,6 +306,18 @@ void prog_opts::process_inputs(std::vector const &argv, throw std::runtime_error(report_wrong_value()); } } + else if ((*selected).find("mixed") != std::string::npos) + { + auto pos = (*selected).rfind("mixed") + 5; // 5 == length of "mixed" + try { + grid = grid_type::mixed; + mgrid_group = std::stoi(std::string((*selected).substr(pos))); + } catch(std::invalid_argument &) { + throw std::runtime_error(report_wrong_value()); + } catch(std::out_of_range &) { + throw std::runtime_error(report_wrong_value()); + } + } else throw std::runtime_error(report_wrong_value()); } From d8f4c3033eef86ca123c6b9a2baef608da68ede3 Mon Sep 17 00:00:00 2001 From: Miroslav Stoyanov Date: Tue, 20 Aug 2024 20:01:27 -0400 Subject: [PATCH 2/2] fixed test --- src/asgard_program_options.cpp | 6 ++++-- src/asgard_program_options_tests.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/asgard_program_options.cpp b/src/asgard_program_options.cpp index 6f301071e..2a31b007a 100644 --- a/src/asgard_program_options.cpp +++ b/src/asgard_program_options.cpp @@ -296,7 +296,9 @@ void prog_opts::process_inputs(std::vector const &argv, { auto s2 = move_process_next(); if (not s2) - throw std::runtime_error("missing mixed grid number"); + throw std::runtime_error( + "missing mixed grid number, see " + std::string(argv.front()) + + " -help"); try { grid = grid_type::mixed; mgrid_group = std::stoi(s2->data()); @@ -306,7 +308,7 @@ void prog_opts::process_inputs(std::vector const &argv, throw std::runtime_error(report_wrong_value()); } } - else if ((*selected).find("mixed") != std::string::npos) + else if (selected->size() > 6 and (*selected).find("mixed") != std::string::npos) { auto pos = (*selected).rfind("mixed") + 5; // 5 == length of "mixed" try { diff --git a/src/asgard_program_options_tests.cpp b/src/asgard_program_options_tests.cpp index 11d6ad988..34cc4212c 100644 --- a/src/asgard_program_options_tests.cpp +++ b/src/asgard_program_options_tests.cpp @@ -74,7 +74,7 @@ TEST_CASE("new program options", "[single options]") REQUIRE_THROWS_WITH(prog_opts(vecstrview({"exe", "-g", "dummy"})), "invalid value for -g, see exe -help"); REQUIRE_THROWS_WITH(prog_opts(vecstrview({"exe", "-g", "mix"})), - "mix must be followed by a value, see exe -help"); + "missing mixed grid number, see exe -help"); prog_opts opts3(vecstrview({"exe", "-g", "sparse"})); REQUIRE_FALSE(opts3.mgrid_group); }