PLUTO
adv_flux.c File Reference

Compute flux for passive scalars. More...

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

Go to the source code of this file.

Macros

#define USE_CMA   NO
 

Functions

void AdvectFlux (const State_1D *state, int beg, int end, Grid *grid)
 

Detailed Description

Compute flux for passive scalars.

Compute the interface upwind flux for passive scalars q obeying advection equations of the form:

\[ \partial_tq + v\cdot \nabla q = 0 \qquad\Longleftrightarrow\qquad \partial_t(\rho q) + \nabla\cdot(\rho\vec{v}q) = 0 \]

Fluxes are computed using an upwind selection rule based on the density flux, already computed during a previous Riemann solver:

\[ (\rho vq)_{i+\HALF} = \left\{\begin{array}{ll} (\rho v)_{i+\HALF}q_L & \;\textrm{if} \quad (\rho v)_{i+\HALF} \ge 0 \\ \noalign{\medskip} (\rho v)_{i+\HALF}q_R & \; \textrm{otherwise} \end{array}\right. \]

where $ (\rho v)_{i+\HALF}$ is the density flux computed with the employed Riemann solver.

When ionization fractions are present, we employ a technique similar to the CMA (Consistent multi-fluid advection method) to normalize the sum of mass fractions to one.

The CMA can also be switched on for standard tracers ( #define USE_CMA YES)

Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
O. Tesileanu
Date
02 April, 2015

Reference "The consistent multi-fluid advection method" Plewa and Muller, A&A (1999) 342, 179.

Definition in file adv_flux.c.

Macro Definition Documentation

#define USE_CMA   NO

Definition at line 43 of file adv_flux.c.

Function Documentation

void AdvectFlux ( const State_1D state,
int  beg,
int  end,
Grid grid 
)
Parameters
[in,out]state
[in]beginitial index of computation
[in]endfinal index of computation
Returns
This function has no return value.

Definition at line 47 of file adv_flux.c.

56 {
57  int i, nv;
58  double *ts, *flux, *vL, *vR;
59  double s, rho;
60  double phi;
61  static double *sigma, **vi;
62 
63 /* -- compute scalar's fluxes -- */
64 
65  for (i = beg; i <= end; i++){
66 
67  flux = state->flux[i];
68  vL = state->vL[i];
69  vR = state->vR[i];
70 
71  ts = flux[RHO] > 0.0 ? vL:vR;
72 
73  NSCL_LOOP(nv) flux[nv] = flux[RHO]*ts[nv];
74 
75  #if COOLING == MINEq
76 
77  /* ----- He ----- */
78 
79  phi = ts[X_HeI] + ts[X_HeII];
80  for (nv = X_HeI; nv <= X_HeII; nv++) flux[nv] /= phi;
81 
82  /* ----- C ----- */
83 
84  phi = 0.0;
85  for (nv = X_CI; nv < X_CI + C_IONS; nv++) phi += ts[nv];
86  for (nv = X_CI; nv < X_CI + C_IONS; nv++) flux[nv] /= phi;
87 
88  /* ----- N ----- */
89 
90  phi = 0.0;
91  for (nv = X_NI; nv < X_NI+N_IONS; nv++) phi += ts[nv];
92  for (nv = X_NI; nv < X_NI+N_IONS; nv++) flux[nv] /= phi;
93 
94  /* ----- O ----- */
95 
96  phi = 0.0;
97  for (nv = X_OI; nv < X_OI+O_IONS; nv++) phi += ts[nv];
98  for (nv = X_OI; nv < X_OI+O_IONS; nv++) flux[nv] /= phi;
99 
100  /* ----- Ne ----- */
101 
102  phi = 0.0;
103  for (nv = X_NeI; nv < X_NeI+Ne_IONS; nv++) phi += ts[nv];
104  for (nv = X_NeI; nv < X_NeI+Ne_IONS; nv++) flux[nv] /= phi;
105 
106  /* ----- S ----- */
107 
108  phi = 0.0;
109  for (nv = X_SI; nv < X_SI+S_IONS; nv++) phi += ts[nv];
110  for (nv = X_SI; nv < X_SI+S_IONS; nv++) flux[nv] /= phi;
111 
112  #endif
113 
114  #if COOLING == H2_COOL
115  phi = ts[X_HI] + 2.0*ts[X_H2] + ts[X_HII];
116  for (nv = X_HI; nv < X_HI + NIONS; nv++) flux[nv] /= phi;
117  #endif
118 
119  #if USE_CMA == YES /* -- only for tracers -- */
120  phi = 0.0;
121  NTRACER_LOOP(nv) phi += ts[nv];
122  NTRACER_LOOP(nv) flux[nv] /= phi;
123  #endif
124 
125  #if ENTROPY_SWITCH
126  if (flux[RHO] >= 0.0) flux[ENTR] = state->vL[i][ENTR]*flux[RHO];
127  else flux[ENTR] = state->vR[i][ENTR]*flux[RHO];
128  #endif
129  }
130 }
#define S_IONS
Definition: cooling.h:17
#define NSCL_LOOP(n)
Definition: pluto.h:616
double ** flux
upwind flux computed with the Riemann solver
Definition: structs.h:149
#define RHO
Definition: mod_defs.h:19
#define C_IONS
Definition: cooling.h:13
#define NTRACER_LOOP(n)
Definition: pluto.h:615
double ** vR
Primitive variables to the right of the interface, .
Definition: structs.h:139
#define O_IONS
Definition: cooling.h:15
Definition: cooling.h:110
#define X_HII
Definition: cooling.h:31
#define NIONS
Definition: cooling.h:28
Definition: cooling.h:110
#define s
#define Ne_IONS
Definition: cooling.h:16
int i
Definition: analysis.c:2
#define X_H2
Definition: cooling.h:30
double ** vL
Primitive variables to the left of the interface, .
Definition: structs.h:136
#define N_IONS
Definition: cooling.h:14

Here is the caller graph for this function: