Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Hook the exact Riemann solver into Castro #2908

Open
wants to merge 52 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
fe81e5d
fix some namespace issues + add missing headers to runtime_parameters.H
zingale Jun 26, 2024
000768f
more work on getting castro params into exact Riemann
zingale Jun 27, 2024
d01fa53
this seems to work
zingale Jun 27, 2024
94d35b2
Merge branch 'development' into exact_riemann_castro_params
zingale Jun 27, 2024
a4a16d3
this works now
zingale Jun 27, 2024
b0b48bb
add missing file
zingale Jun 27, 2024
c08294d
Merge branch 'development' into exact_riemann_castro_params
zingale Jun 27, 2024
afcb2dc
Merge branch 'development' into exact_riemann_castro_params
zingale Jun 27, 2024
8b81044
unused header
zingale Jun 27, 2024
a3c59f6
Merge branch 'exact_riemann_castro_params' of github.com:zingale/Cast…
zingale Jun 27, 2024
372229c
rename some Riemann runtime parameters
zingale Jun 27, 2024
1f3a733
fix runtime params
zingale Jun 27, 2024
07307ec
Merge branch 'rename_riemann_runtime' into next_exact_riemann
zingale Jul 1, 2024
f6363f2
work on using Source/hydro riemann parameters
zingale Jul 1, 2024
03b9653
move some Riemann history constexpr to riemann_constants namespace
zingale Jul 1, 2024
ad30404
Merge branch 'move_history_params_to_riemann' into next_exact_riemann
zingale Jul 1, 2024
9e7e820
split constants into riemann_constants.H
zingale Jul 1, 2024
0d51f94
Merge branch 'development' into exact_riemann_castro_params
zingale Jul 1, 2024
a3f5802
Merge branch 'exact_riemann_castro_params' into move_history_params_t…
zingale Jul 1, 2024
a932e27
Merge branch 'move_history_params_to_riemann' into next_exact_riemann
zingale Jul 1, 2024
9b1cf4d
remove unneeded header
zingale Jul 1, 2024
0a6ce88
more work on getting the Riemann solver to fully use Castro stuff
zingale Jul 1, 2024
17431ba
for pstar convergence in exact_riemann use std::abs()
zingale Jul 1, 2024
65a818c
remove the ustar test
zingale Jul 1, 2024
d3f70a6
Merge branch 'development' into move_history_params_to_riemann
zingale Jul 8, 2024
4a134a9
Merge branch 'development' into next_exact_riemann
zingale Jul 8, 2024
6aa51c3
Merge branch 'development' into finish_riemann_cleaning
zingale Jul 8, 2024
bbcd4d8
Merge branch 'development' into fix_exact_riemann_pstar_test
zingale Jul 8, 2024
22a9572
fix header guard
zingale Jul 8, 2024
a204219
Merge branch 'next_exact_riemann' into finish_riemann_cleaning
zingale Jul 8, 2024
75a7724
Merge branch 'development' into move_history_params_to_riemann
zingale Jul 9, 2024
166c276
Merge branch 'move_history_params_to_riemann' into finish_riemann_cle…
zingale Jul 9, 2024
06a8d20
Merge branch 'move_history_params_to_riemann' into next_exact_riemann
zingale Jul 9, 2024
cfc0071
Merge branch 'next_exact_riemann' into finish_riemann_cleaning
zingale Jul 9, 2024
2ad23f4
Merge branch 'development' into next_exact_riemann
zingale Jul 9, 2024
2f458f6
Merge branch 'next_exact_riemann' into finish_riemann_cleaning
zingale Jul 9, 2024
51f2c9f
Merge branch 'development' into fix_exact_riemann_pstar_test
zingale Jul 9, 2024
f5b4dfe
Merge branch 'fix_exact_riemann_pstar_test' into finish_riemann_cleaning
zingale Jul 9, 2024
3fb9b51
more cleaning
zingale Jul 9, 2024
51313d2
finish
zingale Jul 9, 2024
2a1a272
rename
zingale Jul 10, 2024
6bfab82
some moving
zingale Jul 10, 2024
e05bc5c
add heading
zingale Jul 10, 2024
7300498
Merge branch 'development' into finish_riemann_cleaning
zingale Jul 10, 2024
19b2713
Merge branch 'finish_riemann_cleaning' into exact_riemann_merge
zingale Jul 10, 2024
b2b9592
add enum
zingale Jul 10, 2024
72ace4c
Merge branch 'development' into exact_riemann_merge
zingale Jul 10, 2024
e872e29
a bit more work
zingale Jul 10, 2024
0fa676c
more implementation
zingale Jul 10, 2024
d060b06
fix compiler warning
zingale Jul 10, 2024
6f6083b
Merge branch 'development' into exact_riemann_merge
zingale Jul 27, 2024
f940f16
Merge branch 'development' into exact_riemann_merge
zingale Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ riemann_sample(const amrex::Real rho_l, const amrex::Real u_l, const amrex::Real
const amrex::Real rho_r, const amrex::Real u_r, const amrex::Real p_r, const amrex::Real* xn_r,
const amrex::Real ustar, const amrex::Real pstar,
const amrex::Real W_l, const amrex::Real W_r,
const amrex::Real x, const amrex::Real xjump, const amrex::Real time,
const amrex::Real xi,
amrex::Real& rho, amrex::Real& u, amrex::Real& p, amrex::Real* xn) {

// get the initial sound speeds
Expand Down Expand Up @@ -47,11 +47,6 @@ riemann_sample(const amrex::Real rho_l, const amrex::Real u_l, const amrex::Real

// This follows from the discussion around C&G Eq. 15

// compute xi = x/t -- this is the similarity variable for the
// solution

amrex::Real xi = (x - xjump) / time;

// check which side of the contact we need to worry about

amrex::Real chi = std::copysign(1.0_rt, xi - ustar);
Expand Down
6 changes: 4 additions & 2 deletions Source/hydro/riemann.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ Castro::cmpflx_plus_godunov(const Box& bx,
{


if (riemann_solver == 0 || riemann_solver == 1) {
if (riemann_solver == riemann_constants::TWO_SHOCK_CGF ||
riemann_solver == riemann_constants::TWO_SHOCK_CG ||
riemann_solver == riemann_constants::EXACT) {
// approximate state Riemann solvers

// first find the interface state on the current interface
Expand Down Expand Up @@ -120,7 +122,7 @@ Castro::cmpflx_plus_godunov(const Box& bx,
}
}

} else if (riemann_solver == 2) {
} else if (riemann_solver == riemann_constants::HLLC) {
// HLLC
HLL::HLLC(i, j, k, idir,
qm, qp,
Expand Down
8 changes: 8 additions & 0 deletions Source/hydro/riemann_constants.H
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
using namespace amrex::literals;

namespace riemann_constants {

enum RiemannSolver : std::uint8_t {
TWO_SHOCK_CGF=0,
TWO_SHOCK_CG,
HLLC,
EXACT
};

constexpr amrex::Real smlp1 = 1.e-10_rt;
constexpr amrex::Real small = 1.e-8_rt;
constexpr amrex::Real smallu = 1.e-12_rt;
Expand Down
75 changes: 73 additions & 2 deletions Source/hydro/riemann_solvers.H
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <Castro_util.H>
#include <riemann_type.H>
#include <riemann_2shock_solvers.H>
#include <exact_riemann_star_state.H>
#include <exact_riemann_sample.H>
#ifdef HYBRID_MOMENTUM
#include <hybrid.H>
#endif
Expand Down Expand Up @@ -318,18 +320,87 @@ riemann_state(const int i, const int j, const int k, const int idir,


// Solve Riemann problem
if (riemann_solver == 0) {
if (riemann_solver == riemann_constants::TWO_SHOCK_CGF) {
// Colella, Glaz, & Ferguson solver

TwoShock::riemannus(ql, qr, raux, qint);

} else if (riemann_solver == 1) {
} else if (riemann_solver == riemann_constants::TWO_SHOCK_CG) {
// Colella & Glaz solver

#ifndef RADIATION
TwoShock::riemanncg(ql, qr, raux, qint);
#endif

} else if (riemann_solver == riemann_constants::EXACT) {
// Exact Riemann solver

// solve for the star state

amrex::Real ustar{};
amrex::Real pstar{};
amrex::Real W_l{};
amrex::Real W_r{};

amrex::Real xn_l[NumSpec];
for (int n = 0; n < NumSpec; ++n) {
xn_l[n] = qm(i,j,k,QFS+n);
}
amrex::Real xn_r[NumSpec];
for (int n = 0; n < NumSpec; ++n) {
xn_r[n] = qp(i,j,k,QFS+n);
}

riemann_star_state(ql.rho, ql.un, ql.p, xn_l,
qr.rho, qr.un, qr.p, xn_r,
ustar, pstar, W_l, W_r);

// sample the solution at xi = 0

amrex::Real xi{};

amrex::Real rho{};
amrex::Real u{};
amrex::Real p{};
amrex::Real xn_s[NumSpec]{};

riemann_sample(ql.rho, ql.un, ql.p, xn_l,
qr.rho, qr.un, qr.p, xn_r,
ustar, pstar, W_l, W_r,
xi,
rho, u, p, xn_s);

// pack the RiemannState interface state

qint.rho = rho;
qint.un = u;
qint.p = p;

// get the energy
eos_rep_t eos_state;
eos_state.rho = qint.rho;
eos_state.T = castro::T_guess;
eos_state.p = qint.p;
for (int n = 0; n < NumSpec; ++n) {
eos_state.xn[n] = xn_s[n];
}

eos(eos_input_rp, eos_state);

qint.rhoe = qint.rho * eos_state.e;
qint.gamc = eos_state.gam1;

// we need to manually do the transverse sampling based on the
// contact

if (ustar > 0) {
qint.ut = ql.ut;
qint.utt = ql.utt;
} else {
qint.ut = qr.ut;
qint.utt = qr.utt;
}

#ifndef AMREX_USE_GPU
} else {
amrex::Error("ERROR: invalid value of riemann_solver");
Expand Down
15 changes: 9 additions & 6 deletions Util/exact_riemann/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
This is an exact Riemann solver for a general equation of state. It
follows the outline for Colella & Glaz 1985, section 1. This is too
slow to use in an actual hydro run, but instead is intended to
generate exact solutions to the Riemann problem for comparison with
Castro shocktube output. Several inputs files for Helmholtz EOS-based
shocktubes are provided.
# Exact Riemann solver

This is a driver for the exact Riemann solver for a general equation
of state. The main implementation is in Source/hydro.

The exact Riemann solver follows the outline for Colella & Glaz 1985,
section 1 and this driver is intended to generate exact solutions to
the Riemann problem for comparison with Castro shocktube output.
Several inputs files for Helmholtz EOS-based shocktubes are provided.

This solver is used in Zingale & Katz (2015):

Expand Down
7 changes: 6 additions & 1 deletion Util/exact_riemann/exact_riemann.H
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,15 @@ exact_riemann() {

amrex::Real rho, u, p, xn_s[NumSpec];

// compute xi = x/t -- this is the similarity variable for the
// solution

amrex::Real xi = (x - problem::xjump) / problem::t;

riemann_sample(problem::rho_l, problem::u_l, problem::p_l, xn,
problem::rho_r, problem::u_r, problem::p_r, xn,
ustar, pstar, W_l, W_r,
x, problem::xjump, problem::t,
xi,
rho, u, p, xn_s);

// get the thermodynamics for this state for output
Expand Down
Loading