aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@10716dce-81a3-4424-a2c8-48026a0d3035>2000-11-29 00:59:05 +0000
committertradke <tradke@10716dce-81a3-4424-a2c8-48026a0d3035>2000-11-29 00:59:05 +0000
commit7ee1d9d98121b398b6b654cc2ec213d35804bbbb (patch)
tree8436005abc49fa78455935370484d9841b892338
parente847b302bfa4329eb6e5630d05eae0942cd701bb (diff)
Fixed the inconsistent passing of the hyperslab directions vector.
Now the directions are passed in as a set of N-dimensional vectors, one for each dimension of the hyperslab, and N being the dimension of the variable to extract the hyperslab from. That means nothing changes for 1D hyperslabs where you still pass in one vector (the direction vector). But eg. for 2D you now have to pass 2 vectors (the direction vectors spawning the hyperslab). I decided still to use integers for the vector components so you give it in units (of grid points). This also allows arbitrary hyperslab specifications although PUGHSlab can only do orthogonal hyperslabs. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHSlab/trunk@45 10716dce-81a3-4424-a2c8-48026a0d3035
-rw-r--r--src/NewHyperslab.c153
-rw-r--r--src/NewPUGHSlab.h41
2 files changed, 106 insertions, 88 deletions
diff --git a/src/NewHyperslab.c b/src/NewHyperslab.c
index 7e86a21..ecf6fba 100644
--- a/src/NewHyperslab.c
+++ b/src/NewHyperslab.c
@@ -46,14 +46,38 @@ CCTK_FILEVERSION(CactusPUGH_PUGHSlab_Hyperslab_c)
/*** prototypes of routines defined in this source file ***/
/* routine to check parameters passed to the Hyperslab routines */
+int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
+ int hdim, int htype,
+ PUGHSlab_conversion_fn conversion_fn,
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
+ void **hdata,
+ int hsize[/* hdim */],
+ int hsize_global[/* hdim */],
+ int hoffset_global[/* hdim */]);
+int NewHyperslab_GetHyperslab (cGH *GH,
+ int target_proc,
+ int vindex,
+ int vtimelvl,
+ int hdim,
+ int htype,
+ PUGHSlab_conversion_fn conversion_fn,
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
+ void **hdata,
+ int hsize[/* hdim */]);
static const char *checkParameters (cGH *GH, int vindex, int vtimelvl,
int hdim,
- const int global_startpoint[/*vdim*/],
- const int directions[/*vdim*/],
- const int extents[/*hdim*/],
- const int downsample_[/*hdim*/],
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
void **hdata,
- int hsize[/*hdim*/]);
+ int hsize[/* hdim */]);
/*** external routines ***/
/* Gerd's routine to get 1D lines from a 3D array */
@@ -111,12 +135,7 @@ int Hyperslab_CollectData1D (cGH *GH, int vindex, int vtimelvl,
@endvar
@var directions
@vdesc directions which span the hyperslab
- This is the direction vector for 1D hyperslabs,
- or the normal vector of the 2 lowest dimensions
- for hyperslabs of higher dimensions.
- If the hyperslab is of same dimensionality as the variable
- the directions vector is ignored.
- @vtype const int[dimensions of vindex]
+ @vtype const int[hdim times dimensions of vindex]
@vio in
@endvar
@var extents
@@ -156,14 +175,14 @@ int Hyperslab_CollectData1D (cGH *GH, int vindex, int vtimelvl,
int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
int hdim, int htype,
PUGHSlab_conversion_fn conversion_fn,
- const int global_startpoint[/*vdim*/],
- const int directions[/*vdim*/],
- const int extents[/*hdim*/],
- const int downsample_[/*hdim*/],
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
void **hdata,
- int hsize[/*hdim*/],
- int hsize_global[/*hdim*/],
- int hoffset_global[/*hdim*/])
+ int hsize[/* hdim */],
+ int hsize_global[/* hdim */],
+ int hoffset_global[/* hdim */])
{
int *point; /* looper over hyperslab dimensions */
int *startpoint, /* hyperslab's local start and endpoint */
@@ -245,26 +264,12 @@ int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
points_per_dim = point + 7*vinfo.dim;
/* get the actual directions in which to spawn the hyperslab */
- /* Note: hdim == 1 the normal vector is the directions vector itself
- hdim < vdim the normal vector is the negated directions vector
- hdim == vdim the normal vector is completely ignored,
- and all directions are selected */
- if (hdim == 1)
- {
- memcpy (do_dir, directions, vinfo.dim * sizeof (int));
- }
- else if (hdim < vinfo.dim)
- {
- for (vdim = 0; vdim < vinfo.dim; vdim++)
- {
- do_dir[vdim] = ! directions[vdim];
- }
- }
- else
+ memcpy (do_dir, directions, vinfo.dim * sizeof (int));
+ for (i = 1; i < hdim; i++)
{
for (vdim = 0; vdim < vinfo.dim; vdim++)
{
- do_dir[vdim] = 1;
+ do_dir[vdim] |= directions[i * vinfo.dim + vdim];
}
}
@@ -441,14 +446,17 @@ int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
hdata_size = CCTK_VarTypeSize (htype);
/* allocate the buffer for the hyperslab data */
- *hdata = malloc (totals * hdata_size);
- typed_hdata = (char *) (*hdata);
+ *hdata = malloc (totals * hdata_size);
+ typed_hdata = (char *) (*hdata);
- /* get the number of hyperslab points in lowest dimension,
- their size in bytes,
- and the byte offset between adjacent points in the source array */
- dim0_points = (endpoint[0] - startpoint[0]) / downsample[0];
- dim0_hsize = dim0_points * hdata_size;
+ /* get the number of hyperslab points in lowest dimension
+ and their size in bytes */
+ dim0_points = (endpoint[0] - startpoint[0]) / downsample[0];
+ if ((endpoint[0] - startpoint[0]) % downsample[0])
+ {
+ dim0_points++;
+ }
+ dim0_hsize = dim0_points * hdata_size;
/* transform the ranges into byte ranges */
for (i = 0; i < vinfo.dim; i++)
@@ -601,12 +609,7 @@ int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
@endvar
@var directions
@vdesc directions which span the hyperslab
- This is the direction vector for 1D hyperslabs,
- or the normal vector of the 2 lowest dimensions
- for hyperslabs of higher dimensions.
- If the hyperslab is of same dimensionality as the variable
- the directions vector is ignored.
- @vtype const int[dimensions of vindex]
+ @vtype const int[hdim times dimensions of vindex]
@vio in
@endvar
@var extents
@@ -632,14 +635,19 @@ int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
@vio out
@endvar
@@*/
-int NewHyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl,
- int hdim, int htype, PUGHSlab_conversion_fn conversion_fn,
- const int global_startpoint[/*vdim*/],
- const int directions[/*vdim*/],
- const int extents[/*hdim*/],
- const int downsample_[/*hdim*/],
+int NewHyperslab_GetHyperslab (cGH *GH,
+ int target_proc,
+ int vindex,
+ int vtimelvl,
+ int hdim,
+ int htype,
+ PUGHSlab_conversion_fn conversion_fn,
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
void **hdata,
- int hsize[/*hdim*/])
+ int hsize[/* hdim */])
{
int myproc, nprocs; /* processor identification */
int retval; /* the return value */
@@ -997,14 +1005,14 @@ int NewHyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelv
/********************** local routines ************************************/
static const char *checkParameters (cGH *GH, int vindex, int vtimelvl,
int hdim,
- const int global_startpoint[/*vdim*/],
- const int directions[/*vdim*/],
- const int extents[/*hdim*/],
- const int downsample_[/*hdim*/],
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
void **hdata,
- int hsize[/*hdim*/])
+ int hsize[/* hdim */])
{
- int dim; /* looper */
+ int i, vdim; /* looper */
int num_directions; /* number of non-zero directions */
cGroup vinfo; /* variable's group info */
@@ -1027,13 +1035,13 @@ static const char *checkParameters (cGH *GH, int vindex, int vtimelvl,
}
/* check the extent and downsample parameters */
- for (dim = 0; dim < hdim; dim++)
+ for (vdim = 0; vdim < hdim; vdim++)
{
- if (extents[dim] == 0)
+ if (extents[vdim] == 0)
{
return ("Invalid hyperslab extent parameters");
}
- if (downsample_[dim] <= 0)
+ if (downsample_[vdim] <= 0)
{
return ( "Invalid hyperslab downsample parameters");
}
@@ -1052,29 +1060,28 @@ static const char *checkParameters (cGH *GH, int vindex, int vtimelvl,
}
/* check the hyperslab dimension */
- if (hdim < 0 || hdim > vinfo.dim)
+ if (hdim <= 0 || hdim > vinfo.dim)
{
return ("Invalid hyperslab dimension");
}
- /* check the direction(s) of the hyperslab
- if it is less-dimensional than the variable */
- if (hdim != vinfo.dim)
+ /* check the direction(s) of the hyperslab */
+ for (i = 0; i < hdim; i++)
{
- for (dim = 0, num_directions = 0; dim < vinfo.dim; dim++)
+ for (vdim = 0, num_directions = 0; vdim < vinfo.dim; vdim++)
{
- if (directions[dim])
+ if (directions[i * vinfo.dim + vdim])
{
num_directions++;
}
}
if (num_directions == 0)
{
- return ("Given normal vector is a null vector");
+ return ("Given direction vector is a null vector");
}
- if (num_directions > 1)
+ if (num_directions != 1)
{
- return ("Given normal vector isn't orthogonal");
+ return ("Given direction vector isn't orthogonal");
}
}
diff --git a/src/NewPUGHSlab.h b/src/NewPUGHSlab.h
index a531682..a61c611 100644
--- a/src/NewPUGHSlab.h
+++ b/src/NewPUGHSlab.h
@@ -17,21 +17,32 @@ typedef void (*PUGHSlab_conversion_fn) (void *hdata,
/* function prototypes */
-int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
- int hdim, int htype, PUGHSlab_conversion_fn copy_fn,
- const int global_startpoint [/*vdim*/],
- const int directions [/*vdim*/],
- const int lengths [/*hdim*/],
- const int downsample_ [/*hdim*/],
+int NewHyperslab_GetLocalHyperslab (cGH *GH,
+ int vindex,
+ int vtimelvl,
+ int hdim,
+ int htype,
+ PUGHSlab_conversion_fn copy_fn,
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim * vdim */],
+ const int lengths[/* hdim */],
+ const int downsample_[/* hdim */],
void **hdata,
- int hsize [/*hdim*/], int ghsize [/*hdim*/],
- int hoffset [/*hdim*/]);
-int NewHyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl,
- int hdim, int htype, PUGHSlab_conversion_fn copy_fn,
- const int global_startpoint [/*vdim*/],
- const int directions [/*vdim*/],
- const int lengths [/*hdim*/],
- const int downsample_ [/*hdim*/],
- void **hdata, int hsize [/*hdim*/]);
+ int hsize[/* hdim */],
+ int hsize_global[/* hdim */],
+ int hoffset_global[/* hdim */]);
+int NewHyperslab_GetHyperslab (cGH *GH,
+ int target_proc,
+ int vindex,
+ int vtimelvl,
+ int hdim,
+ int htype,
+ PUGHSlab_conversion_fn copy_fn,
+ const int global_startpoint [/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int lengths[/* hdim */],
+ const int downsample_[/* hdim */],
+ void **hdata,
+ int hsize[/* hdim */]);
PUGHSlab_conversion_fn PUGHSlab_GetDatatypeConversionFn (int vtype, int htype);