aboutsummaryrefslogtreecommitdiff
path: root/Auxiliary
diff options
context:
space:
mode:
authorSteve Brandt <sbrandt@sbrandt-think.cct.lsu.edu>2012-05-03 16:23:20 -0500
committerSteve Brandt <sbrandt@sbrandt-think.cct.lsu.edu>2012-05-03 16:23:20 -0500
commit74dbb92ec39325a4a73a2b508ffc291521b92e5e (patch)
tree68e057642ed885ef89e110be87a991e3cd4cedf3 /Auxiliary
parent3994abad3de76227fb94e324d7b0d2599a61bcf1 (diff)
parent56a871e790cff27e8e971ccbe48ff3954c66ee54 (diff)
Merge branch 'master' of github.com:ianhinder/Kranc
Diffstat (limited to 'Auxiliary')
-rw-r--r--Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c10
-rw-r--r--Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h15
-rw-r--r--Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h4
3 files changed, 16 insertions, 13 deletions
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c
index 1bd1a61..023e6e8 100644
--- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c
+++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.c
@@ -49,16 +49,6 @@
/* TODO: provide functions for differencing, use FD macros to evaluate
corresponding functions */
-int sgn(CCTK_REAL x)
-{
- if (x < 0)
- return -1;
- else if (x > 0)
- return 1;
- else
- return 0;
-}
-
void GenericFD_GetBoundaryWidths(cGH const * restrict const cctkGH, int nboundaryzones[6])
{
int is_internal[6];
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h
index 53e8035..6e3ed2b 100644
--- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h
+++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/GenericFD.h
@@ -30,6 +30,8 @@
#include "cctk.h"
+#include <math.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -54,7 +56,18 @@ extern "C" {
#define KRANC_GFOFFSET3D(var,i,j,k) \
(*(CCTK_REAL const*)&((char const*)(var))[cdi*(i)+cdj*(j)+cdk*(k)])
-int sgn(CCTK_REAL x);
+/* Implement the signum function, used for Mathematica's Sign function */
+
+#ifdef __CUDACC__
+#define KRANC_WHERE __device__
+#else
+#define KRANC_WHERE
+#endif
+
+KRANC_WHERE static inline CCTK_REAL sgn(CCTK_REAL x)
+{
+ return x==(CCTK_REAL)0.0 ? (CCTK_REAL)0.0 : copysign((CCTK_REAL)1.0, x);
+}
int GenericFD_GetBoundaryWidth(cGH const * restrict const cctkGH);
diff --git a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h
index 252116c..28bcebc 100644
--- a/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h
+++ b/Auxiliary/Cactus/KrancNumericalTools/GenericFD/src/MathematicaCompat.h
@@ -40,11 +40,11 @@
#define Csch(x) (1.0/sinh(x))
#define Coth(x) (1.0/tanh(x))
+#define Sign(x) (sgn(x))
+
#ifdef KRANC_C
-# define Sign(x) (copysign( (CCTK_REAL) 1.0,(CCTK_REAL) (x)))
# define ToReal(x) ((CCTK_REAL)(x))
#else
-# define Sign(x) (sgn(x))
# define ToReal(x) (real((x),kind(khalf)))
#endif