aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgoodale <goodale@d60812e6-3970-4df4-986e-c251b06effeb>2001-06-29 14:02:02 +0000
committergoodale <goodale@d60812e6-3970-4df4-986e-c251b06effeb>2001-06-29 14:02:02 +0000
commite2e1eed3fae6ba2d1bf7304e3c33c7710a9602d4 (patch)
tree3ef689b99a98ddb8e99af88316d8ee5d81458179 /src
parent536fc971111676b96b215e947cf46b57e8dbf8a9 (diff)
Reduction for Grid Scalars. Weakly tested.
Tom git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHReduce/trunk@16 d60812e6-3970-4df4-986e-c251b06effeb
Diffstat (limited to 'src')
-rw-r--r--src/Reduction.c85
1 files changed, 83 insertions, 2 deletions
diff --git a/src/Reduction.c b/src/Reduction.c
index 6316a22..035b126 100644
--- a/src/Reduction.c
+++ b/src/Reduction.c
@@ -26,6 +26,9 @@ static int PUGH_ReductionGA (cGH *GH,
CCTK_REAL *outval,
reduction_fn_t reduction_fn);
+static int PUGH_ReductionScalar (cGH *GH, int index, int proc, CCTK_REAL *outval,
+ reduction_fn_t reduction_fn);
+
static int copy_real_to_outtype (int num_elems,
CCTK_REAL inarray [/* num_elems */],
int outtype,
@@ -208,8 +211,8 @@ int PUGH_ReductionGVs (cGH *GH,
break;
case CCTK_SCALAR:
- CCTK_WARN (1, "PUGH_ReductionGVs: Reducing scalars doesn't make sense");
- this_retval = -1;
+ this_retval = PUGH_ReductionScalar (GH, invars[i], proc, &result,
+ reduction_fn);
break;
default:
@@ -311,6 +314,84 @@ static int PUGH_ReductionGA (cGH *GH, int index, int proc, CCTK_REAL *outval,
return (retval);
}
+ /*@@
+ @routine PUGH_ReductionScalar
+ @date Fri Jun 29 15:35:01 2001
+ @author Tom Goodale
+ @desc
+ Reduction of a scalar GV.
+ Basically a copy of PUGH_ReductionGA cut down to the scalar case.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+ @var GH
+ @vdesc A CCTK GH
+ @vtype cGH *
+ @vio in
+ @vcomment
+
+ @endvar
+ @var index
+ @vdesc The GV index
+ @vtype int
+ @vio in
+ @vcomment
+
+ @endvar
+ @var proc
+ @vdesc The processor at which we desire the result
+ @vtype int
+ @vio in
+ @vcomment
+
+ @endvar
+ @var reduction_fn
+ @vdesc The function which does the actual reduction
+ @vtype reduction_fn_t
+ @vio in
+ @vcomment
+
+ @endvar
+
+ @returntype int
+ @returndesc
+ The return code of the reduction operator.
+ @endreturndesc
+@@*/
+static int PUGH_ReductionScalar (cGH *GH,
+ int index,
+ int proc,
+ CCTK_REAL *outval,
+ reduction_fn_t reduction_fn)
+{
+ int retval;
+
+ int num_points, from, to, iterator, points_per_dim, type;
+
+ void *data;
+
+ /* get the data for the current timelevel */
+ data = ((void ***) PUGH_pGH (GH)->variables)[index][0];
+
+ from = 0;
+ to = 1;
+ iterator = 1;
+ points_per_dim = 1;
+ type = CCTK_VarTypeI (index);
+
+ num_points = 1;
+
+ /* now do the reduction */
+ retval = reduction_fn (GH, proc, 1, &from, &to, &iterator,
+ &points_per_dim, num_points, 1, &type, &data,
+ 1, outval);
+
+ return retval;
+}
+
/*@@
@routine copy_real_to_outtype