diff options
Diffstat (limited to 'Auxiliary/Cactus/KrancNumericalTools/GenericFD/src')
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h | 28 | ||||
-rw-r--r-- | Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h | 39 |
2 files changed, 29 insertions, 38 deletions
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h index 401b4e0..ace83a0 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h @@ -43,18 +43,30 @@ extern "C" { #include "MathematicaCompat.h" #ifdef KRANC_C + + /* Grid function access */ + /* var is a pointer to a grid point, i,j,k are offsets with respect + to that point. + For example: KRANC_GFINDEX3D_OFFSET(&u[ind3d],-1,-1,0) */ +#ifndef VECTORISE + /* standard, thorn Vectors is not used */ + /* simple implementation */ + /* # define KRANC_GFOFFSET3D(var,i,j,k) ((var)[di*(i)+dj*(j)+dk*(k)]) */ + /* more efficient implementation for some compilers */ +# define KRANC_GFOFFSET3D(var,i,j,k) \ + (*(CCTK_REAL const*)&((char const*)(var))[cdi*(i)+cdj*(j)+cdk*(k)]) +#else + /* vectorised version */ +# define KRANC_GFOFFSET3D(var,i,j,k) \ + vec_loadu_maybe3((i),(j),(k), \ + *(CCTK_REAL const*)& \ + ((char const*)(var))[cdi*(i)+cdj*(j)+cdk*(k)]) +#endif + int sgn(CCTK_REAL x); int GenericFD_GetBoundaryWidth(cGH const * restrict const cctkGH); -#ifdef __cplusplus -// Define the restrict qualifier -# ifdef CCTK_CXX_RESTRICT -# undef restrict -# define restrict CCTK_CXX_RESTRICT -# endif -#endif - void GenericFD_GetBoundaryInfo(cGH const * restrict cctkGH, int const * restrict cctk_lsh, int const * restrict cctk_lssh, diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h index 18cbb7e..72a05f9 100644 --- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h +++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h @@ -38,42 +38,21 @@ #define ArcSin(x) (asin(x)) #define ArcCos(x) (acos(x)) #define ArcTan(x) (atan(x)) +#define ArcTan2(x,y) (atan2(y,x)) #define Sinh(x) (sinh(x)) #define Cosh(x) (cosh(x)) #define Tanh(x) (tanh(x)) +#define Csch(x) (1./sinh(x)) +#define Sech(x) (1./cosh(x)) -#if 0 - -/* TODO: use fma(x,y,z) to implement fmadd and friends? Note that fma - may be unsupported, or may be slow. */ - -/* #define fmadd(x,y,z) ((x)*(y)+(z)) */ -/* #define fmsub(x,y,z) ((x)*(y)-(z)) */ -/* #define fnmadd(x,y,z) (-(z)-(x)*(y)) */ -/* #define fnmsub(x,y,z) (+(z)-(x)*(y)) */ - -#define fpos(x) (+(x)) -#define fneg(x) (-(x)) -#define fmul(x,y) ((x)*(y)) -#define fdiv(x,y) ((x)/(y)) -#define fadd(x,y) ((x)+(y)) -#define fsub(x,y) ((x)-(y)) - -#define fmadd(x,y,z) (fadd(fmul(x,y),z)) -#define fmsub(x,y,z) (fsub(fmul(x,y),z)) -#define fnmadd(x,y,z) (fsub(fneg(z),fmul(x,y))) -#define fnmsub(x,y,z) (fsub(z,fmul(x,y))) - -#define kexp(x) (exp(x)) -#define kfabs(x) (fabs(x)) -#define kfmax(x,y) (fmax(x,y)) -#define kfmin(x,y) (fmin(x,y)) -#define klog(x) (log(x)) -#define kpow(x,y) (pow(x,y)) -#define ksqrt(x) (sqrt(x)) - +#ifdef KRANC_C +# define Sign(x) (copysign(1.0,(x))) +# define ToReal(x) ((CCTK_REAL)(x)) +#else +# define Sign(x) (sgn(x)) +# define ToReal(x) (real((x),kind(khalf))) #endif #ifdef KRANC_C |