PLUTO  4.4-patch2
Functions
mod_defs.h File Reference

Set labels, indexes and prototypes for the HD module. More...

Go to the source code of this file.

Functions

int ConsToPrim (double **, double **, int, int, uint16_t *)
 
void Eigenvalues (double **, double *, double **, int, int)
 
void PrimEigenvectors (const State *, int, int)
 
void ConsEigenvectors (double *, double *, double, double **, double **, double *)
 
void Flux (const State *, int, int)
 
void HLL_Speed (const State *, const State *, double *, double *, int, int)
 
void MaxSignalSpeed (const State *, double *, double *, int, int)
 
void PrimToCons (double **, double **, int, int)
 
void PrimRHS (double *, double *, double, double, double *)
 
void PrimSource (const State *, double **, int, int, Grid *)
 

Detailed Description

Contains variable names and prototypes for the HD module

Author
A. Mignone (migno.nosp@m.ne@t.nosp@m.o.inf.nosp@m.n.it)
Date
Dec 2, 2020

Function Documentation

◆ ConsEigenvectors()

void ConsEigenvectors ( double *  u,
double *  v,
double  a2,
double **  Lc,
double **  Rc,
double *  lambda 
)

Provide conservative eigenvectors for HD equations.

Parameters
[in]uarray of conservative variables
[in]varray of primitive variables
[in]a2square of sound speed
[out]LLleft conservative eigenvectors
[out]RRright conservative eigenvectors
[out]lambdaeigenvalues

References:

  • "Riemann Solvers and Numerical Methods for Fluid Dynamics",
    Toro, 1997 Springer-Verlag (Page 107)

Provide conservative eigenvectors for MHD equations.

Parameters
[in]uarray of conservative variables
[in]varray of primitive variables
[in]a2square of sound speed
[out]Lcleft conservative eigenvectors
[out]Rcright conservative eigenvectors
[out]lambdaeigenvalues

Reference

  • "High-order conservative finite difference GLM-MHD schemes for cell-centered MHD"
    Mignone, Tzeferacos & Bodo, JCP (2010) 229, 5896
  • "A High-order WENO Finite Difference Scheme for the Equations of Ideal MHD"
    Jiang,Wu, JCP 150,561 (1999)

With the following corrections:

The components (By, Bz) of L_{1,7} page 571 should be +{rho}a instead of -. Also, since Bx is not considered as a parameter, one must also add a component in the fast and slow waves. This can be seen by forming the conservative eigenvectors from the primitive ones, see the paper from Powell, Roe Linde.

The Lc_{1,3,5,7}[Bx] components, according to Serna 09 are -(1-g_gamma)*a_{f,s}*Bx and not (1-g_gamma)*a_{f,s}*Bx. Both are orthonormal though. She is WRONG! -Petros-

◆ ConsToPrim()

int ConsToPrim ( double **  ucons,
double **  uprim,
int  beg,
int  end,
uint16_t *  flag 
)

Convert from conservative to primitive variables.

Parameters
[in]uconsarray of conservative variables
[out]uprimarray of primitive variables
[in]begstarting index of computation
[in]endfinal index of computation
[in,out]flagarray of flags tagging, in input, zones where entropy must be used to recover pressure and, on output, zones where conversion was not successful.
Returns
Return 0 if conversion was successful in all zones in the range [ibeg,iend]. Return 1 if one or more zones could not be converted correctly and either pressure, density or energy took non-physical values.

◆ Eigenvalues()

void Eigenvalues ( double **  v,
double *  cs2,
double **  lambda,
int  beg,
int  end 
)

Compute eigenvalues for the HD equations

Parameters
[in]v1-D array of primitive variables
[out]csound21-D array containing the square of sound speed
[out]lambda1-D array [i][nv] containing the eigenvalues
[in]begstarting index of computation
[in]endfinal index of computation

Compute eigenvalues for the MHD equations

Parameters
[in]v1-D array of primitive variables
[out]csound21-D array containing the square of sound speed
[out]lambda1-D array [i][nv] containing the eigenvalues
[in]begstarting index of computation
[in]endfinal index of computation

Provide eigenvalues for the MHD equations

◆ Flux()

void Flux ( const State state,
int  beg,
int  end 
)
Parameters
[in,out]statePointer to a state structure
[in]beginitial index of computation
[in]endfinal index of computation
Returns
This function has no return value.

Compute the component of the flux tensor normal to the direction of integration.

Parameters
[in,out]statePointer to a state structure
[in]beginitial index of computation
[in]endfinal index of computation
Returns
This function has no return value.

◆ HLL_Speed()

void HLL_Speed ( const State stateL,
const State stateR,
double *  SL,
double *  SR,
int  beg,
int  end 
)

Compute leftmost (SL) and rightmost (SR) speeds for the Riemann fan.

