diff options
Diffstat (limited to 'src/Hyperslab.c')
-rw-r--r-- | src/Hyperslab.c | 99 |
1 files changed, 49 insertions, 50 deletions
diff --git a/src/Hyperslab.c b/src/Hyperslab.c index 9c482e6..dd5f840 100644 --- a/src/Hyperslab.c +++ b/src/Hyperslab.c @@ -131,16 +131,6 @@ CCTK_FILEVERSION(CactusPUGH_PUGHSlab_Hyperslab_c) } -/*** local function prototypes ***/ -/* Gerd's routine to get 1D lines from a 3D array */ -int Hyperslab_CollectData1D (const cGH *GH, int vindex, int vtimelvl, - const int *origin, - const int *directions, - int downsampling, - int length, - void **hdata, - int *hsize, - int proc); /* routine to check parameters passed to the Hyperslab routines */ static const char *checkParameters (const cGH *GH, int vindex, int vtimelvl, int hdim, @@ -746,46 +736,6 @@ int Hyperslab_GetHyperslab (const cGH *GH, #endif - /* do some plausibility checks */ - errormsg = checkParameters (GH, vindex, vtimelvl, hdim, - global_origin, directions, extents, - downsample_, hdata, hsize); - - /* FIXME: hack for getting diagonals from 3D variables - This is calling Gerd's CollectData1D() routine which can - extract non-axis-parallel lines too but is fixed to 3D data. */ - if (errormsg && ! strcmp (errormsg, "Given normal vector isn't axis-parallel")) - { - int length; - - - /* get the info on the variable to extract a hyperslab from */ - CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo); - - if (hdim != 1 || vinfo.dim != 3) - { - CCTK_WARN (1, "Non-axis-parallel hyperslabs are supported as 1D lines " - "from 3D variables only"); - return (-1); - } - - length = extents[0]; - if (length > 0) - { - length--; - } - return (Hyperslab_CollectData1D (GH, vindex, vtimelvl, global_origin, - directions, downsample_[0], length, - hdata, hsize, target_proc)); - } - - /* immediately return in case of errors */ - if (errormsg) - { - CCTK_WARN (1, errormsg); - return (-1); - } - /* get processor information */ myproc = CCTK_MyProc (GH); nprocs = CCTK_nProcs (GH); @@ -812,6 +762,55 @@ int Hyperslab_GetHyperslab (const cGH *GH, /* get the info on the variable to extract a hyperslab from */ CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo); + /* do some plausibility checks */ + errormsg = checkParameters (GH, vindex, vtimelvl, hdim, + global_origin, directions, extents, + downsample_, hdata, hsize); + + /* FIXME: hack for getting diagonals from 3D variables */ + if (errormsg && ! strcmp (errormsg, "Given normal vector isn't axis-parallel")) + { + int mapping; + + + if (hdim != 1 || vinfo.dim != 3) + { + CCTK_WARN (1, "Non-axis-parallel hyperslabs are supported as diagonals " + "from non-staggered 3D variables only"); + return (-1); + } + + mapping = Hyperslab_DefineGlobalMappingByIndex (GH, vindex, 1, directions, + global_origin, extents, + downsample_, -1, + target_proc, NULL, hsize); + if (mapping < 0) + { + CCTK_WARN (1, "Failed to define hyperslab mapping for 3D diagonal"); + return (-1); + } + if (hsize[0] > 0) + { + *hdata = malloc (hsize[0] * CCTK_VarTypeSize (vinfo.vartype)); + retval = Hyperslab_Get (GH, mapping, vindex, 0, vinfo.vartype, *hdata); + } + else + { + *hdata = NULL; + retval = 0; + } + Hyperslab_FreeMapping (mapping); + + return (retval); + } + + /* immediately return in case of errors */ + if (errormsg) + { + CCTK_WARN (1, errormsg); + return (-1); + } + /* set the pointers to pass to Hyperslab_GetLocalHyperslab() */ if (nprocs == 1) { |