Alamo
HLLE.H
Go to the documentation of this file.
1#ifndef SOLVER_LOCAL_RIEMANN_HLLE_H
2#define SOLVER_LOCAL_RIEMANN_HLLE_H
3
4#include "IO/ParmParse.H"
6
7/// A bunch of solvers
8namespace Solver
9{
10/// Local solvers
11namespace Local
12{
13
14namespace Riemann
15{
16
17class HLLE : public Riemann
18{
19public:
20
21
22 static constexpr const char* name = "hlle";
23 HLLE (IO::ParmParse &pp, std::string name)
24 {pp_queryclass(name,*this);}
26 {pp_queryclass(*this);}
27 HLLE ()
28 {
30 pp_queryclass(*this);
31 }
32
33 int lowmach = 0;
35
36 static void Parse(HLLE & value, IO::ParmParse & pp)
37 {
38 // toggle to apply a low mach correction approximation
39 pp.query_default("lowmach",value.lowmach,false);
40 // cutoff value if using the low mach approximation
41 pp.query_default("cutoff",value.cutoff,0.1);
42 }
43
44 virtual Flux Solve(State lo, State hi, Model::Gas::Gas& gas, Set::Patch<const Set::Scalar>& X, int i, int j, int k, int side, Set::Scalar small) override
45 {
46 // Grab and label the input states
47 Set::Scalar rho_L = lo.rho , rho_R = hi.rho;
48 Set::Scalar Mn_L = lo.M_normal , Mn_R = hi.M_normal ;
49 //Set::Scalar Mt_L = lo.M_tangent , Mt_R = hi.M_tangent ;
50 Set::Scalar E_L = lo.E , E_R = hi.E ;
51
52 // Ensure no negative densities
53 rho_L = std::max(small,rho_L);
54 rho_R = std::max(small,rho_R);
55
56
57 // Calculate primitives
58 Set::Scalar u_L = Mn_L/(rho_L+small), u_R = Mn_R/(rho_R+small);
59 Set::Scalar v_L = Mn_L/(rho_L+small), v_R = Mn_R/(rho_R+small);
60
61 Set::Scalar T_L=0, T_R=0, p_L=0, p_R=0, gamma_L=0, gamma_R=0;
62 switch (side) {
63 case 0: // xlo
64 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i-1, j ,k);
65 p_L = gas.ComputeP(rho_L, T_L, X, i-1, j, k);
66 gamma_L = gas.gamma(T_L, X, i-1, j, k);
67 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i, j ,k);
68 p_R = gas.ComputeP(rho_R, T_R, X, i, j, k);
69 gamma_R = gas.gamma(T_R, X, i, j, k);
70 break;
71 case 1: // xhi
72 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i, j ,k);
73 p_L = gas.ComputeP(rho_L, T_L, X, i, j, k);
74 gamma_L = gas.gamma(T_L, X, i, j, k);
75 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i+1, j ,k);
76 p_R = gas.ComputeP(rho_R, T_R, X, i+1, j, k);
77 gamma_R = gas.gamma(T_R, X, i+1, j, k);
78 break;
79 case 2: // ylo
80 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i, j-1 ,k);
81 p_L = gas.ComputeP(rho_L, T_L, X, i, j-1, k);
82 gamma_L = gas.gamma(T_L, X, i, j-1, k);
83 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i, j ,k);
84 p_R = gas.ComputeP(rho_R, T_R, X, i, j, k);
85 gamma_R = gas.gamma(T_R, X, i, j, k);
86 break;
87 case 3: // yhi
88 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i, j ,k);
89 p_L = gas.ComputeP(rho_L, T_L, X, i, j, k);
90 gamma_L = gas.gamma(T_L, X, i, j, k);
91 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i, j+1 ,k);
92 p_R = gas.ComputeP(rho_R, T_R, X, i, j+1, k);
93 gamma_R = gas.gamma(T_R, X, i, j+1, k);
94 break;
95 case 4: // zlo
96 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i, j ,k-1);
97 p_L = gas.ComputeP(rho_L, T_L, X, i, j, k-1);
98 gamma_L = gas.gamma(T_L, X, i, j, k-1);
99 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i, j ,k);
100 p_R = gas.ComputeP(rho_R, T_R, X, i, j, k);
101 gamma_R = gas.gamma(T_R, X, i, j, k);
102 break;
103 case 5: // zhi
104 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i, j ,k);
105 p_L = gas.ComputeP(rho_L, T_L, X, i, j, k);
106 gamma_L = gas.gamma(T_L, X, i, j, k);
107 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i, j ,k+1);
108 p_R = gas.ComputeP(rho_R, T_R, X, i, j, k+1);
109 gamma_R = gas.gamma(T_R, X, i, j, k+1);
110 break;
111 default:
112 Util::Abort(INFO, "Unknown side in Riemann solver, ",side);
113 }
114
115 Set::Scalar c_L = std::sqrt(gamma_L * p_L / (rho_L + small));
116 Set::Scalar c_R = std::sqrt(gamma_R * p_R / (rho_R + small));
117
118 // Max wave speeds
119 Set::Scalar S_L = std::min(u_L-c_L, u_R - c_R);
120 Set::Scalar S_R = std::max(u_L+c_L, u_R + c_R);
121
122
123 if (lowmach)
124 {
125 Set::Scalar u_RL = 0.5 * (u_L + u_R);
126 Set::Scalar a_RL = 0.5 * (c_L + c_R);
127 Set::Scalar Mach = std::abs(u_RL) / (a_RL + small);
128 Set::Scalar psi = std::max(Mach, cutoff); // Mach cutoff
129 S_L *= psi;
130 S_R *= psi;
131 }
132
133 Flux F_L (
134 lo.M_normal,
135 lo.M_normal * u_L + p_L,
136 lo.M_tangent * u_L,
137 u_L * (lo.E + p_L)
138 );
139 Flux F_R (
140 hi.M_normal,
141 hi.M_normal * u_R + p_R,
142 hi.M_tangent * u_R,
143 u_R * (hi.E + p_R)
144 );
145
146 if (S_L >= 0.0)
147 {
148 return F_L;
149 }
150 else if (S_R <= 0.0)
151 {
152 return F_R;
153 }
154 else
155 {
156 State dState = hi - lo;
157 Set::Scalar dS = S_R - S_L;
158 return (S_R*F_L - S_L*F_R + S_L*S_R*Flux(dState)) / dS;
159 }
160 }
161};
162}
163}
164}
165
166#endif
#define X(name)
#define pp_queryclass(...)
Definition ParmParse.H:109
#define INFO
Definition Util.H:24
int query_default(std::string name, T &value, T defaultvalue)
Definition ParmParse.H:293
double ComputeP(double density, double T, Set::Patch< const Set::Scalar > &X, int i, int j, int k) const
Definition Gas.cpp:66
double ComputeT(double density, double momentumx, double momentumy, double E, double Tguess, Set::Patch< const Set::Scalar > &X, int i, int j, int k, double rtol=1e-12) const
Definition Gas.cpp:52
double gamma(double T, Set::Patch< const Set::Scalar > &X, int i, int j, int k) const
Definition Gas.H:129
static constexpr const char * name
Definition HLLE.H:22
static void Parse(HLLE &value, IO::ParmParse &pp)
Definition HLLE.H:36
HLLE(IO::ParmParse &pp, std::string name)
Definition HLLE.H:23
HLLE(IO::ParmParse &pp)
Definition HLLE.H:25
virtual Flux Solve(State lo, State hi, Model::Gas::Gas &gas, Set::Patch< const Set::Scalar > &X, int i, int j, int k, int side, Set::Scalar small) override
Definition HLLE.H:44
amrex::Real Scalar
Definition Base.H:18
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:19
A bunch of solvers.
Definition CG.H:6
void Abort(const char *msg)
Definition Util.cpp:268