From 61df3404e9b2600454482e52a9008bb561568d4c Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Mon, 24 Jun 2024 12:43:17 -0400 Subject: [PATCH] more exact Riemann cleaning (#2875) remove co_moving_frame stuff also start removing runtime parameter from the solver itself --- Util/exact_riemann/_prob_params | 4 - .../ci-benchmarks/test1-riemann.out | 90 +++++++++---------- Util/exact_riemann/exact_riemann.H | 12 --- Util/exact_riemann/inputs.moving | 21 ----- Util/exact_riemann/main.cpp | 4 +- Util/exact_riemann/riemann_rarefaction.H | 3 - Util/exact_riemann/riemann_shock.H | 4 - Util/exact_riemann/riemann_star_state.H | 13 ++- 8 files changed, 51 insertions(+), 100 deletions(-) delete mode 100644 Util/exact_riemann/inputs.moving diff --git a/Util/exact_riemann/_prob_params b/Util/exact_riemann/_prob_params index 6d9a75185b..9c43f0d3b5 100644 --- a/Util/exact_riemann/_prob_params +++ b/Util/exact_riemann/_prob_params @@ -21,7 +21,3 @@ npts integer 128 y use_Tinit integer 0 y initial_temp_guess real 1.0d5 y - -riemann_max_iter integer 10 y - -co_moving_frame integer 0 y diff --git a/Util/exact_riemann/ci-benchmarks/test1-riemann.out b/Util/exact_riemann/ci-benchmarks/test1-riemann.out index 4c6ec142cf..1624fcf02c 100644 --- a/Util/exact_riemann/ci-benchmarks/test1-riemann.out +++ b/Util/exact_riemann/ci-benchmarks/test1-riemann.out @@ -68,51 +68,51 @@ 67 519531.25 3782769.06389 306131662.364 1.99799647911e+23 58852893.6708 9.19281449819e+16 1.50260347548 68 527343.75 3677627.42215 314046760.692 1.9150955856e+23 57947741.148 9.04497857546e+16 1.5041134824 69 535156.25 3573422.36381 322064216.687 1.83402150589e+23 57038358.4286 8.89637619826e+16 1.50565406349 - 70 542968.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 71 550781.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 72 558593.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 73 566406.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 74 574218.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 75 582031.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 76 589843.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 77 597656.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 78 605468.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 79 613281.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 80 621093.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 81 628906.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 82 636718.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 83 644531.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 84 652343.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 85 660156.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 86 667968.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 87 675781.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 88 683593.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 89 691406.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 90 699218.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 91 707031.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 92 714843.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 93 722656.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 94 730468.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 95 738281.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 96 746093.75 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 97 753906.25 3566771.3761 322581533.648 1.82889264617e+23 57003324.3672 8.8868625651e+16 1.50575410561 - 98 761718.75 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 99 769531.25 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 100 777343.75 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 101 785156.25 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 102 792968.75 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 103 800781.25 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 104 808593.75 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 105 816406.25 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 106 824218.75 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 107 832031.25 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 108 839843.75 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 109 847656.25 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 110 855468.75 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 111 863281.25 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 112 871093.75 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 113 878906.25 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 - 114 886718.75 2952884.63461 322581533.648 1.82889264617e+23 758658820.738 1.09750124478e+17 1.49554976549 + 70 542968.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 71 550781.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 72 558593.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 73 566406.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 74 574218.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 75 582031.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 76 589843.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 77 597656.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 78 605468.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 79 613281.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 80 621093.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 81 628906.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 82 636718.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 83 644531.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 84 652343.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 85 660156.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 86 667968.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 87 675781.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 88 683593.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 89 691406.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 90 699218.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 91 707031.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 92 714843.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 93 722656.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 94 730468.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 95 738281.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 96 746093.75 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 97 753906.25 3566771.39183 322581533.75 1.82889264698e+23 57003293.328 8.88686252995e+16 1.50575410519 + 98 761718.75 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 99 769531.25 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 100 777343.75 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 101 785156.25 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 102 792968.75 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 103 800781.25 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 104 808593.75 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 105 816406.25 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 106 824218.75 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 107 832031.25 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 108 839843.75 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 109 847656.25 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 110 855468.75 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 111 863281.25 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 112 871093.75 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 113 878906.25 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 + 114 886718.75 2952884.63392 322581533.75 1.82889264698e+23 758658822.183 1.09750124564e+17 1.49554976542 115 894531.25 1000000 0 2.55457320691e+22 999999.999997 4.08260803009e+16 1.57201404928 116 902343.75 1000000 0 2.55457320691e+22 999999.999997 4.08260803009e+16 1.57201404928 117 910156.25 1000000 0 2.55457320691e+22 999999.999997 4.08260803009e+16 1.57201404928 diff --git a/Util/exact_riemann/exact_riemann.H b/Util/exact_riemann/exact_riemann.H index d7e7c4831b..39deafe8d4 100644 --- a/Util/exact_riemann/exact_riemann.H +++ b/Util/exact_riemann/exact_riemann.H @@ -47,12 +47,6 @@ exact_riemann() { } - if (problem::co_moving_frame) { - amrex::Real W_avg = 0.5_rt * (problem::u_l + problem::u_r); - problem::u_l -= W_avg; - problem::u_r -= W_avg; - } - amrex::Real ustar, pstar, W_l, W_r; riemann_star_state(problem::rho_l, problem::u_l, problem::p_l, xn, @@ -86,12 +80,6 @@ exact_riemann() { x, problem::xjump, problem::t, rho, u, p, xn_s); - if (problem::co_moving_frame) { - amrex::Real W_avg = 0.5_rt * (problem::u_l + problem::u_r); - u += W_avg; - x += problem::t * W_avg; - } - // get the thermodynamics for this state for output eos_t eos_state; diff --git a/Util/exact_riemann/inputs.moving b/Util/exact_riemann/inputs.moving deleted file mode 100644 index 16d6a1adc2..0000000000 --- a/Util/exact_riemann/inputs.moving +++ /dev/null @@ -1,21 +0,0 @@ -problem.rho_l = 1.0e7 -problem.u_l = 5.e7 -problem.p_l = 8.4e23 -problem.T_l = 1.e8 - -problem.rho_r = 1.0e6 -problem.u_r = 1.0e7 -problem.p_r = 2.55e22 -problem.T_r = 1.e6 - -problem.use_Tinit = 1 - -problem.xmin = 0.0e0 -problem.xmax = 1.0e6 -problem.xjump = 0.5e6 - -problem.t = 0.0008 -problem.npts = 128 - -problem.co_moving_frame = 1 - diff --git a/Util/exact_riemann/main.cpp b/Util/exact_riemann/main.cpp index e91b337308..c2b3ed296d 100644 --- a/Util/exact_riemann/main.cpp +++ b/Util/exact_riemann/main.cpp @@ -10,7 +10,7 @@ #include #include #include -#include + #include int main(int argc, char *argv[]) { @@ -18,8 +18,6 @@ int main(int argc, char *argv[]) { amrex::Initialize(argc, argv); std::cout << "starting the exact Riemann solver..." << std::endl; - std::cout << argv[1] << std::endl; - std::cout << strlen(argv[1]) << std::endl; // initialize the external runtime parameters in C++ diff --git a/Util/exact_riemann/riemann_rarefaction.H b/Util/exact_riemann/riemann_rarefaction.H index 9592225fa0..c5d98c6f87 100644 --- a/Util/exact_riemann/riemann_rarefaction.H +++ b/Util/exact_riemann/riemann_rarefaction.H @@ -68,7 +68,6 @@ riemann_invariant_rhs2(const amrex::Real u, const amrex::Real tau, const amrex:: amrex::ignore_unused(u); - std::cout << "in riemann_invariant_rhs2: " << u << " " << tau << " " << p << std::endl; eos_rep_t eos_state; eos_state.rho = 1.0_rt / tau; eos_state.p = p; @@ -326,8 +325,6 @@ rarefaction_to_u(const amrex::Real rho_s, const amrex::Real u_s, const amrex::Re bool finished = false; - std::cout << "integrating from u: " << u << " " << ustop << " " << xi << " " << c << std::endl; - // this will be used as an initial guess to accelerate the EOS inversions amrex::Real T = eos_state.T; diff --git a/Util/exact_riemann/riemann_shock.H b/Util/exact_riemann/riemann_shock.H index 93fc4c17ac..c91ac466de 100644 --- a/Util/exact_riemann/riemann_shock.H +++ b/Util/exact_riemann/riemann_shock.H @@ -129,10 +129,6 @@ shock(const amrex::Real pstar, 2.0_rt * (1.0_rt - gammaE_bar / gammaC_bar) * (gammaE_bar - 1.0_rt) * (pstar - p_s) / (pstar + p_s); - std::cout << "pstar, ps = " << pstar << " " << p_s << " " << gammaE_s << " " << gammaE_star << std::endl; - std::cout << (pstar/rho_s - (gammaE_star - 1.0_rt)/(gammaE_s - 1.0_rt) * p_s/rho_s); - std::cout << (pstar + 0.5_rt * (gammaE_star - 1.0_rt) * (pstar + p_s)); - // there is a pathological case that if p_s - pstar ~ 0, the root finding // just doesn't work. In this case, we use the ideas from CG, Eq. 35, and // take W = sqrt(gamma p rho) diff --git a/Util/exact_riemann/riemann_star_state.H b/Util/exact_riemann/riemann_star_state.H index 47d1ee4781..67eeabada7 100644 --- a/Util/exact_riemann/riemann_star_state.H +++ b/Util/exact_riemann/riemann_star_state.H @@ -80,9 +80,6 @@ riemann_star_state(const amrex::Real rho_l, const amrex::Real u_l, const amrex:: // find the exact pstar and ustar std::cout << "solving for star state: " << std::endl; - std::cout << rho_l << " " << u_l << " " << p_l << std::endl; - std::cout << rho_r << " " << u_r << " " << p_r << std::endl; - // this procedure follows directly from Colella & Glaz 1985, section 1 // the basic idea is that we want to find the pstar that satisfies: @@ -111,14 +108,13 @@ riemann_star_state(const amrex::Real rho_l, const amrex::Real u_l, const amrex:: bool converged = false; int iter = 1; - while (! converged && iter < problem::riemann_max_iter) { + while (! converged && iter < riemann_solver::max_iters) { // compute Z_l, W_l and Z_r, W_r -- the form of these depend // on whether the wave is a shock or a rarefaction amrex::Real Z_l, Z_r; - std::cout << "iteration: " << iter << " " << pstar << " " << p_l << " " << p_r << std::endl; // left wave if (pstar - p_l > SMALL * p_l) { @@ -146,9 +142,6 @@ riemann_star_state(const amrex::Real rho_l, const amrex::Real u_l, const amrex:: amrex::Real pstar_new = pstar - Z_l * Z_r * (ustar_r - ustar_l) / (Z_l + Z_r); - std::cout << "done with iteration " << iter << std::endl; - std::cout << "ustar_l/r, pstar: " << ustar_l << " " << ustar_r << " " << pstar_new << std::endl; - // estimate the error in the current star solution amrex::Real err1 = std::abs(ustar_r - ustar_l); amrex::Real err2 = pstar_new - pstar; @@ -164,6 +157,10 @@ riemann_star_state(const amrex::Real rho_l, const amrex::Real u_l, const amrex:: iter++; } + if (! converged) { + amrex::Error("star state did not converge"); + } + ustar = 0.5_rt * (ustar_l + ustar_r); std::cout << "found pstar, ustar: " << pstar << " " << ustar << std::endl;