3 #include "../../misc/universal_error.hpp" 4 #include "../../misc/utils.hpp" 19 Conserved Ull = (sr*Ur - sl * Ul + Fl - Fr) / (sr - sl);
27 WaveSpeeds(
double left_i,
29 double right_i,
double ps_i) :
32 right(right_i),ps(ps_i) {}
34 WaveSpeeds(WaveSpeeds
const& other):left(other.left),center(other.center),
35 right(other.right),ps(other.ps){}
37 WaveSpeeds& operator=(WaveSpeeds
const& ws)
55 WaveSpeeds estimate_wave_speeds(
Primitive const& left,
Primitive const& right,
double pstar)
61 const double dr = right.
Density;
65 const double sl = vl - cl * (pstar > pl ? std::sqrt(0.8*(pstar / pl - 1) + 1) : 1);
66 const double sr = vr + cr * (pstar > pr ? std::sqrt(0.8*(pstar / pr - 1) + 1) : 1);
67 const double denom = 1.0 /(dl*(sl - vl) - dr * (sr - vr));
68 const double ss = (pr - pl + dl * vl*(sl - vl) - dr * vr*(sr - vr)) *denom;
69 const double ps =
std::max(0.0,dl * (sl - vl)*(pr - dr * (vr - vl)*(sr - vr)) *denom - pl * dr*(sr - vr) *denom);
70 return WaveSpeeds(sl, ss, sr,ps);
79 double left_wave_speed,
80 double center_wave_speed,
81 double right_wave_speed)
84 res.AddEntry(
"left density", left.
Density);
85 res.AddEntry(
"left pressure", left.
Pressure);
86 res.AddEntry(
"left x velocity", left.
Velocity.
x);
87 res.AddEntry(
"left y velocity", left.
Velocity.
y);
88 res.AddEntry(
"left sound speed", left.
SoundSpeed);
89 res.AddEntry(
"left energy", left.
Energy);
90 res.AddEntry(
"right density", right.
Density);
91 res.AddEntry(
"right pressure", right.
Pressure);
92 res.AddEntry(
"right x velocity", right.
Velocity.
x);
93 res.AddEntry(
"right y velocity", right.
Velocity.
y);
94 res.AddEntry(
"right sound speed", right.
SoundSpeed);
95 res.AddEntry(
"right energy", right.
Energy);
96 res.AddEntry(
"interface velocity", velocity);
97 res.AddEntry(
"left wave speed", left_wave_speed);
98 res.AddEntry(
"center wave speed", center_wave_speed);
99 res.AddEntry(
"right wave speed", right_wave_speed);
107 (
Primitive const& state,
double sk,
double ss)
109 const double dk = state.
Density;
113 const double ds = dk*(sk - uk) / (sk - ss);
120 ds*(ss - uk)*(ss + pk / dk / (sk - uk));
131 double velocity)
const 133 if (
is_nan(right.Velocity.x))
140 local_left.
Velocity -= velocity*normaldir;
141 local_right.
Velocity -= velocity*normaldir;
144 std::pair<double, double> p_u_star = HLLpu(local_left, local_right, eos_);
145 double old_ps = p_u_star.first;
149 WaveSpeeds ws = estimate_wave_speeds(local_left, local_right, old_ps);
153 while (ws.ps > 1.01 * old_ps || old_ps > 1.01 * ws.ps)
156 ws = estimate_wave_speeds(local_left, local_right, ws.ps);
160 std::cout <<
"Too many iterations in HLLC" << std::endl;
161 std::cout <<
"Normal " << normaldir.x <<
"," << normaldir.y <<
" velocity = " << velocity << std::endl;
162 std::cout <<
" Left density = " << left.
Density <<
" pressure = " << left.
Pressure <<
" internal_energy = " << left.
Energy <<
" vx = " << left.
Velocity.
x <<
163 " vy = " << left.
Velocity.
y << std::endl;
164 std::cout <<
" Right density = " << right.Density <<
" pressure = " << right.Pressure <<
" internal_energy = " << right.Energy <<
" vx = " << right.Velocity.x <<
165 " vy = " << right.Velocity.y << std::endl;
166 std::cout <<
"Old Pstar = " << old_ps <<
" new Pstar = " << ws.ps << std::endl;
174 local_left.
Velocity -= ws.center*normaldir;
175 local_right.
Velocity -= ws.center*normaldir;
176 velocity += ws.center;
178 ws = estimate_wave_speeds(local_left, local_right, ws.ps);
189 const Conserved usl = starred_state(local_left, ws.left, ws.center);
190 const Conserved usr = starred_state(local_right, ws.right, ws.center);
198 else if (ws.left <= 0 && ws.center >= 0)
200 f_gr = fl + ws.left*(usl - ul);
205 else if (ws.center < 0 && ws.right >= 0)
207 f_gr = fr + ws.right*(usr - ur);
210 ((ws.right - local_right.
Velocity.
x) / (ws.right - ws.center) - 1))*local_right.
Density;
219 throw invalid_wave_speeds(local_left,
227 0.5*f_gr.
Mass*velocity*velocity;
Set of conserved variables (extensive)
Vector2D Momentum
Momentum.
double SoundSpeed
Speed of sound.
virtual double de2p(double d, double e, tvector const &tracers=tvector(), vector< string > const &tracernames=vector< string >()) const =0
Calculates the pressure.
Container for error reports.
Vector2D Velocity
Velocity.
double max(vector< double > const &v)
returns the maximal term in a vector
double Energy
Total energy (kinetic + thermal)
double TotalEnergyDensity(Primitive const &p)
Calculates the total energy density.
double y
Component in the y direction.
Conserved Primitive2Conserved(Primitive const &p)
Converts primitive variables to conserved intensive.
Conserved Primitive2Flux(Primitive const &p, Vector2D const &n)
Converts primitive variables to flux.
double ScalarProd(Vector3D const &v1, Vector3D const &v2)
Scalar product of two vectors.
Base class for equation of state.
double min(vector< double > const &v)
Returns the minimal term in a vector.
double Energy
Thermal energy per unit mass, entahalpy in relativistic case.
bool is_nan(double x)
Checks whether a number is a nan.
HLLC riemann solver that keeps track of transfered internal energy.
Primitive hydrodynamic variables.
double x
Component in the x direction.
LagrangianHLLC(EquationOfState const &eos, bool massflux=true, bool iter=false)
Class constructor.