PLUTO
res_flux.c File Reference

Compute the resistive MHD flux. More...

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

Go to the source code of this file.

Functions

void ResistiveFlux (Data_Arr V, Data_Arr curlB, double **res_flux, double **dcoeff, int beg, int end, Grid *grid)
 

Detailed Description

Compute the resistive MHD flux.

Compute the resistive fluxes for the induction and energy equations. In the induction equation, fluxes are computed by explicitly writing the curl operator in components. In Cartesian components, for instance, one has

\[ \pd{\vec{B}}{t} = - \nabla\times{\vec{E}_{\rm res}} = \pd{}{x}\left(\begin{array}{c} 0 \\ \noalign{\medskip} \eta_z J_z \\ \noalign{\medskip} - \eta_y J_y \end{array}\right) + \pd{}{y}\left(\begin{array}{c} - \eta_z J_z \\ \noalign{\medskip} 0 \\ \noalign{\medskip} \eta_x J_x \end{array}\right) + \pd{}{z}\left(\begin{array}{c} \eta_y J_y \\ \noalign{\medskip} -\eta_x J_x \\ \noalign{\medskip} 0 \end{array}\right) \,,\qquad \left(\vec{E}_{\rm res} = \tens{\eta}\cdot\vec{J}\right) \]

where $\tens{\eta}$ is the resistive diagonal tensor and $J = \nabla\times\vec{B}$ is the current density. The corresponding contribution to the energy equation is

\[ \pd{E}{t} = -\nabla\cdot\Big[(\tens{\eta}\cdot\vec{J})\times\vec{B}\Big] = - \pd{}{x}\left(\eta_yJ_yB_z - \eta_zJ_zB_y\right) - \pd{}{y}\left(\eta_zJ_zB_x - \eta_xJ_xB_z\right) - \pd{}{z}\left(\eta_xJ_xB_y - \eta_yJ_yB_x\right) \]

References

  • "The PLUTO Code for Adaptive Mesh Computations in Astrophysical Fluid Dynamics"
    Mignone et al, ApJS (2012) 198, 7M
Authors
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
T. Matsakos
Date
Feb 20, 2014

Definition in file res_flux.c.

Function Documentation

void ResistiveFlux ( Data_Arr  V,
Data_Arr  curlB,
double **  res_flux,
double **  dcoeff,
int  beg,
int  end,
Grid grid 
)

Compute resistive fluxes for the induction and energy equations. Also, compute the diffusion coefficient. Called by either ParabolicFlux or ParabolicRHS.

Parameters
[in]V3D data array of primitive variables
[out]res_fluxthe resistive fluxes
[out]dcoeffthe diffusion coefficients evaluated at cell interfaces
[in]beginitial index of computation
[in]endfinal index of computation
[in]gridpointer to an array of Grid structures.

Definition at line 52 of file res_flux.c.

