[Developers] Adding C/C++ indexing functions for vector grid variables

Frank Loeffler knarf at cct.lsu.edu
Tue Dec 8 14:08:51 CST 2009


Hi,

On Fri, Dec 04, 2009 at 09:16:47PM -0800, Erik Schnetter wrote:
> Add functions CCTK_VectGF1D, CCTK_VectGF2D etc. and the corresponding 
> macros CCTK_VECTGFINDEX1D etc. that allow indexing into vector grid 
> variables.  Vector grid variables require an additional index, namely 
> the vector index.

static inline int CCTK_VECTGFINDEX2D (const cGH *GH, int i, int j, int n)
{
  return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*n));
}

This is effectively identical to

static inline int CCTK_GFINDEX3D (const cGH *GH, int i, int j, int k)
{
  return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*k));
}

It duplicates the code. However, simply calling CCTK_GFINDEX3D from
within CCTK_VECTGFINDEX2D might destroy the inline compiler
optimization.

What are the feelings about the following?

#define CCTK_VECTGFINDEX2D(GH,i,j,n) CCTK_GFINDEX3D(GH,i,j,n)

Frank

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://www.cactuscode.org/pipermail/developers/attachments/20091208/9d841837/attachment.bin 


More information about the Developers mailing list