Parameters
[in]stateLpointer to a state structure for the left state
[in]stateRpointer to a state structure for the right state
[out]SLthe (estimated) leftmost speed of the Riemann fan
[out]SRthe (estimated) rightmost speed of the Riemann fan
[in]begstarting index of computation
[in]endfinal index of computation

Switches:

ROE_ESTIMATE (YES/NO), DAVIS_ESTIMATE (YES/NO). TVD_ESTIMATE (YES/NO) JAN_HLL (YES/NO)

These switches set how the wave speed estimates are going to be computed. Only one can be set to 'YES', and the rest of them must be set to 'NO'

ROE_ESTIMATE: b_m = (0, (u_R - c_R, u_L - c_L, u_{roe} - c_{roe})) b_m = (0, (u_R + c_R, u_L + c_L, u_{roe} + c_{roe}))

where u_{roe} and c_{roe} are computed using Roe averages.

DAVIS_ESTIMATE: b_m = (0, (u_R - c_R, u_L - c_L)) b_m = (0, (u_R + c_R, u_L + c_L))

Compute leftmost (SL) and rightmost (SR) speeds for the Riemann fan.

Parameters
[in]stateLpointer to a state structure for the left state
[in]stateRpointer to a state structure for the right state
[out]SLthe (estimated) leftmost speed of the Riemann fan
[out]SRthe (estimated) rightmost speed of the Riemann fan
[in]begstarting index of computation
[in]endfinal index of computation

Switches:

ROE_ESTIMATE (YES/NO), DAVIS_ESTIMATE (YES/NO)

These switches set how the wave speed estimates are going to be computed. Only one can be set to 'YES', and the rest of them must be set to 'NO'

ROE_ESTIMATE: b_m = (0, (u_R - c_R, u_L - c_L, u_{roe} - c_{roe})) b_m = (0, (u_R + c_R, u_L + c_L, u_{roe} + c_{roe}))

where u_{roe} and c_{roe} are computed using Roe averages.

DAVIS_ESTIMATE: b_m = (0, (u_R - c_R, u_L - c_L)) b_m = (0, (u_R + c_R, u_L + c_L))

Compute leftmost (SL) and rightmost (SR) speeds for the Riemann fan.

Parameters
[in]stateLpointer to a state structure for the left state
[in]stateRpointer to a state structure for the right state
[out]SLthe (estimated) leftmost speed of the Riemann fan
[out]SRthe (estimated) rightmost speed of the Riemann fan
[in]begstarting index of computation
[in]endfinal index of computation

◆ MaxSignalSpeed()

void MaxSignalSpeed ( const State state,
double *  cmin,
double *  cmax,
int  beg,
int  end 
)

Compute the maximum and minimum characteristic velocities for the HD equations from the vector of primitive variables state->v.

Parameters
[in]statepointer to a State structure
[out]cmin1-D array containing the leftmost characteristic
[out]cmin1-D array containing the rightmost characteristic
[in]begstarting index of computation
[in]endfinal index of computation

Compute the maximum and minimum characteristic velocities for the MHD equations, cmin= v - cf, cmax = v + cf

Parameters
[in]statepointer to a State structure
[out]cmin1-D array containing the leftmost characteristic
[out]cmin1-D array containing the rightmost characteristic
[in]begstarting index of computation
[in]endfinal index of computation

Return the rightmost (cmax) and leftmost (cmin) wave propagation speed in the Riemann fan

Compute the maximum and minimum propagation speeds for the RHD equations.

Parameters
[in]statepointer to a State structure
[out]cmin1-D array containing the leftmost characteristic
[out]cmin1-D array containing the rightmost characteristic
[in]begstarting index of computation
[in]endfinal index of computation

◆ PrimEigenvectors()

void PrimEigenvectors ( const State state,
int  beg,
int  end 
)

Provide left and right eigenvectors and corresponding eigenvalues for the primitive form of the HD equations (adiabatic, pvte & isothermal cases).

Parameters
[in]statepointer to a State structure
[in]begstarting index of computation
[in]endfinal index of computation
Note
It is highly recommended that state->LL and state->RR be initialized to zero BEFORE since only non-zero entries are treated here.

Wave names and their order are defined as enumeration constants in mod_defs.h.

Advection modes associated with passive scalars are simple cases for which lambda = u (entropy mode) and l = r = (0, ... , 1, 0, ...). For this reason they are NOT defined here and must be treated seperately.

References:

  • "Riemann Solvers and Numerical Methods for Fluid Dynamics",
    Toro, 1997 Springer-Verlag, Eq. [3.18]

Provide left and right eigenvectors and corresponding eigenvalues for the PRIMITIVE form of the MHD equations (adiabatic & isothermal cases).

Parameters
[in,out]statePointer to State structure
[in]begstarting grid index
[in]endfinal grid index
Note
Eigenvectors state->Lp and state->Rp must be initialized to zero before since only non-zero entries are treated here.

Wave names and their order are defined as enumeration constants in mod_defs.h. Notice that, the characteristic decomposition may differ depending on the way div.B is treated.