68 {
69  int i, j, k, nv;
70  double *x1, *x2, *x3, scrh;
71  double eta[3], vp[NVAR], Jp[NVAR];
72  Data_Arr etas;
73  double ***Jx1, ***Jx2, ***Jx3;
74  double ***eta_x1, ***eta_x2, ***eta_x3;
75 
76  #ifdef STAGGERED_MHD
77  etas = GetStaggeredEta();
78  Jx1 = curlB[IDIR]; eta_x1 = etas[IDIR];
79  Jx2 = curlB[JDIR]; eta_x2 = etas[JDIR];
80  Jx3 = curlB[KDIR]; eta_x3 = etas[KDIR];
81  #endif
82 
83  x1 = grid[IDIR].x;
84  x2 = grid[JDIR].x;
85  x3 = grid[KDIR].x;
86 
87 /* -----------------------------------------------
88  Compute resistive flux for the induction
89  and energy equations
90  ----------------------------------------------- */
91 
92  if (g_dir == IDIR){
93 
94  j = g_j; k = g_k;
95  x1 = grid[IDIR].xr;
96  for (i = beg; i <= end; i++){
97 
98  /* -- interface values at (i+1/2, j, k) -- */
99 
100  for (nv = 0; nv < NVAR; nv++){
101  vp[nv] = 0.5*(V[nv][k][j][i] + V[nv][k][j][i + 1]);
102  }
103 
104  #ifdef STAGGERED_MHD
105  EXPAND( ; ,
106  Jp[KDIR] = AVERAGE_Y(Jx3,k,j-1,i); ,
107  Jp[JDIR] = AVERAGE_Z(Jx2,k-1,j,i);)
108 
109  EXPAND( ; ,
110  eta[KDIR] = AVERAGE_Y(eta_x3,k,j-1,i); ,
111  eta[JDIR] = AVERAGE_Z(eta_x2,k-1,j,i);)
112  #else
113  for (nv = 0; nv < 3; nv++) Jp[nv] = curlB[nv][k][j][i];
114  Resistive_eta (vp, x1[i], x2[j], x3[k], Jp, eta);
115  #endif
116 
117  EXPAND( ; ,
118  res_flux[i][BX2] = - eta[KDIR]*Jp[KDIR]; ,
119  res_flux[i][BX3] = eta[JDIR]*Jp[JDIR];)
120 
121  #if HAVE_ENERGY
122  res_flux[i][ENG] = EXPAND(0.0, + vp[BX2]*res_flux[i][BX2],
123  + vp[BX3]*res_flux[i][BX3]);
124  #endif
125 
126  /* -- store diffusion coefficient -- */
127 
128  EXPAND(dcoeff[i][BX1] = 0.0; ,
129  dcoeff[i][BX2] = eta[KDIR]; ,
130  dcoeff[i][BX3] = eta[JDIR];)
131  }
132 
133  }else if (g_dir == JDIR){
134 
135  i = g_i; k = g_k;
136  x2 = grid[JDIR].xr;
137  for (j = beg; j <= end; j++){
138 
139  /* -- interface value -- */
140 
141  for (nv = 0; nv < NVAR; nv++) {
142  vp[nv] = 0.5*(V[nv][k][j][i] + V[nv][k][j + 1][i]);
143  }
144 
145  #ifdef STAGGERED_MHD
146  EXPAND(Jp[KDIR] = AVERAGE_X(Jx3,k,j,i-1); ,
147  ; ,
148  Jp[IDIR] = AVERAGE_Z(Jx1,k-1,j,i);)
149 
150  EXPAND(eta[KDIR] = AVERAGE_Y(eta_x3,k,j,i-1); ,
151  ; ,
152  eta[IDIR] = AVERAGE_Z(eta_x1,k-1,j,i);)
153  #else
154  for (nv = 0; nv < 3; nv++) Jp[nv] = curlB[nv][k][j][i];
155  Resistive_eta (vp, x1[i], x2[j], x3[k], Jp, eta);
156  #endif
157 
158  EXPAND(res_flux[j][BX1] = eta[KDIR]*Jp[KDIR]; ,
159  ; ,
160  res_flux[j][BX3] = - eta[IDIR]*Jp[IDIR];)
161 
162  #if HAVE_ENERGY
163  res_flux[j][ENG] = EXPAND( vp[BX1]*res_flux[j][BX1],
164  + 0.0,
165  + vp[BX3]*res_flux[j][BX3]);
166  #endif
167 
168  /* -- store diffusion coefficient -- */
169 
170  EXPAND(dcoeff[j][BX1] = eta[KDIR]; ,
171  dcoeff[j][BX2] = 0.0; ,
172  dcoeff[j][BX3] = eta[IDIR];)
173  }
174 
175  }else if (g_dir == KDIR){
176 
177  i = g_i; j = g_j;
178  x3 = grid[KDIR].xr;
179  for (k = beg; k <= end; k++){
180 
181  /* -- interface value -- */
182 
183  for (nv = 0; nv < NVAR; nv++) {
184  vp[nv] = 0.5*(V[nv][k][j][i] + V[nv][k + 1][j][i]);
185  }
186 
187  #ifdef STAGGERED_MHD
188  Jp[JDIR] = AVERAGE_X(Jx2,k,j,i-1);
189  Jp[IDIR] = AVERAGE_Y(Jx1,k,j-1,i);
190 
191  eta[JDIR] = AVERAGE_X(eta_x2,k,j,i-1);
192  eta[IDIR] = AVERAGE_Y(eta_x1,k,j-1,i);
193  #else
194  for (nv = 0; nv < 3; nv++) Jp[nv] = curlB[nv][k][j][i];
195  Resistive_eta (vp, x1[i], x2[j], x3[k], Jp, eta);
196  #endif
197 
198  res_flux[k][BX1] = - eta[JDIR]*Jp[JDIR];
199  res_flux[k][BX2] = eta[IDIR]*Jp[IDIR];
200 
201  #if EOS != ISOTHERMAL
202  res_flux[k][ENG] = vp[BX1]*res_flux[k][BX1] + vp[BX2]*res_flux[k][BX2];
203  #endif
204 
205  /* -- store diffusion coefficient -- */
206 
207  EXPAND(dcoeff[k][BX1] = eta[JDIR]; ,
208  dcoeff[k][BX2] = eta[IDIR]; ,
209  dcoeff[k][BX3] = 0.0;)
210  }
211  }
212 }
#define AVERAGE_Z(q, k, j, i)
Definition: macros.h:258
double **** Data_Arr
Definition: pluto.h:492
double * xr
Definition: structs.h:81
tuple scrh
Definition: configure.py:200
static double *** eta[3]
Definition: res_functions.c:94
#define KDIR
Definition: pluto.h:195
#define AVERAGE_Y(q, k, j, i)
Definition: macros.h:257
int g_i
x1 grid index when sweeping along the x2 or x3 direction.
Definition: globals.h:82
#define IDIR
Definition: pluto.h:193
int g_dir
Specifies the current sweep or direction of integration.
Definition: globals.h:86
int g_j
x2 grid index when sweeping along the x1 or x3 direction.
Definition: globals.h:83
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
#define AVERAGE_X(q, k, j, i)
Definition: macros.h:256
double * x
Definition: structs.h:80
int g_k
x3 grid index when sweeping along the x1 or x2 direction.
Definition: globals.h:84
void Resistive_eta(double *v, double x1, double x2, double x3, double *J, double *eta)
Definition: res_eta.c:17
#define BX3
Definition: mod_defs.h:27
int i
Definition: analysis.c:2
#define BX1
Definition: mod_defs.h:25
#define BX2
Definition: mod_defs.h:26
#define JDIR
Definition: pluto.h:194
#define NVAR
Definition: pluto.h:609
#define HAVE_ENERGY
Definition: pluto.h:395

Here is the call graph for this function:

Here is the caller graph for this function: