PLUTO
parabolic_flux.c
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Compute diffusion fluxes for explicit time stepping.
5 
6  Compute parabolic fluxes and corresponding source terms for explicit
7  time stepping only and add them to upwind fluxes.
8  For ::STS and ::RKC integration see the ParabolicRHS() function.
9  Note that source terms are only included for viscous terms, since
10  resistivity and thermal conduction do not need any.
11 
12  \note For explicit resistive MHD, the EMF is comprised of 2 terms:
13  EMF = E(hyp) + E(par)
14  The correct sequence of steps for building the EMF are:
15  - E(hyp) is the flux computed with Riemann solver
16  - for STAGGERED_MHD E(hyp) is stored at appropriate
17  location for later re-use by calling ::CT_StoreEMF
18  - Parabolic fluxes are added to the hyperbolic flux
19  (useful only for cell-centered MHD).
20 
21 
22  \authors A. Mignone (mignone@ph.unito.it)\n
23  P. Tzeferacos (petros.tzeferacos@ph.unito.it)
24  \date Sept 4, 2014
25 */
26 /* ///////////////////////////////////////////////////////////////////// */
27 #include "pluto.h"
28 
29 #if THERMAL_CONDUCTION != NO && (EOS == ISOTHERMAL || EOS == BAROTROPIC)
30  #error ! No Energy Equation: Thermal Conduction cannot be included
31 #endif
32 
33 /* ********************************************************************* */
34 void ParabolicFlux (Data_Arr V, Data_Arr J, double ***T,
35  const State_1D *state,
36  double **dcoeff, int beg, int end, Grid *grid)
37 /*!
38  * Add the diffusion fluxes to the upwind fluxes for explicit time
39  * integration.
40  *
41  * \param [in] V pointer to the 3D array of cell-centered primitive
42  * variables
43  * \param [in,out] state pointer to a State_1D structure
44  * \param [out] dcoeff the diffusion coefficients 1D array
45  * \param [in] beg initial index of computation
46  * \param [in] end final index of computation
47  * \param [in] grid pointer to an array of Grid structures
48  *
49  *********************************************************************** */
50 {
51  int i, j, k, nv;
52 
53 /* -------------------------------------------------
54  1. Viscosity
55  ------------------------------------------------- */
56 
57  #if VISCOSITY == EXPLICIT
58  #ifdef FARGO
59  print ("! ParabolicFlux: FARGO incompatible with explicit viscosity.\n");
60  print (" Try STS or RKC instead\n");
61  QUIT_PLUTO(1);
62  #endif
63  ViscousFlux (V, state->visc_flux, state->visc_src, dcoeff, beg, end, grid);
64  for (i = beg; i <= end; i++){
65  EXPAND(state->flux[i][MX1] -= state->visc_flux[i][MX1]; ,
66  state->flux[i][MX2] -= state->visc_flux[i][MX2]; ,
67  state->flux[i][MX3] -= state->visc_flux[i][MX3]; )
68  #if HAVE_ENERGY
69  state->flux[i][ENG] -= state->visc_flux[i][ENG];
70  #endif
71 
72  }
73  #endif
74 
75 /* -------------------------------------------------
76  2. Thermal conduction
77  ------------------------------------------------- */
78 
79  #if THERMAL_CONDUCTION == EXPLICIT
80  TC_Flux (T, state, dcoeff, beg, end, grid);
81  for (i = beg; i <= end; i++) state->flux[i][ENG] -= state->tc_flux[i][ENG];
82  /* !!!! tc_flux can be redefined as a 1D array since only the energy
83  component is required !!! */
84  #endif
85 
86 /* ----------------------------------------------------------------
87  3. Resistivity.
88  Note for the entropy flux: differently from viscosity and
89  thermal conduction, the contribution to the entropy due to
90  currents is given by J^2 and cannot be expressed as a simple
91  two-point flux difference.
92  This is done in a separate step (...)
93  ---------------------------------------------------------------- */
94 
95  #if (RESISTIVITY == EXPLICIT)
96  ResistiveFlux (V, J, state->res_flux, dcoeff, beg, end, grid);
97  for (i = beg; i <= end; i++){
98 
99  /* ------------------------------------------
100  normal component of magnetic field does
101  not evolve during the current sweep.
102  ------------------------------------------ */
103 
104  state->res_flux[i][BXn] = 0.0;
105 
106  /* ---------------------------------------------------
107  add the parabolic part of the EMF, only for
108  cell-centered MHD. CT is handled in a truly
109  multidimensional way.
110  --------------------------------------------- */
111 
112  EXPAND(state->flux[i][BX1] += state->res_flux[i][BX1]; ,
113  state->flux[i][BX2] += state->res_flux[i][BX2]; ,
114  state->flux[i][BX3] += state->res_flux[i][BX3]; )
115  #if HAVE_ENERGY
116  state->flux[i][ENG] += state->res_flux[i][ENG];
117  #endif
118  }
119  #endif
120 
121 }
#define MX3
Definition: mod_defs.h:22
tuple T
Definition: Sph_disk.py:33
void ViscousFlux(Data_Arr, double **, double **, double **, int, int, Grid *)
Definition: viscous_flux.c:14
#define MX1
Definition: mod_defs.h:20
double **** Data_Arr
Definition: pluto.h:492
double ** flux
upwind flux computed with the Riemann solver
Definition: structs.h:149
void TC_Flux(double ***, const State_1D *, double **, int, int, Grid *)
Definition: tc_flux.c:57
double ** visc_src
Viscosity source term.
Definition: structs.h:151
double ** res_flux
Resistive flux (current)
Definition: structs.h:153
double ** visc_flux
Viscosity flux.
Definition: structs.h:150
int BXn
Definition: globals.h:75
Definition: structs.h:78
int j
Definition: analysis.c:2
#define MX2
Definition: mod_defs.h:21
if(divB==NULL)
Definition: analysis.c:10
int k
Definition: analysis.c:2
void print(const char *fmt,...)
Definition: amrPluto.cpp:497
double ** tc_flux
Thermal conduction flux.
Definition: structs.h:152
#define BX3
Definition: mod_defs.h:27
PLUTO main header file.
#define RESISTIVITY
Definition: pluto.h:357
int i
Definition: analysis.c:2
#define BX1
Definition: mod_defs.h:25
void ParabolicFlux(Data_Arr V, Data_Arr J, double ***T, const State_1D *state, double **dcoeff, int beg, int end, Grid *grid)
#define BX2
Definition: mod_defs.h:26
void ResistiveFlux(Data_Arr V, Data_Arr curlB, double **res_flux, double **dcoeff, int beg, int end, Grid *grid)
Definition: res_flux.c:52
#define QUIT_PLUTO(e_code)
Definition: macros.h:125
#define EXPLICIT
Definition: pluto.h:67