PLUTO
macros.h File Reference

PLUTO header file for function-like macros. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BOX_LOOP(B, k, j, i)
 
#define FOR_EACH(nv, beg, list)
 
#define INT_FLOOR(z)    ((int)((z) + 32768.) - 32768)
 
#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 MINMOD(a, b)   ((a)*(b) > 0.0 ? (fabs(a) < fabs(b) ? (a):(b)):0.0)
 
#define VAN_LEER(a, b)   ((a)*(b) > 0.0 ? 2.0*(a)*(b)/((a)+(b)):0.0)
 
#define MC(a, b)   (MINMOD(0.5*((a)+(b)), 2.0*MINMOD((a),(b))))
 
#define SWAP_VAR(x)   SwapEndian(&x, sizeof(x));
 
#define QUIT_PLUTO(e_code)    exit(e_code);
 
#define WARNING(a)   a
 
#define DOT_PRODUCT(a, b)   (EXPAND((a)[0]*(b)[0], + (a)[1]*(b)[1], + (a)[2]*(b)[2]))
 
#define VAR_LOOP(n)    for ((n) = NVAR; (n)--; )
 
#define DIM_LOOP(d)    for ((d) = 0; (d) < DIMENSIONS; (d)++)
 
#define FDIFF_X1(b, k, j, i)   (b[k][j][i+1] - b[k][j][i])
 
#define FDIFF_X2(b, k, j, i)   (b[k][j+1][i] - b[k][j][i])
 
#define FDIFF_X3(b, k, j, i)   (b[k+1][j][i] - b[k][j][i])
 
#define CDIFF_X1(b, k, j, i)   0.5*(b[k][j][i+1] - b[k][j][i-1])
 
#define CDIFF_X2(b, k, j, i)   0.5*(b[k][j+1][i] - b[k][j-1][i])
 
#define CDIFF_X3(b, k, j, i)   0.5*(b[k+1][j][i] - b[k-1][j][i])
 
#define AVERAGE_X(q, k, j, i)    0.5*(q[k][j][i] + q[k][j][i+1])
 
#define AVERAGE_Y(q, k, j, i)    0.5*(q[k][j][i] + q[k][j+1][i])
 
#define AVERAGE_Z(q, k, j, i)    0.5*(q[k][j][i] + q[k+1][j][i])
 
#define AVERAGE_XY(q, k, j, i)
 
#define AVERAGE_XZ(q, k, j, i)
 
#define AVERAGE_YZ(q, k, j, i)
 
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. The *BEG_LOOP and *END_LOOP macros are used to loop in the leftmost or rightmost boundary ghost zones in the corresponding direction I, J or K. The *DOM_LOOP macros are used to loop inside the computational domain (boundaries excluded) while the *TOT_LOOP macros are used to loop across the entire domain (inside+boundary).

#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, ip, i, j, k)
 

Detailed Description

PLUTO header file for function-like macros.

Author
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
July 31, 2014

Definition in file macros.h.

Macro Definition Documentation

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

Return the number with the smaller absolute value.

Definition at line 107 of file macros.h.

#define AVERAGE_X (   q,
  k,
  j,
  i 
)    0.5*(q[k][j][i] + q[k][j][i+1])

Definition at line 256 of file macros.h.

#define AVERAGE_XY (   q,
  k,
  j,
  i 
)
Value:
0.25*( q[k][j][i] + q[k][j][i+1] \
+ q[k][j+1][i] + q[k][j+1][i+1])
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
int i
Definition: analysis.c:2
static Runtime q

Definition at line 260 of file macros.h.

#define AVERAGE_XZ (   q,
  k,
  j,
  i 
)
Value:
0.25*( q[k][j][i] + q[k][j][i+1] \
+ q[k+1][j][i] + q[k+1][j][i+1])
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
int i
Definition: analysis.c:2
static Runtime q

Definition at line 262 of file macros.h.

#define AVERAGE_Y (   q,
  k,
  j,
  i 
)    0.5*(q[k][j][i] + q[k][j+1][i])

Definition at line 257 of file macros.h.

#define AVERAGE_YZ (   q,
  k,
  j,
  i 
)
Value:
0.25*( q[k][j][i] + q[k][j+1][i] \
+ q[k+1][j][i] + q[k+1][j+1][i])
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
int i
Definition: analysis.c:2
static Runtime q

