PLUTO
tvdlf.c
Go to the documentation of this file.
1 #include "pluto.h"
2 
3 /* ********************************************************************* */
4 void LF_Solver (const State_1D *state, int beg, int end,
5  double *cmax, Grid *grid)
6 /*
7  *
8  * NAME
9  *
10  * LF_SOLVER
11  *
12  *
13  * PURPOSE
14  *
15  * Solve riemann problem for the relativistic MHD equations
16  * using th Lax-Friedrichs Rusanov solver.
17  *
18  * LAST_MODIFIED
19  *
20  * Feb 15/2010 by Andrea Mignone (mignone@ph.unito.it)
21  *
22  *
23  **************************************************************************** */
24 {
25  int nv, i;
26  double *uL, *uR, *flux, cL, cR;
27  static double **fL, *pL, *a2L, *hL, *cmin_L, *cmax_L;
28  static double **fR, *pR, *a2R, *hR, *cmin_R, *cmax_R;
29  static double **VL, **VR, **UL, **UR;
30 
31  if (fR == NULL){
32  fR = ARRAY_2D(NMAX_POINT, NFLX, double);
33  fL = ARRAY_2D(NMAX_POINT, NFLX, double);
34  pR = ARRAY_1D(NMAX_POINT, double);
35  pL = ARRAY_1D(NMAX_POINT, double);
36  cmin_R = ARRAY_1D(NMAX_POINT, double);
37  cmin_L = ARRAY_1D(NMAX_POINT, double);
38  cmax_R = ARRAY_1D(NMAX_POINT, double);
39  cmax_L = ARRAY_1D(NMAX_POINT, double);
40  #ifdef GLM_MHD
41  VL = ARRAY_2D(NMAX_POINT, NVAR, double);
42  VR = ARRAY_2D(NMAX_POINT, NVAR, double);
43  UL = ARRAY_2D(NMAX_POINT, NVAR, double);
44  UR = ARRAY_2D(NMAX_POINT, NVAR, double);
45  #endif
46 
47  a2R = ARRAY_1D(NMAX_POINT, double);
48  a2L = ARRAY_1D(NMAX_POINT, double);
49  hR = ARRAY_1D(NMAX_POINT, double);
50  hL = ARRAY_1D(NMAX_POINT, double);
51  }
52 
53 /* ----------------------------------------------------
54  redefine states if GLM_MHD is used
55  ---------------------------------------------------- */
56 
57  #ifdef GLM_MHD
58  GLM_Solve (state, VL, VR, beg, end, grid);
59  PrimToCons (VL, UL, beg, end);
60  PrimToCons (VR, UR, beg, end);
61  #else
62  VL = state->vL; UL = state->uL;
63  VR = state->vR; UR = state->uR;
64  #endif
65 
66 /* ----------------------------------------------------
67  compute sound speed & fluxes at zone interfaces
68  ---------------------------------------------------- */
69 
70  SoundSpeed2 (VL, a2L, hL, beg, end, FACE_CENTER, grid);
71  SoundSpeed2 (VR, a2R, hR, beg, end, FACE_CENTER, grid);
72 
73  Flux (UL, VL, hL, fL, pL, beg, end);
74  Flux (UR, VR, hR, fR, pR, beg, end);
75 
76 /* -------------------------------------------------------------------
77  compute Max and min eigenvalues for the left and right states
78  ------------------------------------------------------------------- */
79 
80  MaxSignalSpeed (VL, a2L, hL, cmin_L, cmax_L, beg, end);
81  MaxSignalSpeed (VR, a2R, hR, cmin_R, cmax_R, beg, end);
82 
83  for (i = beg; i <= end; i++) {
84 
85  /* -- compute local max eigenvalue -- */
86 
87  cL = MAX(fabs(cmax_L[i]), fabs(cmin_L[i]));
88  cR = MAX(fabs(cmax_R[i]), fabs(cmin_R[i]));
89  cmax[i] = MAX(cL, cR);
90  state->SL[i] = -cmax[i];
91  state->SR[i] = cmax[i];
92 
93  /* -- compute Rusanov flux -- */
94 
95  uL = UL[i];
96  uR = UR[i];
97  flux = state->flux[i];
98  for (nv = NFLX; nv--; ) {
99  flux[nv] = 0.5*(fL[i][nv] + fR[i][nv] - cmax[i]*(uR[nv] - uL[nv]));
100  }
101  state->press[i] = 0.5*(pL[i] + pR[i]);
102  }
103 
104 /* --------------------------------------------------------
105  initialize source term
106  -------------------------------------------------------- */
107 
108  #if DIVB_CONTROL == EIGHT_WAVES
109  POWELL_DIVB_SOURCE (state, beg, end, grid);
110  #endif
111 
112 }
#define MAX(a, b)
Definition: macros.h:101
void GLM_Solve(const State_1D *state, double **VL, double **VR, int beg, int end, Grid *grid)
Definition: glm.c:24
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
double * SR
Rightmost velocity in the Riemann fan at i+1/2.
Definition: structs.h:167
void LF_Solver(const State_1D *state, int beg, int end, double *cmax, Grid *grid)
Definition: tvdlf.c:38
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
#define FACE_CENTER
Definition: pluto.h:206
Definition: structs.h:78
double * SL
Leftmost velocity in the Riemann fan at i+1/2.
Definition: structs.h:166
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
void PrimToCons(double **uprim, double **ucons, int ibeg, int iend)
Definition: mappers.c:26
int i
Definition: analysis.c:2
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
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
void POWELL_DIVB_SOURCE(const State_1D *, int, int, Grid *)
Definition: source.c:5
#define NVAR
Definition: pluto.h:609
double ** uL
same as vL, in conservative vars
Definition: structs.h:144