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
60 Set::Scalar T_L=0, T_R=0, p_L=0, p_R=0, gamma_L=0, gamma_R=0;
61 switch (side) {
62 case 0: // xlo
63 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i-1, j ,k);
64 p_L = gas.ComputeP(rho_L, T_L, X, i-1, j, k);
65 gamma_L = gas.gamma(T_L, X, i-1, j, k);
66 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i, j ,k);
67 p_R = gas.ComputeP(rho_R, T_R, X, i, j, k);
68 gamma_R = gas.gamma(T_R, X, i, j, k);
69 break;
70 case 1: // xhi
71 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i, j ,k);
72 p_L = gas.ComputeP(rho_L, T_L, X, i, j, k);
73 gamma_L = gas.gamma(T_L, X, i, j, k);
74 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i+1, j ,k);
75 p_R = gas.ComputeP(rho_R, T_R, X, i+1, j, k);
76 gamma_R = gas.gamma(T_R, X, i+1, j, k);
77 break;
78 case 2: // ylo
79 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i, j-1 ,k);
80 p_L = gas.ComputeP(rho_L, T_L, X, i, j-1, k);
81 gamma_L = gas.gamma(T_L, X, i, j-1, k);
82 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i, j ,k);
83 p_R = gas.ComputeP(rho_R, T_R, X, i, j, k);
84 gamma_R = gas.gamma(T_R, X, i, j, k);
85 break;
86 case 3: // yhi
87 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i, j ,k);
88 p_L = gas.ComputeP(rho_L, T_L, X, i, j, k);
89 gamma_L = gas.gamma(T_L, X, i, j, k);
90 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i, j+1 ,k);
91 p_R = gas.ComputeP(rho_R, T_R, X, i, j+1, k);
92 gamma_R = gas.gamma(T_R, X, i, j+1, k);
93 break;
94 case 4: // zlo
95 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i, j ,k-1);
96 p_L = gas.ComputeP(rho_L, T_L, X, i, j, k-1);
97 gamma_L = gas.gamma(T_L, X, i, j, k-1);
98 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i, j ,k);
99 p_R = gas.ComputeP(rho_R, T_R, X, i, j, k);
100 gamma_R = gas.gamma(T_R, X, i, j, k);
101 break;
102 case 5: // zhi
103 T_L = gas.ComputeT(rho_L, lo.M_normal, lo.M_tangent, E_L, 500.0, X, i, j ,k);
104 p_L = gas.ComputeP(rho_L, T_L, X, i, j, k);
105 gamma_L = gas.gamma(T_L, X, i, j, k);
106 T_R = gas.ComputeT(rho_R, hi.M_normal, hi.M_tangent, E_R, 500.0, X, i, j ,k+1);
107 p_R = gas.ComputeP(rho_R, T_R, X, i, j, k+1);
108 gamma_R = gas.gamma(T_R, X, i, j, k+1);
109 break;
110 default:
111 Util::Abort(INFO, "Unknown side in Riemann solver, ",side);
112 }
113
114 Set::Scalar c_L = std::sqrt(gamma_L * p_L / (rho_L + small));
115 Set::Scalar c_R = std::sqrt(gamma_R * p_R / (rho_R + small));
116
117 // Max wave speeds
118 Set::Scalar S_L = std::min(u_L-c_L, u_R - c_R);
119 Set::Scalar S_R = std::max(u_L+c_L, u_R + c_R);
120
121
122 if (lowmach)
123 {
124 Set::Scalar u_RL = 0.5 * (u_L + u_R);
125 Set::Scalar a_RL = 0.5 * (c_L + c_R);
126 Set::Scalar Mach = std::abs(u_RL) / (a_RL + small);
127 Set::Scalar psi = std::max(Mach, cutoff); // Mach cutoff
128 S_L *= psi;
129 S_R *= psi;
130 }
131
132 Flux F_L (
133 lo.M_normal,
134 lo.M_normal * u_L + p_L,
135 lo.M_tangent * u_L,
136 u_L * (lo.E + p_L)
137 );
138 Flux F_R (
139 hi.M_normal,
140 hi.M_normal * u_R + p_R,
141 hi.M_tangent * u_R,
142 u_R * (hi.E + p_R)
143 );
144
145 if (S_L >= 0.0)
146 {
147 return F_L;
148 }
149 else if (S_R <= 0.0)
150 {
151 return F_R;
152 }
153 else
154 {
155 State dState = hi - lo;
156 Set::Scalar dS = S_R - S_L;
157 return (S_R*F_L - S_L*F_R + S_L*S_R*Flux(dState)) / dS;
158 }
159 }
160};
161}
162}
163}
164
165#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