PLUTO
hll_speed.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Compute the outermost wave speeds for HLL-based solvers.
5 
6  HLL_Speed() computes an estimate to the leftmost and rightmost
7  wave signal speeds bounding the Riemann fan based on the input states
8  ::vR and ::vL.
9  Depending on the estimate, several variants are possible.
10 
11  \authors A. Mignone (mignone@ph.unito.it)
12  \date June 6, 2013
13 */
14 /* ///////////////////////////////////////////////////////////////////// */
15 #include"pluto.h"
16 
17 /* **** switches, see below for description **** */
18 
19 #define DAVIS_ESTIMATE YES
20 #define EINFELDT_ESTIMATE NO
21 #define ROE_ESTIMATE NO
22 
23 /* ********************************************************************* */
24 void HLL_Speed (double **vL, double **vR, double *a2L, double *a2R,
25  double *SL, double *SR, int beg, int end)
26 /*!
27  * Compute leftmost (SL) and rightmost (SR) speed for the Riemann fan.
28  *
29  * \param [in] vL left state for the Riemann solver
30  * \param [in] vR right state for the Riemann solver
31  * \param [in] a2L 1-D array containing the square of the sound speed
32  * for the left state
33  * \param [in] a2R 1-D array containing the square of the sound speed
34  * for the right state
35  * \param [out] SL the (estimated) leftmost speed of the Riemann fan
36  * \param [out] SR the (estimated) rightmost speed of the Riemann fan
37  * \param [in] beg starting index of computation
38  * \param [in] end final index of computation
39  *
40  * Switches:
41  *
42  * ROE_ESTIMATE (YES/NO), DAVIS_ESTIMATE (YES/NO). TVD_ESTIMATE (YES/NO)
43  * JAN_HLL (YES/NO)
44  *
45  * These switches set how the wave speed estimates are
46  * going to be computed. Only one can be set to 'YES', and
47  * the rest of them must be set to 'NO'
48  *
49  * ROE_ESTIMATE: b_m = \min(0, \min(u_R - c_R, u_L - c_L, u_{roe} - c_{roe}))
50  * b_m = \min(0, \min(u_R + c_R, u_L + c_L, u_{roe} + c_{roe}))
51  *
52  * where u_{roe} and c_{roe} are computed using Roe averages.
53  *
54  * DAVIS_ESTIMATE: b_m = \min(0, \min(u_R - c_R, u_L - c_L))
55  * b_m = \min(0, \min(u_R + c_R, u_L + c_L))
56  *
57  *********************************************************************** */
58 {
59  int i;
60  double scrh, s, c;
61  double aL, dL;
62  double aR, dR;
63  double dvx, dvy, dvz;
64  double a_av, du, vx;
65  static double *sl_min, *sl_max;
66  static double *sr_min, *sr_max;
67 
68  if (sl_min == NULL){
69  sl_min = ARRAY_1D(NMAX_POINT, double);
70  sl_max = ARRAY_1D(NMAX_POINT, double);
71 
72  sr_min = ARRAY_1D(NMAX_POINT, double);
73  sr_max = ARRAY_1D(NMAX_POINT, double);
74  }
75 
76 /* ----------------------------------------------
77  DAVIS Estimate
78  ---------------------------------------------- */
79 
80  #if DAVIS_ESTIMATE == YES
81 
82  MaxSignalSpeed (vL, a2L, sl_min, sl_max, beg, end);
83  MaxSignalSpeed (vR, a2R, sr_min, sr_max, beg, end);
84  for (i = beg; i <= end; i++) {
85 
86  SL[i] = MIN(sl_min[i], sr_min[i]);
87  SR[i] = MAX(sl_max[i], sr_max[i]);
88 
89  aL = sqrt(a2L[i]);
90  aR = sqrt(a2R[i]);
91 
92  scrh = fabs(vL[i][VXn]) + fabs(vR[i][VXn]);
93  scrh /= aL + aR;
94 
95  g_maxMach = MAX(scrh, g_maxMach);
96  }
97 
98  #endif
99 
100 /* ----------------------------------------------
101  Einfeldt Estimate for wave speed
102  ---------------------------------------------- */
103 
104  #if EINFELDT_ESTIMATE == YES
105 
106  for (i = beg; i <= end; i++) {
107 
108  aL = sqrt(a2L[i]);
109  aR = sqrt(a2R[i]);
110 
111  dL = sqrt(vL[i][RHO]);
112  dR = sqrt(vR[i][RHO]);
113  a_av = 0.5*dL*dR/( (dL + dR)*(dL + dR));
114  du = vR[i][VXn] - vL[i][VXn];
115  scrh = (dR*aL*aL + dR*aR*aR)/(dL + dR);
116  scrh += a_av*du*du;
117 
118  SL[i] = (dl*ql[VXn] + dr*qr[VXn])/(dl + dr);
119 
120  bmin = MIN(0.0, um[VXn] - sqrt(scrh));
121  bmax = MAX(0.0, um[VXn] + sqrt(scrh));
122  }
123  #endif
124 
125 /* ----------------------------------------------
126  Roe-like Estimate
127  ---------------------------------------------- */
128 
129  #if ROE_ESTIMATE == YES
130 
131  for (i = beg; i <= end; i++) {
132 
133  aL = sqrt(a2L[i]);
134  aR = sqrt(a2R[i]);
135 
136  s = 1.0/(1.0 + sqrt(vR[i][RHO]/vL[i][RHO]));
137  c = 1.0 - s;
138 
139  vx = s*vL[i][VXn] + c*vR[i][VXn];
140 
141 /* ************************************************************
142  The following definition of the averaged sound speed
143  is equivalent to original formulation given by Roe;
144  here we just simplify the expression without explicitly
145  computing the Enthalpy:
146  ************************************************************ */
147 
148  EXPAND(dvx = vL[i][VX1] - vR[i][VX1]; ,
149  dvy = vL[i][VX2] - vR[i][VX2]; ,
150  dvz = vL[i][VX3] - vR[i][VX3];)
151 
152  scrh = EXPAND(dvx*dvx, + dvy*dvy, + dvz*dvz);
153 
154  a_av = sqrt(s*aL2 + c*aR2 + 0.5*s*c*gmm1*scrh);
155 
156  SL[i] = MIN(vL[i][VXn] - aL, vx - a_av);
157  SR[i] = MAX(vR[i][VXn] + aR, vx + a_av);
158 
159  scrh = (fabs(vL[i][VXn]) + fabs(vR[i][VXn]))/(aL + aR);
160  g_maxMach = MAX(scrh, g_maxMach);
161 
162  }
163  #endif
164 
165 }
166 #undef DAVIS_ESTIMATE
167 #undef EINFELDT_ESTIMATE
168 #undef ROE_ESTIMATE
#define MAX(a, b)
Definition: macros.h:101
#define VX2
Definition: mod_defs.h:29
#define RHO
Definition: mod_defs.h:19
tuple scrh
Definition: configure.py:200
#define VX1
Definition: mod_defs.h:28
#define MIN(a, b)
Definition: macros.h:104
double g_maxMach
The maximum Mach number computed during integration.
Definition: globals.h:119
tuple c
Definition: menu.py:375
int VXn
Definition: globals.h:73
#define s
PLUTO main header file.
#define ARRAY_1D(nx, type)
Definition: prototypes.h:170
long int NMAX_POINT
Maximum number of points among the three directions, boundaries excluded.
Definition: globals.h:62
int i
Definition: analysis.c:2
void HLL_Speed(double **vL, double **vR, double *a2L, double *a2R, double *SL, double *SR, int beg, int end)
Definition: hll_speed.c:24
#define VX3
Definition: mod_defs.h:30
void MaxSignalSpeed(double **v, double *cs2, double *cmin, double *cmax, int beg, int end)
Definition: eigenv.c:34