Definition at line 264 of file macros.h.

#define AVERAGE_Z (   q,
  k,
  j,
  i 
)    0.5*(q[k][j][i] + q[k+1][j][i])

Definition at line 258 of file macros.h.

#define BOX_LOOP (   B,
  k,
  j,
  i 
)
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)
int j
Definition: analysis.c:2
int k
Definition: analysis.c:2
int i
Definition: analysis.c:2

The BOX_LOOP() macro implements a loop over (i,j,k) in a rectangular portion of the domain with indices defined by the (pointer to) 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).

Definition at line 70 of file macros.h.

#define CDIFF_X1 (   b,
  k,
  j,
  i 
)    0.5*(b[k][j][i+1] - b[k][j][i-1])

Definition at line 240 of file macros.h.

#define CDIFF_X2 (   b,
  k,
  j,
  i 
)    0.5*(b[k][j+1][i] - b[k][j-1][i])

Definition at line 241 of file macros.h.

#define CDIFF_X3 (   b,
  k,
  j,
  i 
)    0.5*(b[k+1][j][i] - b[k-1][j][i])

Definition at line 242 of file macros.h.

#define DIM_LOOP (   d)    for ((d) = 0; (d) < DIMENSIONS; (d)++)

Definition at line 227 of file macros.h.

#define DOM_LOOP (   k,
  j,
  i 
)    KDOM_LOOP(k) JDOM_LOOP(j) IDOM_LOOP(i)

Definition at line 42 of file macros.h.

#define DOT_PRODUCT (   a,
 
)    (EXPAND((a)[0]*(b)[0], + (a)[1]*(b)[1], + (a)[2]*(b)[2]))

Definition at line 222 of file macros.h.

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

Return the sign of x.

Definition at line 110 of file macros.h.

#define FDIFF_X1 (   b,
  k,
  j,
  i 
)    (b[k][j][i+1] - b[k][j][i])

Definition at line 236 of file macros.h.

#define FDIFF_X2 (   b,
  k,
  j,
  i 
)    (b[k][j+1][i] - b[k][j][i])

Definition at line 237 of file macros.h.

#define FDIFF_X3 (   b,
  k,
  j,
  i 
)    (b[k+1][j][i] - b[k][j][i])

Definition at line 238 of file macros.h.

#define FOR_EACH (   nv,
  beg,
  list 
)
Value:
for ((list)->i = beg, nv = (list)->indx[beg]; \
(list)->i < (list)->nvar; \
nv = (list)->indx[++((list)->i)])
int i
Definition: analysis.c:2

The FOR_EACH(p, beg, intList) macro implements a loop over the elements of the array intList->indx starting at beg (in a similar way to Python lists).

Example:

1 intList list;
2 list.nvar = 3;
3 list.indx[0] = 2;
4 list.indx[1] = 5;
5 list.indx[2] = 17;
6 FOR_EACH(nv, 0, list) printf ("value is = %d\n",nv);

Definition at line 89 of file macros.h.

#define IBEG_LOOP (   i)    for ((i) = IBEG; (i)--; )

Definition at line 26 of file macros.h.

#define IDOM_LOOP (   i)    for ((i) = IBEG; (i) <= IEND; (i)++)

Definition at line 34 of file macros.h.

#define IEND_LOOP (   i)    for ((i) = IEND + 1; (i) < NX1_TOT; (i)++)

Definition at line 30 of file macros.h.

#define INT_FLOOR (   z)    ((int)((z) + 32768.) - 32768)

Faster implementation than stdlib floor() function. It returns the largest integer value less than or equal to z.

Definition at line 98 of file macros.h.

#define ITOT_LOOP (   i)    for ((i) = 0; (i) < NX1_TOT; (i)++)

Definition at line 38 of file macros.h.

#define JBEG_LOOP (   j)    for ((j) = JBEG; (j)--; )

Definition at line 27 of file macros.h.

#define JDOM_LOOP (   j)    for ((j) = JBEG; (j) <= JEND; (j)++)

Definition at line 35 of file macros.h.

#define JEND_LOOP (   j)    for ((j) = JEND + 1; (j) < NX2_TOT; (j)++)

Definition at line 31 of file macros.h.

#define JTOT_LOOP (   j)    for ((j) = 0; (j) < NX2_TOT; (j)++)

Definition at line 39 of file macros.h.

