PLUTO  4.4-patch2
Data Structures | Functions
mod_defs.h File Reference

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

Go to the source code of this file.

Data Structures

struct  Map_param
 

Functions

int ConsToPrim (double **, double **, int, int, uint16_t *)
 
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 PrimEigenvectors (const State *, int, int)
 
void PrimToCons (double **, double **, int, int)
 
void PrimRHS (double *, double *, double, double, double *)
 
void PrimSource (const State *, double **, int, int, Grid *)
 
int RHD_EnergySolve (double *, double *)
 
int RHD_EntropySolve (double *, double *)
 
int RHD_PressureFix (double *, double *)
 
void VelocityLimiter (double *, double *, double *)
 

Detailed Description

Contains variable names and prototypes for the RHD module

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

Function Documentation

◆ 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.

◆ 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.
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

◆ RHD_EnergySolve()

int RHD_EnergySolve ( double *  u,
double *  v 
)
Parameters
[in,out]uarray of conservative variables (entropy will be redefined)
[out]varray of primitive variables
Returns
Error codes:
  • 0 = success
  • 1 = solution does not exist
  • 2 = negative pressure
  • 3 = inaccurate solution (debug only)
  • 4 = NaN

◆ RHD_EntropySolve()

int RHD_EntropySolve ( double *  u,
double *  v 
)

Convert the conservative variables {D, m, sigma_c} (where sigma_c = D*sigma is the conserved entropy) to primitive variable using a Newton-Raphson/Bisection scheme.

◆ RHD_PressureFix()

int RHD_PressureFix ( double *  uc,
double *  vc 
)
Returns
Error codes are:
  • 0 = success
  • 1 = v^2 > 1
  • 2 = too many iterations

◆ VelocityLimiter()

void VelocityLimiter ( double *  v,
double *  vp,
double *  vm 
)

Check whether the total reconstructed velocity is > 1 If a superluminal value occurs, flatten distribution.