PLUTO  4.0
 All Data Structures Files Functions Variables Enumerations Macros Pages
Data Structures | Macros | Variables
pluto.h File Reference

PLUTO main header file. More...

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include "definitions.h"
#include "MHD/mod_defs.h"
#include "prototypes.h"

Go to the source code of this file.

Data Structures

struct  Data
 
struct  State_1D
 
struct  Grid
 
struct  Time_Step
 
struct  Output
 
struct  RBox
 

Macros

#define MAX(a, b)   ( (a) >= (b) ? (a) : (b) )
 
#define MIN(a, b)   ( (a) <= (b) ? (a) : (b) )
 
#define ABS_MIN(a, b)   (fabs(a) < fabs(b) ? (a):(b))
 
#define DSIGN(x)   ( (x) >= 0.0 ? (1.0) : (-1.0))
 
#define NEW_GEOM   1
 
#define MAX_OUTPUT_TYPES   11
 
#define EXPAND(a, b, c)   a b c
 
#define SELECT(a, b, c)   c
 
#define D_EXPAND(a, b, c)   a b c
 
#define D_SELECT(a, b, c)   c
 
#define BOX_LOOP(B, k, j, i)
 
#define KELVIN   (g_unitVelocity*g_unitVelocity*CONST_amu/CONST_kB)
 
Bit flag labels.

The following macros define the bits that can be turned on or off in an unsigned char (= 1 byte = 8 bits) variable. Different bit flags allow to enable or disable certain actions in a given cell at different points in the code, see also flag.c. The 3D unsigned char ***flag array is used for bookeeping, in each zone (i,j,k), which bits are actually switched on or off. A simple bitwise operation is used to enable a flag, e.g., flag[k][j][i] |= FLAG_XXX . For instance, by turning the FLAG_HLL bit on, we have flag = 00000100 , while by also enabling the FLAG_SPLIT_CELL one has flag = 00010100 and so on.

#define FLAG_MINMOD   1
 
#define FLAG_FLAT   2
 
#define FLAG_HLL   4
 
#define FLAG_ENTROPY   8
 
#define FLAG_SPLIT_CELL   16
 
#define FLAG_INTERNAL_BOUNDARY   32
 
#define FLAG_BIT7   64
 
#define FLAG_BIT8   128
 
Spatial loop macros.

The following macros provide a compact way to perform 1D or multi-D loops in selected regions of the (local) computational domain. "BEG" and "END" refers to the leftmost or rightmost boundary region in the corresponding direction I, J or K. "DOM" is used for looping inside the computational domain (boundaries excluded) while "TOT" is used for looping inside the ghost zones.

#define IBEG_LOOP(i)   for ((i) = IBEG; (i)--; )
 
#define JBEG_LOOP(j)   for ((j) = JBEG; (j)--; )
 
#define KBEG_LOOP(k)   for ((k) = KBEG; (k)--; )
 
#define IEND_LOOP(i)   for ((i) = IEND + 1; (i) < NX1_TOT; (i)++)
 
#define JEND_LOOP(j)   for ((j) = JEND + 1; (j) < NX2_TOT; (j)++)
 
#define KEND_LOOP(k)   for ((k) = KEND + 1; (k) < NX3_TOT; (k)++)
 
#define IDOM_LOOP(i)   for ((i) = IBEG; (i) <= IEND; (i)++)
 
#define JDOM_LOOP(j)   for ((j) = JBEG; (j) <= JEND; (j)++)
 
#define KDOM_LOOP(k)   for ((k) = KBEG; (k) <= KEND; (k)++)
 
#define ITOT_LOOP(i)   for ((i) = 0; (i) < NX1_TOT; (i)++)
 
#define JTOT_LOOP(j)   for ((j) = 0; (j) < NX2_TOT; (j)++)
 
#define KTOT_LOOP(k)   for ((k) = 0; (k) < NX3_TOT; (k)++)
 
#define DOM_LOOP(k, j, i)   KDOM_LOOP(k) JDOM_LOOP(j) IDOM_LOOP(i)
 
#define TOT_LOOP(k, j, i)   KTOT_LOOP(k) JTOT_LOOP(j) ITOT_LOOP(i)
 
#define X1_BEG_LOOP(k, j, i)   KTOT_LOOP(k) JTOT_LOOP(j) IBEG_LOOP(i)
 
#define X2_BEG_LOOP(k, j, i)   KTOT_LOOP(k) JBEG_LOOP(j) ITOT_LOOP(i)
 
#define X3_BEG_LOOP(k, j, i)   KBEG_LOOP(k) JTOT_LOOP(j) ITOT_LOOP(i)
 
#define X1_END_LOOP(k, j, i)   KTOT_LOOP(k) JTOT_LOOP(j) IEND_LOOP(i)
 
#define X2_END_LOOP(k, j, i)   KTOT_LOOP(k) JEND_LOOP(j) ITOT_LOOP(i)
 