#define KBEG_LOOP (   k)    for ((k) = KBEG; (k)--; )

Definition at line 28 of file macros.h.

#define KDOM_LOOP (   k)    for ((k) = KBEG; (k) <= KEND; (k)++)

Definition at line 36 of file macros.h.

#define KEND_LOOP (   k)    for ((k) = KEND + 1; (k) < NX3_TOT; (k)++)

Definition at line 32 of file macros.h.

#define KTOT_LOOP (   k)    for ((k) = 0; (k) < NX3_TOT; (k)++)

Definition at line 40 of file macros.h.

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

Return the maximum between two numbers.

Definition at line 101 of file macros.h.

#define MC (   a,
 
)    (MINMOD(0.5*((a)+(b)), 2.0*MINMOD((a),(b))))

Definition at line 114 of file macros.h.

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

Return the minimum between two numbers.

Definition at line 104 of file macros.h.

#define MINMOD (   a,
 
)    ((a)*(b) > 0.0 ? (fabs(a) < fabs(b) ? (a):(b)):0.0)

Definition at line 112 of file macros.h.

#define QUIT_PLUTO (   e_code)    exit(e_code);

Exit macro. For Chombo it is defined elsewhere.

Definition at line 125 of file macros.h.

#define SWAP_VAR (   x)    SwapEndian(&x, sizeof(x));

Definition at line 115 of file macros.h.

#define TOT_LOOP (   k,
  j,
  i 
)    KTOT_LOOP(k) JTOT_LOOP(j) ITOT_LOOP(i)

Definition at line 44 of file macros.h.

#define TRANSVERSE_LOOP (   indx,
  ip,
  i,
  j,
  k 
)
Value:
if (g_dir == IDIR) {ip = &i; indx.pt1 = &j; indx.pt2 = &k;} \
if (g_dir == JDIR) {ip = &j; indx.pt1 = &i; indx.pt2 = &k;} \
if (g_dir == KDIR) {ip = &k; indx.pt1 = &i; indx.pt2 = &j;} \
for (*(indx.pt2) = indx.t2_beg; *(indx.pt2) <= indx.t2_end; *(indx.pt2) += 1) \
for (*(indx.pt1) = indx.t1_beg; *(indx.pt1) <= indx.t1_end; *(indx.pt1) += 1)
#define KDIR
Definition: pluto.h:195
#define IDIR
Definition: pluto.h:193
int g_dir
Specifies the current sweep or direction of integration.
Definition: globals.h:86
int j
Definition: analysis.c:2
if(divB==NULL)
Definition: analysis.c:10
int k
Definition: analysis.c:2
int i
Definition: analysis.c:2
#define JDIR
Definition: pluto.h:194

Definition at line 54 of file macros.h.

#define VAN_LEER (   a,
 
)    ((a)*(b) > 0.0 ? 2.0*(a)*(b)/((a)+(b)):0.0)

Definition at line 113 of file macros.h.

#define VAR_LOOP (   n)    for ((n) = NVAR; (n)--; )

Definition at line 226 of file macros.h.

#define WARNING (   a)    a

Definition at line 217 of file macros.h.

#define X1_BEG_LOOP (   k,
  j,
  i 
)    KTOT_LOOP(k) JTOT_LOOP(j) IBEG_LOOP(i)

Definition at line 46 of file macros.h.

#define X1_END_LOOP (   k,
  j,
  i 
)    KTOT_LOOP(k) JTOT_LOOP(j) IEND_LOOP(i)

Definition at line 50 of file macros.h.

#define X2_BEG_LOOP (   k,
  j,
  i 
)    KTOT_LOOP(k) JBEG_LOOP(j) ITOT_LOOP(i)

Definition at line 47 of file macros.h.

#define X2_END_LOOP (   k,
  j,
  i 
)    KTOT_LOOP(k) JEND_LOOP(j) ITOT_LOOP(i)

Definition at line 51 of file macros.h.

#define X3_BEG_LOOP (   k,
  j,
  i 
)    KBEG_LOOP(k) JTOT_LOOP(j) ITOT_LOOP(i)

Definition at line 48 of file macros.h.

#define X3_END_LOOP (   k,
  j,
  i 
)    KEND_LOOP(k) JTOT_LOOP(j) ITOT_LOOP(i)

Definition at line 52 of file macros.h.