From ac6c858f8f2c9969d50f9a747766c97dd24c316d Mon Sep 17 00:00:00 2001 From: tradke Date: Fri, 28 Dec 2001 21:26:13 +0000 Subject: Set slice centers to zero for dimensions with no coordinates. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOUtil/trunk@144 b32723a9-ab3a-4a60-88e2-2e5d99d7c17a --- src/Utils.c | 78 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/Utils.c b/src/Utils.c index c17a8f1..7abec4d 100644 --- a/src/Utils.c +++ b/src/Utils.c @@ -118,60 +118,60 @@ int IOUtil_1DLines (const cGH *GH, { for (dim = 0; dim < num_dims; dim++) { - slice_center[dir][dim] = -1; + slice_center[dir][dim] = 0; } } - retval=-1; + retval = -1; } /* now set the slice center for each line according to origin_index[] or origin_phys[] */ - if (!retval) + if (! retval) { for (dir = 0; dir < num_dims; dir++) { for (dim = 0; dim < num_dims; dim++) { - if (dim == dir) - { - /* line always starts at the first point */ - slice_center[dir][dim] = 0; - } - else if (origin_index && origin_index[dir][dim] >= 0) - { - /* FIXME: check upper index bounds also ?? */ - slice_center[dir][dim] = origin_index[dir][dim]; - } - else if (lower_range[dim] > origin_phys[dir][dim] || - upper_range[dim] < origin_phys[dir][dim]) - { - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "IOUtil_1DLines: %c-coordinate for slice center of 1D " - "lines in %c-direction (%f) is out of grid coordinates " - "range (%f, %f)", - 'x' + dim, 'x' + dir, (double) origin_phys[dir][dim], - (double) lower_range[dim], (double) upper_range[dim]); - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "IOUtil_1DLines: no 1D %c-line output will be written for " - "%dD variables with this slice center default", - 'x' + dir, num_dims); - - slice_center[dir][dim] = -1; - } - else - { - /* Find index for first point above the chosen coordinate */ - slice_center[dir][dim] = - ceil ((origin_phys[dir][dim] - lower_range[dim]) / - GH->cctk_delta_space[dim] - 1e-6); + if (dim == dir) + { + /* line always starts at the first point */ + slice_center[dir][dim] = 0; + } + else if (origin_index && origin_index[dir][dim] >= 0) + { + /* FIXME: check upper index bounds also ?? */ + slice_center[dir][dim] = origin_index[dir][dim]; + } + else if (lower_range[dim] > origin_phys[dir][dim] || + upper_range[dim] < origin_phys[dir][dim]) + { + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOUtil_1DLines: %c-coordinate for slice center of 1D " + "lines in %c-direction (%f) is out of grid coordinates " + "range (%f, %f)", + 'x' + dim, 'x' + dir, (double) origin_phys[dir][dim], + (double) lower_range[dim], (double) upper_range[dim]); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOUtil_1DLines: no 1D %c-line output will be written for " + "%dD variables with this slice center default", + 'x' + dir, num_dims); + + slice_center[dir][dim] = -1; + } + else + { + /* Find index for first point above the chosen coordinate */ + slice_center[dir][dim] = + ceil ((origin_phys[dir][dim] - lower_range[dim]) / + GH->cctk_delta_space[dim] - 1e-6); #ifdef DEBUG_IOUTIL - printf("spxyz for %c-coord of lines in %c-direction is %d\n", - 'x' + dim,'x' + dir, slice_center[dir][dim]); + printf("spxyz for %c-coord of lines in %c-direction is %d\n", + 'x' + dim,'x' + dir, slice_center[dir][dim]); #endif - } + } } } } @@ -179,7 +179,7 @@ int IOUtil_1DLines (const cGH *GH, /* free allocated resources */ free (lower_range); - return retval; + return (retval); } -- cgit v1.2.3