#define X3_END_LOOP(k, j, i)   KEND_LOOP(k) JTOT_LOOP(j) ITOT_LOOP(i)
 
#define TRANSVERSE_LOOP(indx, in, i, j, k)
 
Constant physical value macros.

The following set of macros express some useful physical constants in c.g.s units (erg, cm and sec). Values have been taken from http://physic.nist.gov/cuu/Constants/index.html

#define CONST_PI   3.14159265358979
 
#define CONST_amu   1.66053886e-24
 
#define CONST_mp   1.67262171e-24
 
#define CONST_mn   1.67492728e-24
 
#define CONST_me   9.1093826e-28
 
#define CONST_mH   1.6733e-24
 
#define CONST_kB   1.3806505e-16
 
#define CONST_sigma   5.67051e-5
 
#define CONST_sigmaT   6.6524e-25
 
#define CONST_NA   6.0221367e23
 
#define CONST_c   2.99792458e10
 
#define CONST_Msun   2.e33
 
#define CONST_Rsun   6.96e10
 
#define CONST_Mearth   5.9736e27
 
#define CONST_Rearth   6.378136e8
 
#define CONST_G   6.6726e-8
 
#define CONST_h   6.62606876e-27
 
#define CONST_pc   3.0856775807e18
 
#define CONST_ly   0.9461e18
 
#define CONST_au   1.49597892e13
 
#define CONST_eV   1.602176463158e-12
 

Variables

int prank
 
long int IBEG
 
long int IEND
 
long int JBEG
 
long int JEND
 
long int KBEG
 
long int KEND
 
long int NX1
 
long int NX2
 
long int NX3
 
long int NX1_TOT
 
long int NX2_TOT
 
long int NX3_TOT
 
long int NMAX_POINT
 
int * g_i
 
int * g_j
 
int * g_k
 
int g_dir
 
int g_maxRiemannIter
 
long int g_usedMem
 
long int g_stepNumber
 
int g_intStage
 
double g_unitDensity
 
double g_unitLength
 
double g_unitVelocity
 
double g_maxCoolingRate
 
double g_minCoolingTemp
 
double g_smallDensity
 
double g_smallPressure
 
double g_time
 
double g_dt
 
double g_maxMach
 
double g_domBeg [3]
 
double g_domEnd [3]
 
double g_inputParam [32]
 

Detailed Description

Contains basic macro definitions, structure definitions and global variable declarations used by the code.

Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Aug 16, 2012

Macro Definition Documentation

#define ABS_MIN (   a,
 
)    (fabs(a) < fabs(b) ? (a):(b))

Return the number with the smaller absolute value.

#define BOX_LOOP (   B,
  k,
  j,
 
)
Value:
for ((B)->dk = ((k=(B)->kb) <= (B)->ke ? 1:-1); k != (B)->ke+(B)->dk; k += (B)->dk)\
for ((B)->dj = ((j=(B)->jb) <= (B)->je ? 1:-1); j != (B)->je+(B)->dj; j += (B)->dj)\
for ((B)->di = ((i=(B)->ib) <= (B)->ie ? 1:-1); i != (B)->ie+(B)->di; i += (B)->di)

The BOX_LOOP() macro implements a loop over (i,j,k) in a rectangular portion of the domain with indices defined by the RBox structure B. The loop increments (di,dj,dk) are members of the structure which are here initialized to either 1 or -1 depending on whether the lower corner index lies below or above the upper index (e.g. B->ib <= B->ie or not).

#define CONST_amu   1.66053886e-24

Atomic mass unit.

#define CONST_au   1.49597892e13

Astronomical unit.

#define CONST_c   2.99792458e10

Speed of Light.

#define CONST_eV   1.602176463158e-12

Electron Volt in erg.

#define CONST_G   6.6726e-8

Gravitational Constant.

#define CONST_h   6.62606876e-27

Planck Constant.

#define CONST_kB   1.3806505e-16

Boltzmann constant.

#define CONST_ly   0.9461e18

Light year.

#define CONST_me   9.1093826e-28

Electron mass.

#define CONST_Mearth   5.9736e27

Earth Mass.

#define CONST_mH   1.6733e-24

Hydrogen atom mass.

#define CONST_mn   1.67492728e-24

Neutron mass.

#define CONST_mp   1.67262171e-24

Proton mass.

#define CONST_Msun   2.e33

Solar Mass.

#define CONST_NA   6.0221367e23

Avogadro Contant.

#define CONST_pc   3.0856775807e18

Parsec.

#define CONST_PI   3.14159265358979

$ \pi $.

#define CONST_Rearth   6.378136e8

Earth Radius.

#define CONST_Rsun   6.96e10

Solar Radius.

#define CONST_sigma   5.67051e-5

Stephan Boltmann constant.

#define CONST_sigmaT   6.6524e-25

Thomson Cross section.

#define D_EXPAND (   a,
  b,
 
)    a b c

Similar to the EXPAND() macro but the expansion depends on DIMENSIONS.

#define D_SELECT (   a,
  b,
 
)    c

