next up previous contents
Next: Examples Up: Using ADM Macros Previous: Fortran   Contents

C

If you are using the macros inside a C function then you must define the grid-function subscripting index ijk, which can be found from i, j and k using the macro CCTK_GFINDEX3D(cctkGH,i,j,k). Of course, since ijk depends on i, j and k, you have to assign ijk its value inside the loop-over-grid-points loops.

You must also define the grid-function strides di, dj and dk to give the grid-function subscripting index offsets of the grid points $(i+1,j,k)$, $(i,j+1,k)$, and $(i,j,k+1)$ (respectively) relative to $(i,j,k)$. That is, you should define di = 1, dj = cctk_lsh[0], and dk = cctk_lsh[0]*cctk_lsh[1]. Since these don't depend on i, j and k, they can be assigned values once outside the loop-over-grid-points loops.

The C example below should make this clear(er).

Note that you should assign all these variables their values before #includeing the <MACRONAME>_guts.h macro (it may do calculations which use these values).