PLUTO
hll.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief HLL Riemann solver for HD.
5 
6  Solve the Riemann problem for the HD equations using the
7  single-state HLL solver by Toro.
8 
9  On input, this function takes left and right primitive state vectors
10  \c state->vL and \c state->vR at zone edge \c i+1/2;
11  On output, return flux and pressure vectors at the same interface
12  \c i+1/2 (note that the \c i refers to \c i+1/2).
13 
14  Also during this step, compute maximum wave propagation speed (cmax)
15  for explicit time step computation.
16 
17  \b Reference:
18  - "Riemann Solver and Numerical Methods for Fluid Dynamics"
19  by E.F. Toro (Chapter 10)
20  - "On Godunov-Type Method near Low Densities"
21  by B. Einfeldt, C.D. Munz, P.L. Roe, JCP 92, 273-295 (1991)
22 
23  \authors A. Mignone (mignone@ph.unito.it)
24  \date March 23, 2012
25 */
26 /* ///////////////////////////////////////////////////////////////////// */
27 #include"pluto.h"
28 
29 /* ********************************************************************* */
30 void HLL_Solver (const State_1D *state, int beg, int end,
31  double *cmax, Grid *grid)
32 /*!
33  * Solve Riemann problem for the adiabatic/isothermal MHD equations
34  * using the HLL Riemann solver.
35  *
36  * \param[in,out] state pointer to State_1D structure
37  * \param[in] beg initial grid index
38  * \param[out] end final grid index
39  * \param[out] cmax 1D array of maximum characteristic speeds
40  * \param[in] grid pointer to array of Grid structures.
41  *
42  *********************************************************************** */
43 {
44  int nv, i;
45  double scrh;
46  static double *pL, *pR, *SL, *SR, *a2L, *a2R;
47  static double **fL, **fR;
48  double *uR, *uL;
49  double bmax, bmin, *vL, *vR, aL, aR;
50 
51 /* -- Allocate memory -- */
52 
53  if (fL == NULL){
54  fL = ARRAY_2D(NMAX_POINT, NFLX, double);
55  fR = ARRAY_2D(NMAX_POINT, NFLX, double);
56 
57  pR = ARRAY_1D(NMAX_POINT, double);
58  pL = ARRAY_1D(NMAX_POINT, double);
59  SR = ARRAY_1D(NMAX_POINT, double);
60  SL = ARRAY_1D(NMAX_POINT, double);
61 
62  a2R = ARRAY_1D(NMAX_POINT, double);
63  a2L = ARRAY_1D(NMAX_POINT, double);
64  }
65 
66 /* ----------------------------------------------------
67  compute sound speed & fluxes at zone interfaces
68  ---------------------------------------------------- */
69 
70  SoundSpeed2 (state->vL, a2L, NULL, beg, end, FACE_CENTER, grid);
71  SoundSpeed2 (state->vR, a2R, NULL, beg, end, FACE_CENTER, grid);
72 
73  Flux (state->uL, state->vL, a2L, fL, pL, beg, end);
74  Flux (state->uR, state->vR, a2R, fR, pR, beg, end);
75 
76  HLL_Speed (state->vL, state->vR, a2L, a2R, SL, SR, beg, end);
77  for (i = beg; i <= end; i++) {
78 
79  scrh = MAX(fabs(SL[i]), fabs(SR[i]));
80  cmax[i] = scrh;
81 
82  if (SL[i] > 0.0){
83 
84  for (nv = NFLX; nv--; ) state->flux[i][nv] = fL[i][nv];
85  state->press[i] = pL[i];
86 
87  }else if (SR[i] < 0.0){
88 
89  for (nv = NFLX; nv--; ) state->flux[i][nv] = fR[i][nv];
90  state->press[i] = pR[i];
91 
92  }else{
93 
94  uR = state->uR[i];
95  uL = state->uL[i];
96 
97  scrh = 1.0 / (SR[i] - SL[i]);
98  for (nv = NFLX; nv--; ) {
99  state->flux[i][nv] = SL[i]*SR[i]*(uR[nv] - uL[nv]) +
100  SR[i]*fL[i][nv] - SL[i]*fR[i][nv];
101  state->flux[i][nv] *= scrh;
102  }
103  state->press[i] = (SR[i]*pL[i] - SL[i]*pR[i])*scrh;
104 
105  }
106  } /* end loops on points */
107 }
#define MAX(a, b)
Definition: macros.h:101
double ** flux
upwind flux computed with the Riemann solver
Definition: structs.h:149
void Flux(double **u, double **w, double *a2, double **fx, double *p, int beg, int end)
Definition: fluxes.c:23
tuple scrh
Definition: configure.py:200
double ** vR
Primitive variables to the right of the interface, .
Definition: structs.h:139
void SoundSpeed2(double **v, double *cs2, double *h, int beg, int end, int pos, Grid *grid)
Definition: eos.c:16
#define NFLX
Definition: mod_defs.h:32
void HLL_Solver(const State_1D *state, int beg, int end, double *cmax, Grid *grid)
Definition: hll.c:30
#define FACE_CENTER
Definition: pluto.h:206
Definition: structs.h:78
double ** uR
same as vR, in conservative vars
Definition: structs.h:145
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
double ** vL
Primitive variables to the left of the interface, .
Definition: structs.h:136
double * press
Upwind pressure term computed with the Riemann solver.
Definition: structs.h:164
#define ARRAY_2D(nx, ny, type)
Definition: prototypes.h:171
double ** uL
same as vL, in conservative vars
Definition: structs.h:144