Expand only the 1st, 2nd or 3rd argument based on the value of DIMENSIONS.

#define DSIGN (   x)    ( (x) >= 0.0 ? (1.0) : (-1.0))

Return the sign of x.

#define EXPAND (   a,
  b,
 
)    a b c

Allows to write dimension-independent code by expanding as many arguments as the value of COMPONENTS. The result is that only the first argument will be expanded in 1D, the first two arguments in 2D and all of them in 3D.

#define FLAG_ENTROPY   8

Update pressure using entropy equation.

#define FLAG_FLAT   2

Reconstruct using FLAT limiter.

#define FLAG_HLL   4

Use HLL Riemann solver.

#define FLAG_INTERNAL_BOUNDARY   32

Zone belongs to an internal boundary region and should be excluded from being updated in time

#define FLAG_MINMOD   1

Reconstruct using MINMOD limiter.

#define FLAG_SPLIT_CELL   16

Zone is covered by a finer level (AMR only).

Define the conversion constant between dimensionless temperature prs/rho and physical temperature in Kelvin, T = (prs/rho)*KELVIN*mu

#define MAX (   a,
 
)    ( (a) >= (b) ? (a) : (b) )

Return the maximum between two numbers.

#define MAX_OUTPUT_TYPES   11

The maximum number of output file formats is fixed to 11 so that the size of runtime structure (defined below) is 64 bytes. This should prevent, for some compilers, attempts to change the alignment of the structure and therefore troubleshooting when restarting from files written on different architectures.

#define MIN (   a,
 
)    ( (a) <= (b) ? (a) : (b) )

Return the minimum between two numbers.

#define NEW_GEOM   1

If this macro is defined, use the geometrical cell-center in place of the cell-center in CYLINDRICAL geometry. The cell-center used to be the default in PLUTO 3.1 but lead to spurious features on the symmetry axis.

#define SELECT (   a,
  b,
 
)    c

Expand only the 1st, 2nd or 3rd argument based on the value of COMPONENTS.

Variable Documentation

int g_dir

Specifies the current sweep or direction of integration. Its value is set usually in the time stepping functions and can take the values

  • IDIR, for integration in the X1 dir;
  • JDIR, for integration in the X2 dir;
  • KDIR, for integration in the X3 dir;
double g_domBeg[3]

Lower limits of the computational domain.

double g_domEnd[3]

Upper limits of the computational domain.

double g_dt

The current integration time step.

int* g_i

Pointer to the x1 grid index when sweeping along the x2 or x3 directions. Set by the TRANSVERSE_LOOP() macro.

double g_inputParam[32]

Array containing the user-defined parameters. The index names of this array are defined in definitions.h through the python interface.

int g_intStage

Gives the current integration stage of the time stepping method (predictor = 0, 1st corrector = 1, and so on).

int * g_j

Pointer to the x2 grid index when sweeping along the x1 or x3 directions. Set by the TRANSVERSE_LOOP() macro.

int * g_k

Pointer to the x3 grid index when sweeping along the x1 or x2 directions. Set by the TRANSVERSE_LOOP() macro.

double g_maxCoolingRate

The maximum fractional variation due to cooling from one step to the next.

double g_maxMach

The maximum Mach number computed during integration.

int g_maxRiemannIter

Maximum number of iterations for iterative Riemann Solver.

double g_minCoolingTemp

The minimum temperature (in K) below which cooling is suppressed.

double g_smallDensity

Small value for density fix.

double g_smallPressure

Small value for pressure fix.

long int g_stepNumber

Gives the current integration step number.

double g_time

The current integration time.

double g_unitDensity

Unit density in gr/cm^3.

double g_unitLength

Unit Legnth in cm.

double g_unitVelocity

Unit velocity in cm/sec.

long int g_usedMem

Amount of used memory in bytes.

long int IBEG

Lower grid index of the computational domain in the the X1 direction for the local processor.

long int IEND

Upper grid index of the computational domain in the the X1 direction for the local processor.

long int JBEG

Lower grid index of the computational domain in the the X2 direction for the local processor.

long int JEND

Upper grid index of the computational domain in the the X2 direction for the local processor.

long int KBEG

Lower grid index of the computational domain in the the X3 direction for the local processor.

long int KEND

Upper grid index of the computational domain in the the X3 direction for the local processor.

long int NMAX_POINT

Maximum number of points among the three directions, boundaries excluded.

long int NX1

Number of interior zones in the X1 directions (boundaries excluded) for the local processor.

long int NX1_TOT

Total number of zones in the X1 direction (boundaries included) for the local processor.

long int NX2

Number of interior zones in the X2 directions (boundaries excluded) for the local processor.

long int NX2_TOT

Total number of zones in the X2 direction (boundaries included) for the local processor.

long int NX3

Number of interior zones in the X3 directions (boundaries excluded) for the local processor.

long int NX3_TOT

Total number of zones in the X3 direction (boundaries included) for the local processor.

int prank

Processor rank. In serial mode it is defined to be 0.