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 ROE_ESTIMATE NO
20 #define DAVIS_ESTIMATE YES
21 
22 /* ********************************************************************* */
23 void HLL_Speed (double **vL, double **vR, double *a2L, double *a2R, double **bgf,
24  double *SL, double *SR, int beg, int end)
25 /*!
26  * Compute leftmost (SL) and rightmost (SR) speed for the Riemann fan.
27  *
28  * \param [in] vL left state for the Riemann solver
29  * \param [in] vR right state for the Riemann solver
30  * \param [in] a2L 1-D array containing the square of the sound speed
31  * for the left state
32  * \param [in] a2R 1-D array containing the square of the sound speed
33  * for the right state
34  * \param [out] SL the (estimated) leftmost speed of the Riemann fan
35  * \param [out] SR the (estimated) rightmost speed of the Riemann fan
36  * \param [in] beg starting index of computation
37  * \param [in] end final index of computation
38  *
39  * Switches:
40  *
41  * ROE_ESTIMATE (YES/NO), DAVIS_ESTIMATE (YES/NO). TVD_ESTIMATE (YES/NO)
42  * JAN_HLL (YES/NO)
43  *
44  * These switches set how the wave speed estimates are
45  * going to be computed. Only one can be set to 'YES', and
46  * the rest of them must be set to 'NO'
47  *
48  * ROE_ESTIMATE: b_m = \min(0, \min(u_R - c_R, u_L - c_L, u_{roe} - c_{roe}))
49  * b_m = \min(0, \min(u_R + c_R, u_L + c_L, u_{roe} + c_{roe}))
50  *
51  * where u_{roe} and c_{roe} are computed using Roe averages.
52  *
53  * DAVIS_ESTIMATE: b_m = \min(0, \min(u_R - c_R, u_L - c_L))
54  * b_m = \min(0, \min(u_R + c_R, u_L + c_L))
55  *
56  *********************************************************************** */
57 {
58  int i;
59  double scrh, s, c;
60  static double *sl_min, *sl_max;
61  static double *sr_min, *sr_max;
62  static double *sm_min, *sm_max;
63  static double **vm;
64 
65  if (sl_min == NULL){
66  vm = ARRAY_2D(NMAX_POINT, NVAR, double);
67  sl_min = ARRAY_1D(NMAX_POINT, double);
68  sl_max = ARRAY_1D(NMAX_POINT, double);
69 
70  sr_min = ARRAY_1D(NMAX_POINT, double);
71  sr_max = ARRAY_1D(NMAX_POINT, double);
72 
73  sm_min = ARRAY_1D(NMAX_POINT, double);
74  sm_max = ARRAY_1D(NMAX_POINT, double);
75  }
76 
77 /* ----------------------------------------------
78  DAVIS Estimate
79  ---------------------------------------------- */
80 
81  #if DAVIS_ESTIMATE == YES
82 
83  MaxSignalSpeed (vL, a2L, sl_min, sl_max, bgf, beg, end);
84  MaxSignalSpeed (vR, a2R, sr_min, sr_max, bgf, beg, end);
85 
86  for (i = beg; i <= end; i++) {
87 
88  SL[i] = MIN(sl_min[i], sr_min[i]);
89  SR[i] = MAX(sl_max[i], sr_max[i]);
90 
91  /* -- define g_maxMach -- */
92 
93  scrh = fabs(vL[i][VXn]) + fabs(vR[i][VXn]);
94  scrh /= sqrt(a2L[i]) + sqrt(a2R[i]);
95 /*
96  #if EOS == IDEAL
97  scrh = fabs(vL[i][VXn]) + fabs(vR[i][VXn]);
98  scrh = scrh/(sqrt(g_gamma*vL[i][PRS]/vL[i][RHO]) + sqrt(g_gamma*vR[i][PRS]/vR[i][RHO]));
99  #elif EOS == ISOTHERMAL
100  scrh = 0.5*( fabs(vL[i][VXn]) + fabs(vR[i][VXn]) )/g_isoSoundSpeed;
101  #elif EOS == BAROTROPIC
102  scrh = 0.5*(fabs(vL[i][VXn]) + fabs(vR[i][VXn]));
103  s = 0.5*(vL[i][RHO] + vR[i][RHO]);
104  c = BAROTROPIC_PR(s);
105  scrh /= sqrt(g_gamma*c/s);
106  #else
107  print ("! HLL_SPEED: not defined for this EoS\n");
108  QUIT_PLUTO(1);
109  #endif
110 */
111  g_maxMach = MAX(scrh, g_maxMach);
112 
113  }
114 
115  #endif
116 
117 /* ----------------------------------------------
118  Roe-like Estimate
119  ---------------------------------------------- */
120 
121  #if ROE_ESTIMATE == YES
122 
123  MaxSignalSpeed (vL, a2L, sl_min, sl_max, bgf, beg, end);
124  MaxSignalSpeed (vR, a2R, sr_min, sr_max, bgf, beg, end);
125 
126  for (i = beg; i <= end; i++) {
127 
128  scrh = sqrt(vR[i][RHO]/vL[i][RHO]);
129  s = 1.0/(1.0 + scrh);
130  c = 1.0 - s;
131 
132  vm[i][RHO] = vL[i][RHO]*scrh;
133  vm[i][VXn] = s*vL[i][VXn] + c*vR[i][VXn];
134 
135  /* ----------------------------------
136  the next definition is not the
137  same as the one given by Roe; it
138  is used here to define the sound
139  speed.
140  ---------------------------------- */
141 
142  #if EOS == IDEAL
143  vm[i][PRS] = s*gpl + c*gpr;
144  #endif
145 
146  /* ---------------------------------------
147  this is the definitions given by
148  Cargo and Gallice, see the Roe
149  Solver
150  --------------------------------------- */
151 
152  EXPAND(vm[i][BXn] = c*vL[i][BXn] + s*vR[i][BXn]; ,
153  vm[i][BXt] = c*vL[i][BXt] + s*vR[i][BXt]; ,
154  vm[i][BXb] = c*vL[i][BXb] + s*vR[i][BXb];)
155 
156  }
157 
158  MAX_CH_SPEED(vm, sm_min, sm_max, bgf, beg, end);
159 
160  for (i = beg; i <= end; i++) {
161  SL[i] = MIN(sl_min[i], sm_min[i]);
162  SR[i] = MAX(sr_max[i], sm_max[i]);
163 
164  /* -- define g_maxMach -- */
165 
166  #if EOS == IDEAL
167  scrh = fabs(vm[i][VXn])/sqrt(vm[i][PRS]/vm[i][RHO]);
168  #elif EOS == ISOTHERMAL
169  scrh = fabs(vm[i][VXn])/g_isoSoundSpeed;
170  #elif EOS == BAROTROPIC
171  print ("! HLL_SPEED: stop\n");
172  QUIT_PLUTO(1);
173  #endif
174  g_maxMach = MAX(scrh, g_maxMach);
175  }
176 
177  #endif
178 }
179 #undef DAVIS_ESTIMATE
180 #undef ROE_ESTIMATE
#define MAX(a, b)
Definition: macros.h:101
#define RHO
Definition: mod_defs.h:19
tuple scrh
Definition: configure.py:200
int BXn
Definition: globals.h:75
#define MIN(a, b)
Definition: macros.h:104
double g_maxMach
The maximum Mach number computed during integration.
Definition: globals.h:119
void print(const char *fmt,...)
Definition: amrPluto.cpp:497
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
void MaxSignalSpeed(double **v, double *cs2, double *cmin, double *cmax, int beg, int end)
Definition: eigenv.c:34
#define ARRAY_2D(nx, ny, type)
Definition: prototypes.h:171
int BXt
Definition: globals.h:75
#define NVAR
Definition: pluto.h:609
int BXb
Definition: globals.h:75
#define QUIT_PLUTO(e_code)
Definition: macros.h:125