Advection modes associated with passive scalars are simple cases for which lambda = u (entropy mode) and l = r = (0, ... , 1, 0, ...). For this reason they are NOT defined here and must be treated seperately.

References:

  • "Notes on the Eigensystem of Magnetohydrodynamics",
    P.L. Roe, D.S. Balsara, SIAM Journal on Applied Mathematics, 56, 57 (1996)
  • "A solution adaptive upwind scheme for ideal MHD",
    K. G. Powell, P. L. Roe, and T. J. Linde, Journal of Computational Physics, 154, 284-309, (1999).
  • "A second-order unsplit Godunov scheme for cell-centered MHD: the CTU-GLM scheme"
    Mignone & Tzeferacos, JCP (2010) 229, 2117
  • "ATHENA: A new code for astrophysical MHD", J. Stone, T. Gardiner, ApJS, 178, 137 (2008)

The derivation of the isothermal eigenvectors follows the consideration given in roe.c

Provide eigenvectors eigenvalues of the relativistic equations in primitive form.

Parameters
[in,out]statePointer to State structure
[in]begstarting grid index
[in]endfinal grid index

Only non-zero components of LL and RR are computed; RR and LL must be initialized to zero outside.

◆ PrimRHS()

void PrimRHS ( double *  w,
double *  dw,
double  cs2,
double  h,
double *  Adw 
)

Compute the matrix-vector multiplication $ A(\mathbf{v})\cdot d\mathbf{v} $ where A is the matrix of the quasi-linear form of the MHD equations.

References

  • "A solution adaptive upwind scheme for ideal MHD", Powell et al., JCP (1999) 154, 284
  • "An unsplit Godunov method for ideal MHD via constrained transport" Gardiner & Stone, JCP (2005) 205, 509
Parameters
[in]vvector of primitive variables
[in]dvlimited (linear) slopes
[in]cs2local sound speed
[in]hlocal enthalpy
[out]AdVmatrix-vector product
Returns
This function has no return value.

Compute the matrix-vector multiplication $ A(\mathbf{v})\cdot \Delta\mathbf{v} $ where A is the matrix of the quasi-linear form of the RHD equations.

Parameters
[in]wvector of primitive variables;
[in]dwlimited (linear) slopes;
[in]cs2local sound speed;
[in]hlocal enthalpy;
[out]Adwmatrix-vector product.
Note
Returns
This function has no return value.

◆ PrimSource()

void PrimSource ( const State state,
double **  src,
int  beg,
int  end,
Grid grid 
)

Compute source terms of the MHD equations in primitive variables. These include:

  • Geometrical sources;
  • Shearing-box terms
  • Gravity;
  • terms related to divergence of B control (Powell eight wave and GLM);
  • FARGO source terms.

The rationale for choosing during which sweep a particular source term has to be incorporated should match the same criterion used during the conservative update. For instance, in polar or cylindrical coordinates, curvilinear source terms are included during the radial sweep only.

Parameters
[in]gaspointer to a Sweep structure
[out]srcarray of source terms
[in]beginitial index of computation
[in]endfinal index of computation
[in]gridpointer to a Grid structure
Note
This function does not work in spherical coordinates yet. For future implementations we annotate hereafter the induction equation in spherical coordinates:

\[ \partial_tB_r + \frac{1}{r}\partial_\theta E_\phi - \frac{1}{r\sin\theta}\partial_\phi E_\theta = -E_\phi\cot\theta/r \]

\[ \partial_t B_\theta + \frac{1}{r\sin\theta}\partial_\phi E_r - \partial_rE_\phi = E_\phi/r \]

\[ \partial_t B_\phi + \partial_r E_\theta - \frac{1}{r}\partial_\theta E_r = - E_\theta/r\]

where

\[ E_\phi = -(v \times B)_\phi = - (v_r B_\theta - v_\theta B_r) \,,\qquad E_\theta = -(v \times B)_\theta = - (v_\phi B_r - v_r B_\phi) \]

Compute source terms of the RHD equations in primitive variables.

  • Geometrical sources;
  • Gravity;

The rationale for choosing during which sweep a particular source term has to be incorporated should match the same criterion used during the conservative update. For instance, in polar or cylindrical coordinates, curvilinear source terms are included during the radial sweep only.

Parameters
[in]statepointer to a Sweep structure
[out]srcarray of source terms
[in]beginitial index of computation
[in]endfinal index of computation
[in]gridpointer to a Grid structure

◆ PrimToCons()

void PrimToCons ( double **  uprim,
double **  ucons,
int  ibeg,
int  iend 
)

Convert primitive variables to conservative variables.

Parameters
[in]uprimarray of primitive variables
[out]uconsarray of conservative variables
[in]begstarting index of computation
[in]endfinal index of computation

Convert primitive variables in conservative variables.

Parameters
[in]uprimarray of primitive variables
[out]uconsarray of conservative variables
[in]begstarting index of computation
[in]endfinal index of computation

Convert a vector of primitive quantities to conservative