PLUTO
fluxes.c File Reference

Compute the MHD flux. More...

#include "pluto.h"
Include dependency graph for fluxes.c:

Go to the source code of this file.

Functions

void Flux (double **ucons, double **wprim, double *a2, double **bck, double **fx, double *p, int beg, int end)
 

Detailed Description

Compute the MHD flux.

Compute the flux of the conservative MHD equations in the direction given by g_dir. This function defines the component of the hyperbolic flux tensor of the standard MHD equations.
In what follows:

  • VXn, MXn, BXn are the velocity, momentum and magnetic field components in the direction given by g_dir (normal, "n")
  • VXt, MXt, BXt and VXb, MXb, BXb are the transverse components (tangent "t" and bi-tangent "b").
Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Jan 16, 2014

Definition in file fluxes.c.

Function Documentation

void Flux ( double **  ucons,
double **  wprim,
double *  a2,
double **  bck,
double **  fx,
double *  p,
int  beg,
int  end 
)
Parameters
[in]ucons1D array of conserved quantities
[in]wprim1D array of primitive quantities
[in]a21D array of sound speeds
[in]bck1D array of background field values
[out]fx1D array of fluxes (total pressure excluded)
[out]p1D array of pressure values
[in]beginitial index of computation
[in]endfinal index of computation
Returns
This function has no return value.

Definition at line 23 of file fluxes.c.

38 {
39  int nv, i;
40  double vB, ptot;
41  double bt1, bt2, bt3;
42  double *w, *u;
43 
44  for (i = beg; i <= end; i++) {
45 
46  w = wprim[i];
47  u = ucons[i];
48 
49  ptot = 0.5*(EXPAND(w[BX1]*w[BX1] , + w[BX2]*w[BX2], + w[BX3]*w[BX3]));
50 
51  #if HAVE_ENERGY
52  ptot += w[PRS];
53  #elif EOS == BAROTROPIC
54  ptot += BAROTROPIC_PR(w[RHO]);
55  #elif EOS == ISOTHERMAL
56  ptot += a2[i]*w[RHO];
57  #else
58  print ("! Flux(): not defined for this EoS\n");
59  QUIT_PLUTO(1);
60  #endif
61 
62  vB = EXPAND(w[VX1]*w[BX1] , + w[VX2]*w[BX2], + w[VX3]*w[BX3]);
63 
64  #if BACKGROUND_FIELD == YES
65  ptot += EXPAND(bck[i][BX1]*w[BX1], + bck[i][BX2]*w[BX2], + bck[i][BX3]*w[BX3]);
66 
67  EXPAND(bt1 = w[BXn] + bck[i][BXn]; ,
68  bt2 = w[BXt] + bck[i][BXt]; ,
69  bt3 = w[BXb] + bck[i][BXb];)
70 
71  fx[i][RHO] = u[MXn];
72  EXPAND(fx[i][MX1] = w[VXn]*u[MX1] - bt1*w[BX1] - w[BXn]*bck[i][BX1]; ,
73  fx[i][MX2] = w[VXn]*u[MX2] - bt1*w[BX2] - w[BXn]*bck[i][BX2]; ,
74  fx[i][MX3] = w[VXn]*u[MX3] - bt1*w[BX3] - w[BXn]*bck[i][BX3]; )
75 
76  EXPAND(fx[i][BXn] = 0.0; ,
77  fx[i][BXt] = w[VXn]*bt2 - bt1*w[VXt]; ,
78  fx[i][BXb] = w[VXn]*bt3 - bt1*w[VXb]; )
79  #if HAVE_ENERGY
80  fx[i][ENG] = (u[ENG] + ptot)*w[VXn] - bt1*vB;
81  #endif
82  #else
83  fx[i][RHO] = u[MXn];
84  EXPAND(fx[i][MX1] = w[VXn]*u[MX1] - w[BXn]*w[BX1]; ,
85  fx[i][MX2] = w[VXn]*u[MX2] - w[BXn]*w[BX2]; ,
86  fx[i][MX3] = w[VXn]*u[MX3] - w[BXn]*w[BX3]; )
87 
88  EXPAND(fx[i][BXn] = 0.0; ,
89  fx[i][BXt] = w[VXn]*w[BXt] - w[BXn]*w[VXt]; ,
90  fx[i][BXb] = w[VXn]*w[BXb] - w[BXn]*w[VXb]; )
91  #if HAVE_ENERGY
92  fx[i][ENG] = (u[ENG] + ptot)*w[VXn] - w[BXn]*vB;
93  #endif
94  #endif
95 
96  p[i] = ptot;
97 
98  #ifdef GLM_MHD
99  fx[i][BXn] = w[PSI_GLM];
100  fx[i][PSI_GLM] = glm_ch*glm_ch*w[BXn];
101  #endif
102  }
103 }
#define MX3
Definition: mod_defs.h:22
#define MX1
Definition: mod_defs.h:20
#define VX2
Definition: mod_defs.h:29
#define RHO
Definition: mod_defs.h:19
#define PSI_GLM
Definition: mod_defs.h:34
#define VX1
Definition: mod_defs.h:28
int VXb
Definition: globals.h:73
int BXn
Definition: globals.h:75
#define MX2
Definition: mod_defs.h:21
int VXt
Definition: globals.h:73
void print(const char *fmt,...)
Definition: amrPluto.cpp:497
int MXn
Definition: globals.h:74
int VXn
Definition: globals.h:73
#define BX3
Definition: mod_defs.h:27
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
int BXt
Definition: globals.h:75
int BXb
Definition: globals.h:75
#define QUIT_PLUTO(e_code)
Definition: macros.h:125
#define HAVE_ENERGY
Definition: pluto.h:395

Here is the call graph for this function: