PLUTO
mod_defs.h
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Module header file for relativistic MHD (RMHD).
5 
6  Set label, indexes and basic prototyping for the relativistic
7  MHD module.
8 
9  \authors A. Mignone (mignone@ph.unito.it)\n
10  C. Zanni (zanni@oato.inaf.it)\n
11  \date April 2, 2015
12 */
13 /* ///////////////////////////////////////////////////////////////////// */
14 
15 #ifndef RESISTIVE_RMHD
16  #define RESISTIVE_RMHD NO
17 #endif
18 
19 /* *********************************************************
20  Set flow variable indices.
21  Extra vector components, when not needed, point to the
22  last element (255) of the array stored by startup.c.
23  ********************************************************* */
24 
25 #define RHO 0
26 #define MX1 1
27 #define MX2 (COMPONENTS >= 2 ? 2: 255)
28 #define MX3 (COMPONENTS == 3 ? 3: 255)
29 #define BX1 (COMPONENTS + 1)
30 #define BX2 (COMPONENTS >= 2 ? (BX1+1): 255)
31 #define BX3 (COMPONENTS == 3 ? (BX1+2): 255)
32 
33 #if HAVE_ENERGY
34  #define ENG (2*COMPONENTS + 1)
35  #define PRS ENG
36 #endif
37 #if DIVB_CONTROL == DIV_CLEANING
38  #define PSI_GLM (2*COMPONENTS + 1 + HAVE_ENERGY)
39 #endif
40 
41 #define VX1 MX1
42 #define VX2 MX2
43 #define VX3 MX3
44 
45 #define NFLX (2 + 2*COMPONENTS + (DIVB_CONTROL == DIV_CLEANING))
46 
47 /* *********************************************************
48  Label the different waves in increasing order
49  following the number of vector components.
50 
51  IMPORTANT: the KPSI_GLMM & KPSI_GLMP modes are
52  present only in the MHD-GLM formulation.
53  We keep them at the END of the enumeration
54  so we can skip them in unnecessary loops.
55  Please do NOT change them !
56  ********************************************************* */
57 
58 enum KWAVES {
60 
61  #if DIVB_CONTROL != DIV_CLEANING
62  , KDIVB
63  #endif
64 
65  #if COMPONENTS >= 2
66  , KSLOWM, KSLOWP
67  #if COMPONENTS == 3
68  , KALFVM, KALFVP
69  #endif
70  #endif
71 
72  #if DIVB_CONTROL == DIV_CLEANING
74  #endif
75 };
76 
77 
78 /* ********************************************************************* */
79 /*! The Map_param structure is used to pass input/output arguments
80  during the conversion from conservative to primitive variables
81  operated by the ConsToPrim() function in the relativistic modules
82  (RHD and RMHD).
83  The output parameter, rho, W, lor and p, must be set at the end
84  of every root-finder routine (EnergySolve(), EntropySolve() and
85  PressureFix()).
86  Additionally, some of the input parameters must be re-computed in
87  EntropySolve() and PressureFix().
88  ********************************************************************* */
89 typedef struct MAP_PARAM{
90  double D; /**< Lab density (input). */
91  double sigma_c; /**< Conserved entropy (input). */
92  double E; /**< Total energy (input). */
93  double m2; /**< Square of total momentum (input). */
94  double S; /**< m<dot>B (input). */
95  double S2; /**< Square of S (input). */
96  double B2; /**< Square of magnetic field (input). */
97 
98  double rho; /**< proper density (output) */
99  double W; /**< D*h*lor (output). */
100  double lor; /**< Lorentz factor (output). */
101  double prs; /**< Thermal pressure (output). */
102 } Map_param;
103 
104 /* ******************************************************
105  Vector potential: these labels are and MUST only
106  be used in the STARTUP / INIT functions;
107  they're convenient in obtaining a discretization
108  that preserve divB since the beginning.
109  ****************************************************** */
110 
111 #define AX1 (NVAR + 1)
112 #define AX2 (NVAR + 2)
113 #define AX3 (NVAR + 3)
114 
115 #define AX AX1 /* backward compatibility */
116 #define AY AX2
117 #define AZ AX3
118 
119 /* *************************************************
120  Now define more convenient and user-friendly
121  pointer labels for geometry setting
122  ************************************************* */
123 
124 #if GEOMETRY == CYLINDRICAL
125 
126  #define iVR VX1
127  #define iVZ VX2
128  #define iVPHI VX3
129 
130  #define iMR MX1
131  #define iMZ MX2
132  #define iMPHI MX3
133 
134  #define iBR BX1
135  #define iBZ BX2
136  #define iBPHI BX3
137 
138 #endif
139 
140 #if GEOMETRY == POLAR
141 
142  #define iVR VX1
143  #define iVPHI VX2
144  #define iVZ VX3
145 
146  #define iMR MX1
147  #define iMPHI MX2
148  #define iMZ MX3
149 
150  #define iBR BX1
151  #define iBPHI BX2
152  #define iBZ BX3
153 
154 #endif
155 
156 #if GEOMETRY == SPHERICAL
157 
158  #define iVR VX1
159  #define iVTH VX2
160  #define iVPHI VX3
161 
162  #define iMR MX1
163  #define iMTH MX2
164  #define iMPHI MX3
165 
166  #define iBR BX1
167  #define iBTH BX2
168  #define iBPHI BX3
169 
170 #endif
171 
172 /* ******************************************************************
173  Module-specific symbolic constants (switches)
174  ****************************************************************** */
175 
176 #ifndef RMHD_FAST_EIGENVALUES
177  #define RMHD_FAST_EIGENVALUES NO /**< If set to YES, use approximate (and
178  faster) expressions when computing the
179  fast magnetosonic speed, see Sect. 3.3
180  of Del Zanna, A&A (2006), 473.
181  Solutions of quartic equation is avoided
182  and replace with upper bounds provided by
183  quadratic equation. */
184 #endif
185 
186 #ifndef RMHD_REDUCED_ENERGY
187  #define RMHD_REDUCED_ENERGY YES /**< By turning RMHD_REDUCED_ENERGY to YES,
188  we let PLUTO evolve the total energy
189  minus the mass density contribution. */
190 #endif
191 
192 /* ---- Function prototyping ---- */
194 int ConsToPrim (double **, double **, int, int, unsigned char *);
195 void PRIM_EIGENVECTORS (double *, double, double, double *, double **, double **);
196 int Eigenvalues (double *, double, double, double *);
197 int EntropySolve (Map_param *);
198 int EnergySolve (Map_param *);
199 int PressureFix (Map_param *);
200 
201 void Flux (double **, double **, double *, double **, double *, int, int);
202 void HLL_Speed (double **, double **, double *, double *, double *, double *,
203  double *, double *, int, int);
204 int MaxSignalSpeed (double **, double *, double *, double *, double *, int, int);
205 
206 void PrimToCons (double **, double **, int, int);
207 void VelocityLimiter (double *, double *, double *);
208 
209 int Magnetosonic (double *vp, double cs2, double h, double *lambda);
210 int QuarticSolve (double, double, double, double, double *);
211 int CubicSolve (double, double, double, double *);
212 
214 
215 
216 #if DIVB_CONTROL == EIGHT_WAVES
217  void POWELL_DIVB_SOURCE(const State_1D *, int, int, Grid *);
218  void HLL_DIVB_SOURCE (const State_1D *, double **, int, int, Grid *);
219 #elif DIVB_CONTROL == DIV_CLEANING
220  #include "MHD/GLM/glm.h"
221 #elif DIVB_CONTROL == CONSTRAINED_TRANSPORT
222  #include "MHD/CT/ct.h"
223 #endif
void Flux(double **, double **, double *, double **, double *, int, int)
Definition: fluxes.c:23
void VelocityLimiter(double *, double *, double *)
Definition: vel_limiter.c:16
int QuarticSolve(double, double, double, double, double *)
Definition: quartic.c:23
struct MAP_PARAM Map_param
int EnergySolve(Map_param *)
Definition: energy_solve.c:23
double m2
Square of total momentum (input).
Definition: mod_defs.h:89
double D
Lab density (input).
Definition: mod_defs.h:86
void PRIM_EIGENVECTORS(double *, double, double, double *, double **, double **)
void Riemann_Solver(const State_1D *, int, int, double *, Grid *)
Definition: pluto.h:489
int PressureFix(Map_param *)
Definition: pressure_fix.c:22
Riemann_Solver HLLC_Solver
Definition: mod_defs.h:106
void PrimToCons(double **, double **, int, int)
Definition: mappers.c:26
Riemann_Solver HLL_Linde_Solver
Definition: mod_defs.h:221
KWAVES
Definition: mod_defs.h:80
Header file for GLM Divergence Cleaning.
double S2
Square of S (input).
Definition: mod_defs.h:95
Header file for Constrained-Transport (CT) module.
void HLL_DIVB_SOURCE(const State_1D *, double **, int, int, Grid *)
Definition: source.c:53
int ConsToPrim(double **, double **, int, int, unsigned char *)
Definition: mappers.c:89
void Eigenvalues(double **, double *, double **, int, int)
Definition: eigenv.c:67
int Magnetosonic(double *vp, double cs2, double h, double *lambda)
Definition: eigenv.c:34
void HLL_Speed(double **, double **, double *, double *, double *, double *, int, int)
Definition: hll_speed.c:24
double rho
proper density (output)
Definition: mod_defs.h:91
int CubicSolve(double, double, double, double *)
Definition: structs.h:78
double W
D*h*lor (output).
Definition: mod_defs.h:92
double S
mB (input).
Definition: mod_defs.h:94
Riemann_Solver HLLD_Solver
Definition: mod_defs.h:221
double lor
Lorentz factor (output).
Definition: mod_defs.h:93
void MaxSignalSpeed(double **, double *, double *, double *, int, int)
Definition: eigenv.c:34
Riemann_Solver HLL_Solver
Definition: mod_defs.h:106
double prs
Thermal pressure (output).
Definition: mod_defs.h:94
int EntropySolve(Map_param *)
Definition: entropy_solve.c:21
Riemann_Solver LF_Solver
Definition: mod_defs.h:106
double sigma_c
Conserved entropy (input).
Definition: mod_defs.h:87
void POWELL_DIVB_SOURCE(const State_1D *, int, int, Grid *)
Definition: source.c:5
double B2
Square of magnetic field (input).
Definition: mod_defs.h:96
double E
Total energy (input).
Definition: mod_defs.h:88