PLUTO
fluxes.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Compute the RMHD flux.
5 
6  Compute the flux of the conservative RMHD equations in the direction
7  given by ::g_dir.
8  This function defines the component of the hyperbolic flux tensor
9  of the standard MHD equations.\n
10  In what follows:
11  - \c VXn, \c MXn, \c BXn are the velocity, momentum and magnetic field
12  components in the direction given by ::g_dir (normal, \c "n")
13  - \c VXt, \c MXt, \c BXt and \c VXb, \c MXb, \c BXb are the transverse
14  components (tangent \c "t" and bi-tangent \c "b").
15 
16  \author A. Mignone (mignone@ph.unito.it)
17  \date Jun 10, 2015
18 */
19 /* ///////////////////////////////////////////////////////////////////// */
20 #include "pluto.h"
21 
22 /* ***************************************************************** */
23 void Flux (double **ucons, double **uprim, double *h,
24  double **fx, real *pr, int beg, int end)
25 /*
26  *
27  *
28  *
29  ******************************************************************* */
30 {
31  int nv, i;
32  double vB, uB, b2, wt, wtg2, Bmag2, pt;
33  double *u, *v, b[4], g, g2, g_2;
34 
35  for (i = beg; i <= end; i++) {
36 
37  u = ucons[i];
38  v = uprim[i];
39 
40  g = u[RHO]/v[RHO];
41  g2 = g*g;
42  g_2 = 1.0/g2;
43 
44  Bmag2 = EXPAND(v[BX1]*v[BX1], + v[BX2]*v[BX2], + v[BX3]*v[BX3]);
45 
46  vB = EXPAND(v[VX1]*v[BX1], + v[VX2]*v[BX2], + v[VX3]*v[BX3]);
47  EXPAND(b[IDIR] = g*(v[BX1]*g_2 + vB*v[VX1]); ,
48  b[JDIR] = g*(v[BX2]*g_2 + vB*v[VX2]); ,
49  b[KDIR] = g*(v[BX3]*g_2 + vB*v[VX3]);)
50  b2 = Bmag2*g_2 + vB*vB;
51 
52  pt = v[PRS] + 0.5*b2;
53  wt = v[RHO]*h[i] + b2;
54  wtg2 = wt*g2;
55 
56  fx[i][RHO] = u[RHO]*v[VXn];
57  EXPAND(fx[i][MX1] = wtg2*v[VX1]*v[VXn] - b[IDIR]*b[g_dir]; ,
58  fx[i][MX2] = wtg2*v[VX2]*v[VXn] - b[JDIR]*b[g_dir]; ,
59  fx[i][MX3] = wtg2*v[VX3]*v[VXn] - b[KDIR]*b[g_dir];)
60  EXPAND(fx[i][BXn] = 0.0; ,
61  fx[i][BXt] = v[VXn]*v[BXt] - v[BXn]*v[VXt]; ,
62  fx[i][BXb] = v[VXn]*v[BXb] - v[BXn]*v[VXb]; )
63 
64  fx[i][ENG] = u[MXn];
65  #if RMHD_REDUCED_ENERGY
66  fx[i][ENG] -= fx[i][RHO];
67  #endif
68 
69  pr[i] = pt;
70 
71 #ifdef GLM_MHD
72  fx[i][BXn] = v[PSI_GLM];
73  fx[i][PSI_GLM] = glm_ch*glm_ch*v[BXn];
74 #endif
75 
76  }
77 }
#define MX3
Definition: mod_defs.h:22
#define MX1
Definition: mod_defs.h:20
#define VX2
Definition: mod_defs.h:29
double real
Definition: pluto.h:488
void Flux(double **u, double **w, double *a2, double **fx, double *p, int beg, int end)
Definition: fluxes.c:23
#define RHO
Definition: mod_defs.h:19
#define PSI_GLM
Definition: mod_defs.h:34
double v[NVAR]
Definition: eos.h:106
#define VX1
Definition: mod_defs.h:28
#define KDIR
Definition: pluto.h:195
int VXb
Definition: globals.h:73
int BXn
Definition: globals.h:75
#define IDIR
Definition: pluto.h:193
int g_dir
Specifies the current sweep or direction of integration.
Definition: globals.h:86
#define MX2
Definition: mod_defs.h:21
int VXt
Definition: globals.h:73
int MXn
Definition: globals.h:74
int VXn
Definition: globals.h:73
#define BX3
Definition: mod_defs.h:27
PLUTO main header file.
int i
Definition: analysis.c:2
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
#define BX2
Definition: mod_defs.h:26
double glm_ch
The propagation speed of divergence error.
Definition: glm.c:21
#define JDIR
Definition: pluto.h:194
int BXt
Definition: globals.h:75
int BXb
Definition: globals.h:75