| "Operator.c": "/*@@\n @file Operator.c\n @date Tue Apr 15 18:22:45 1997\n @author Paul Walker\n @desc\n Definition of interpolation operators for regular uniform grids.\n @enddesc\n\n @history\n @date Sun Jul 04 1999\n @author Thomas Radke\n @hdesc conversion to Cactus 4.0 (copied from pughGetPoints.c)\n @date Wed 31 Jan 2001\n @author Thomas Radke\n @hdesc translation of fortran interpolators into C\n @date 22 Jan 2002\n @author Jonathan Thornburg\n @hdesc Move all local-interpolation code from LocalInterp to here\n @endhistory\n\n @version $Id$\n @@*/\n\n#include <stdlib.h>\n#include <math.h>\n#include <string.h>\n\n#include \"cctk.h\"\n#include \"cctk_Parameters.h\"\n#include \"util_ErrorCodes.h\"\n#include \"util_Table.h\"\n#include \"Interpolate.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Header$\";\nCCTK_FILEVERSION(CactusBase_LocalInterp_Operator_c)\n\n\n/********************************************************************\n ******************** External Routines ************************\n ********************************************************************/\nint LocalInterp_InterpLocalUniform (int num_dims,\n int table,\n /***** coordinate system *****/\n const CCTK_REAL coord_origin[],\n const CCTK_REAL coord_delta[],\n /***** interpolation points *****/\n int num_interp_points,\n int interp_coords_type_code,\n const void *const interp_coords[],\n /***** input arrays *****/\n int num_input_arrays,\n const CCTK_INT input_array_dims[],\n const CCTK_INT input_array_type_codes[],\n const void *const input_arrays[],\n /***** output arrays *****/\n int num_output_arrays,\n const CCTK_INT output_array_type_codes[],\n void *const output_arrays[])\n{\n int iterator, retval;\n char key[128];\n CCTK_INT order, type, nelems;\n\n\n /* check for invalid arguments */\n if (num_dims < 0 || num_interp_points < 0 ||\n num_input_arrays < 0 || num_output_arrays < 0)\n {\n return (UTIL_ERROR_BAD_INPUT);\n }\n\n /* this interpolation operator computes one output array per input array */\n if (num_input_arrays != num_output_arrays)\n {\n CCTK_WARN (1, \"Number of input arrays must match number of output arrays\");\n return (UTIL_ERROR_BAD_INPUT);\n }\n\n if (interp_coords_type_code != CCTK_VARIABLE_REAL)\n {\n CCTK_WARN (1, \"Interpolation coordinates must be of type CCTK_REAL\");\n return (UTIL_ERROR_BAD_INPUT);\n }\n\n /* check if there's anything to do at all */\n if (num_dims == 0 || num_input_arrays == 0)\n {\n return (0);\n }\n\n\n /* get the interpolation order from the user-supplied parameter table */\n order = 1;\n if (table >= 0)\n {\n /* loop through all table options */\n for (iterator = Util_TableItCreate (table);\n Util_TableItQueryIsNonNull (iterator) > 0 &&\n Util_TableItQueryKeyValueInfo (iterator, sizeof (key), key, &type,\n &nelems) > 0;\n Util_TableItAdvance (iterator))\n {\n if (CCTK_Equals (key, \"order\"))\n {\n if (type == CCTK_VARIABLE_INT && nelems == 1)\n {\n Util_TableGetInt (table, &order, \"order\");\n }\n else\n {\n CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Invalid value for option 'order' in interpolation \"\n \"parameter options table \"\n \"(must be CCTK_INT scalar value)\");\n }\n }\n else if (CCTK_Equals (key, \"N_boundary_points_to_omit\") ||\n CCTK_Equals (key, \"boundary_off_centering_tolerance\") ||\n CCTK_Equals (key, \"boundary_extrapolation_tolerance\") ||\n CCTK_Equals (key, \"per_point_status\") ||\n CCTK_Equals (key, \"local_interpolator_status\"))\n {\n /* warn about unsupported options */\n CCTK_VWarn (4, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Option with key '%s' in interpolation parameter options \"\n \"table is not not supported (will be ignored)\", key);\n }\n else if (CCTK_Equals (key, \"input_array_time_levels\"))\n {\n /* silently ignore options which are meant for the global\n interpolator only */\n }\n else\n {\n /* warn about other options */\n CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Found option with unrecognized key '%s' in interpolation \"\n \"parameter options table (will be ignored)\", key);\n }\n }\n Util_TableItDestroy (iterator);\n }\n\n /* call the interpolator function */\n retval = LocalInterp_Interpolate (order, num_interp_points, num_dims,\n num_output_arrays, input_array_dims,\n (const CCTK_REAL *const *) interp_coords,\n coord_origin, coord_delta,\n input_array_type_codes, input_arrays,\n output_array_type_codes, output_arrays);\n\n return (retval);\n}\n", |
| "Interpolate.c": "/*@@\n @file Interpolate.c\n @date Wed 17 Jan 2001\n @author Thomas Radke\n @desc\n Interpolation of arrays to arbitrary points\n\n This interpolator is based on the Cactus 3.x Fortran version\n written by Paul Walker. It also contains some nice optimization\n features from Erik Schnetter. Jonathan Thornburg added some\n additional comments in October 2001.\n @enddesc\n\n @history\n @date Wed 17 Jan 2001\n @author Thomas Radke\n @hdesc Translation from Fortran to C\n @date Thu 18 Oct 2001\n @author Jonathan Thornburg\n @hdesc Add lots of comments, LOCALINTERP_VERBOSE_DEBUG debugging code\n @date 22 Jan 2002\n @author Jonathan Thornburg\n @hdesc Move all local-interpolation code from LocalInterp to here\n @endhistory\n\n @version $$\n @@*/\n\n#include <math.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdio.h>\n\n#include \"util_ErrorCodes.h\"\t\t/* defines error codes */\n#include \"cctk.h\"\n#include \"cctk_Interp.h\"\t\t/* defines error codes */\n#include \"cctk_Parameters.h\"\n#include \"Interpolate.h\"\n\n/* the rcs ID and its dummy function to use it */\nstatic const char *rcsid = \"$Header$\";\nCCTK_FILEVERSION(CactusBase_LocalInterp_Interpolate_c)\n\n#ifdef LOCALINTERP_VERBOSE_DEBUG\n /* if this is >= 0, we print verbose debugging information at this point */\n int LocalInterp_verbose_debug_n = -1;\n#endif\n\n/* the highest order of interpolation we support so far */\n#define MAXORDER 3\n\n/* the highest dimension for variables we can deal with (so far) */\n#define MAXDIM 3\n\n/* we return this if we are successful */\n#define RETURN_SUCCESS\t0\n\n/******************************************************************************/\n\n/*@@\n @routine INTERPOLATE (macro)\n @date 18 Oct 2001\n @author code by ???, these comments by Jonathan Thornburg\n @desc\n This macro does the interpolation of in_array[] to compute\n a single value out_array[n] (actually out_array[n]subpart ;\n see the comments below for details). The data to be interpolated\n must be real numbers of some type, i.e. if the arrays are\n complex this macro must be called separately for the real\n and imaginary parts.\n @enddesc\n\n @var cctk_type\n @vdesc C type of input and output array elements (might be complex)\n @endvar\n\n @var cctk_subtype\n @vdesc C type of actual numbers being interpolated (must be real)\n @endvar\n\n @var subpart\n @vdesc string to be suffixed to input/output array element to get\n to get real number, i.e. empty string if cctk_type is real,\n .Re or .Im as appropriate if cctk_type is complex\n @endvar\n\n @var in_array\n @vdesc A pointer to array to be interpolated (strictly speaking, to\n the array's [0][0]...[0] element); this is typically passed\n as a void * pointer so we typecast it as necessary.\n @endvar\n\n @var out_array\n @vdesc A 1-dimensional array where the interpolation result should be\n stored; this is typically passed as a void * pointer so we\n typecast it as necessary.\n @endvar\n\n @var order\n @vdesc The order of the interpolation (1=linear, 2=quadratic, 3=cubic, ...)\n @endvar\n\n @var point\n @vdesc [MAXDIM] array of integers giving the integer grid coordinates\n of the closest grid point to the interpolation point; the\n interpolation stencil/molecule is centered at this point.\n @endvar\n\n @var dims\n @vdesc [MAXDIM] array of integers giving the dimensions of in_array .\n @endvar\n\n @var n\n @vdesc Position in out_array where we should store the interpolation\n result.\n @endvar\n\n @var coeff\n @vdesc [MAXDIM][MAX_ORDER+1] array of (floating-point) interpolation\n coefficients; detailed semantics are that coeff[axis][m] is the\n coefficient of y[m] when the 1-dimensional Lagrange interpolation\n polynomial passing through the order+1 points\n {(0,y[0]), (1,y[1]), ..., (order,y[order])}\n is evaluated at the position x=offset[axis].\n @endvar\n @@*/\n/*\n * The basic idea here is that conceptually we first interpolate the\n * (say) 3D gridfn in the x direction at each y and z grid point,\n * then interpolate that 2D plane of values in the y direction at\n * each z grid point, and finally interpolate that 1D line of values\n * in the z direction. The implementation actually interleaves the\n * different directions' interpolations so that only 3 scalar temporaries\n * are needed.\n */\n#define INTERPOLATE(cctk_type, in_array, out_array, \\\n order, point, dims, n, coeff) \\\n { \\\n int ii, jj, kk; \\\n const cctk_type *fi; \\\n cctk_type interp_result, fj, fk; \\\n \\\n \\\n interp_result = 0; \\\n \\\n /* NOTE-MAXDIM: support >3D arrays by adding more loops */ \\\n for (kk = 0; kk <= order; kk++) \\\n { \\\n fk = 0; \\\n for (jj = 0; jj <= order; jj++) \\\n { \\\n /* NOTE-MAXDIM: for >3D arrays adapt the index calculation here */ \\\n fi = (const cctk_type *) in_array + \\\n point[0] + dims[0]*(point[1]+jj + dims[1]*(point[2]+kk)); \\\n \\\n fj = 0; \\\n for (ii = 0; ii <= order; ii++) \\\n { \\\n fj += fi[ii] * coeff[0][ii]; \\\n } \\\n /* at this point we have just computed */ \\\n /* fj = in_array[*][jj][kk] interpolated to x=offset[0] */ \\\n \\\n fk += fj * coeff[1][jj]; \\\n } \\\n /* at this point we have just computed */ \\\n /* fk = fj[*][kk] interpolated to y=offset[1] */ \\\n /* = in_array[*][*][kk] interpolated to */ \\\n /* x=offset[0], y=offset[1] */ \\\n \\\n interp_result += fk * coeff[2][kk]; \\\n } \\\n /* at this point we have just computed */ \\\n /* interp_result = fk[*] interpolated to z=offset[2] */ \\\n /* = in_array[*][*][*] interpolated to */ \\\n /* x=offset[0], y=offset[1], z=offset[2] */ \\\n \\\n /* assign the result */ \\\n ((cctk_type *) out_array)[n] = interp_result; \\\n } /* end of macro */\n\n/******************************************************************************/\n\n/*@@\n @routine LocalInterp_Interpolate\n @date Wed 17 Jan 2001\n @author Thomas Radke\n @desc\n This routine interpolates a set of input arrays\n to a set of output arrays (one-to-one) at arbitrary points\n which are given by their coordinates and the underlying\n regular, uniform grid.\n\n Current limitations of this implementation are:\n - arrays up to three (MAXDIM) dimensions only can be handled\n - interpolation orders up to three (MAXORDER) only are supported\n - coordinates must be given as CCTK_REAL types\n - input and output array types must be the same\n (no type casting of interpolation results supported)\n\n Despite of these limitations, the code was programmed almost\n generically in that it can easily be extended to support\n higher-dimensional arrays or more interpolation orders.\n Places where the code would need to be changed to do this,\n are marked with NOTE-MAXDIM and/or NOTE-MAXORDER comments\n as appropriate.\n @enddesc\n\n @var num_points\n @vdesc number of points to interpolate at\n @vtype int\n @vio in\n @endvar\n @var num_dims\n @vdesc dimensionality of the input arrays\n @vtype int\n @vio in\n @endvar\n @var num_arrays\n @vdesc number of input/output arrays\n @vtype int\n @vio in\n @endvar\n @var dims\n @vdesc dimensions of the input arrays\n @vtype CCTK_INT[ num_dims ]\n @vio in\n @endvar\n @var coord\n @vdesc list of coordinates to interpolate at\n @vtype CCTK_REAL coord[ num_dims ][ num_points ]\n @vio in\n @endvar\n @var origin\n @vdesc origin of the underlying grid\n @vtype CCTK_REAL origin[ num_dims ]\n @vio in\n @endvar\n @var delta\n @vdesc deltas of the underlying grid\n @vtype CCTK_REAL delta[ num_dims ]\n @vio in\n @endvar\n @var in_types\n @vdesc CCTK variable types of input arrays\n @vtype CCTK_INT in_types[ num_arrays ]\n @vio in\n @endvar\n @var in_arrays\n @vdesc list of input arrays\n @vtype void *in_arrays[ num_arrays ]\n @vio in\n @endvar\n @var out_types\n @vdesc CCTK variable types of output arrays\n @vtype CCTK_INT out_types[ num_arrays ]\n @vio in\n @endvar\n @var out_arrays\n @vdesc list of output arrays\n @vtype void *out_arrays[ num_arrays ]\n @vio out\n @endvar\n\n @returntype int\n @returndesc\n 0 - successful interpolation\n negative in case of any errors (eg. the negative total number\n of out-of-bounds interpolation points)\n @endreturndesc\n @@*/\nint LocalInterp_Interpolate (int order,\n int num_points,\n int num_dims,\n int num_arrays,\n const CCTK_INT dims[],\n const CCTK_REAL *const coord[],\n const CCTK_REAL origin[],\n const CCTK_REAL delta[],\n const CCTK_INT in_types[],\n const void *const in_arrays[],\n const CCTK_INT out_types[],\n void *const out_arrays[])\n{\n int retval;\n CCTK_REAL delta_inv[MAXDIM];\n\n\n retval = RETURN_SUCCESS;\n\n /*\n * verify parameters and check against our restrictions\n */\n if (num_dims < 1)\n {\n CCTK_WARN (1, \"Number of dimensions must be positive\");\n return UTIL_ERROR_BAD_INPUT;\n }\n\n if (num_dims > MAXDIM)\n {\n CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Interpolation of %d-dimensional arrays not implemented\",\n num_dims);\n return UTIL_ERROR_BAD_INPUT;\n }\n\n if (order < 0)\n {\n CCTK_WARN (1, \"Interpolation order must be non-negative\");\n return UTIL_ERROR_BAD_INPUT;\n }\n\n if (order > MAXORDER)\n {\n CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Interpolation order %d not implemented\", order);\n return UTIL_ERROR_BAD_INPUT;\n }\n\n /* check that the stencil/molecule isn't bigger than the grid */\n for (int i = 0; i < num_dims; i++)\n {\n if (order+1 > dims[i]) /* stencil/molecule size = order+1 */\n {\n return CCTK_ERROR_INTERP_GRID_TOO_SMALL;\n }\n }\n\n if (num_points < 0)\n {\n CCTK_WARN (1, \"Negative number of points given\");\n return UTIL_ERROR_BAD_INPUT;\n }\n\n\n /* also immediately return if there's nothing to do */\n if (num_points == 0)\n {\n return RETURN_SUCCESS;\n }\n\n /* avoid divisions by delta later on */\n for (int i = 0; i < num_dims; i++)\n {\n delta_inv[i] = 1.0 / delta[i];\n }\n\n\n#pragma omp parallel\n {\n int shift, myretval;\n int out_of_bounds;\n CCTK_INT max_dims[MAXDIM], point[MAXDIM];\n CCTK_REAL below[MAXDIM];\n CCTK_REAL offset[MAXDIM];\n CCTK_REAL coeff[MAXDIM][MAXORDER + 1];\n\n /* duplicate the dims[] vector into one with MAXDIM-1 elements\n (with the remaining elements zeroed out)\n so that we can use nested loops over MAXDIM dimensions later on */\n memset (max_dims, 0, sizeof (max_dims));\n memcpy (max_dims, dims, (num_dims - 1) * sizeof (*max_dims));\n\n /* zero out the coefficients and set the elements with index 'order' to one\n so that we can use nested loops over MAXDIM dimensions later on */\n memset (coeff, 0, sizeof (coeff));\n for (int i = num_dims; i < MAXDIM; i++)\n {\n coeff[i][0] = 1;\n }\n\n /* zero out the iterator */\n memset (point, 0, sizeof (point));\n\n myretval = RETURN_SUCCESS;\n\n /* loop over all points to interpolate at */\n #pragma omp for\n for (int n = 0; n < num_points; n++)\n {\n /* reset the out-of-bounds flag */\n out_of_bounds = 0;\n\n /* loop over all dimensions */\n for (int i = 0; i < num_dims; i++)\n {\n /* closest grid point for stencil/molecule */\n point[i] = lrint (floor ((coord[i][n] - origin[i]) * delta_inv[i]\n - 0.5 * (order - 1)));\n\n /* test bounds */\n out_of_bounds |= point[i] < 0 || point[i]+order >= dims[i];\n\n /* if beyond lower bound shift the grid point to the right */\n shift = point[i];\n if (shift < 0)\n {\n point[i] -= shift;\n }\n\n /* if beyond upper bound shift the grid point to the left */\n shift = point[i] + order - (dims[i] - 1);\n if (shift > 0)\n {\n point[i] -= shift;\n }\n\n /* physical coordinate of that grid point */\n below[i] = origin[i] + point[i] * delta[i];\n\n /* offset from that grid point, in fractions of grid points */\n offset[i] = (coord[i][n] - below[i]) * delta_inv[i];\n }\n\n#ifdef LOCALINTERP_VERBOSE_DEBUG\nif (n == LocalInterp_verbose_debug_n)\n#pragma omp critical\n {\n int ii;\n printf(\"out_of_bounds = %d\\n\", out_of_bounds);\n for (ii = 0 ; ii < num_dims ; ++ii)\n {\n printf(\"offset[%d] = %g\\n\", ii, (double) offset[ii]);\n }\n }\n#endif /* LOCALINTERP_VERBOSE_DEBUG */\n\n /* check bounds */\n if (out_of_bounds)\n {\n#pragma omp critical\n if (num_dims == 1)\n {\n CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Interpolation stencil/molecule out of bounds\\n\"\n \" (the interpolation point is either outside the grid, \"\n \"or inside but too close to a grid boundary)\\n\"\n \" for interpolation order %d\\n\"\n \" at interpolation point %d with x = (%f)\\n\"\n \" and grid min/max = (%f/%f)\\n\"\n \"(this may be caused by a global interpolation with\\n\"\n \" driver::ghost_size too small)\\n\"\n ,\n order, n,\n (double) coord[0][n],\n (double) origin[0], (double) (origin[0] + (dims[0]-1)*delta[0]));\n }\n else if (num_dims == 2)\n {\n CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Interpolation stencil/molecule out of bounds\\n\"\n \" (the interpolation point is either outside the grid, \"\n \"or inside but too close to a grid boundary)\\n\"\n \" for interpolation order %d\\n\"\n \" at interpolation point %d with xy = (%f, %f)\\n\"\n \" and grid min/max = (%f/%f, %f/%f)\\n\"\n \"(this may be caused by a global interpolation with\\n\"\n \" driver::ghost_size too small)\\n\"\n ,\n order, n,\n (double) coord[0][n], (double) coord[1][n],\n (double) origin[0], (double) (origin[0] + (dims[0]-1)*delta[0]),\n (double) origin[1], (double) (origin[1] + (dims[1]-1)*delta[1]));\n }\n else if (num_dims == 3)\n {\n CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Interpolation stencil/molecule out of bounds\\n\"\n \" (the interpolation point is either outside the grid, \"\n \"or inside but too close to a grid boundary)\\n\"\n \" for interpolation order %d\\n\"\n \" at interpolation point %d with xyz = (%f, %f, %f)\\n\"\n \" and grid min/max = (%f/%f, %f/%f, %f/%f)\\n\"\n \"(this may be caused by a global interpolation with\\n\"\n \" driver::ghost_size too small)\\n\"\n ,\n order, n,\n (double) coord[0][n], (double) coord[1][n], (double) coord[2][n],\n (double) origin[0], (double) (origin[0] + (dims[0]-1)*delta[0]),\n (double) origin[1], (double) (origin[1] + (dims[1]-1)*delta[1]),\n (double) origin[2], (double) (origin[2] + (dims[2]-1)*delta[2]));\n }\n else\n {\n CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Internal error: %d dimensions aren't supported\", num_dims);\n }\n\n myretval = CCTK_ERROR_INTERP_POINT_OUTSIDE;\n continue;\t\t\t\t/* with next interpolation point */\n }\n\n /*\n * *** compute the interpolation coefficients according to the order ***\n *\n * (Thanks to Erik for formulating these so nicely.)\n *\n * These formulas are \"just\" the coefficients of the classical\n * Lagrange interpolation polynomials along each dimension.\n * For example, in 1 dimension the unique quadratic passing\n * through the 3 points {(x0,y0), (x1,y1), (x2,y2)} is:\n * ( x-x1)( x-x2) ( x-x0)( x-x2) ( x-x0)( x-x1)\n * -------------- y0 + -------------- y1 + -------------- y2\n * (x0-x1)(x0-x2) (x1-x0)(x1-x2) (x2-x0)(x2-x1)\n * (It's easy to see this: each of the terms is yi if x=xi, or\n * zero if x=any other xj.) To get the formulas below, just negate\n * each (x-x) factor, and substitute the values xi=i.\n */\n /*\n * NOTE-MAXORDER: support higher interpolation orders by adding the\n * appropriate coefficients in another else branch\n */\n switch(order)\n {\n case 0:\n /* zeroeth order (copy) 1D interpolation */\n for (int i = 0; i < num_dims; i++)\n {\n coeff[i][0] = 1;\n }\n break;\n case 1:\n /* first order (linear) 1D interpolation */\n for (int i = 0; i < num_dims; i++)\n {\n coeff[i][0] = 1 - offset[i];\n coeff[i][1] = offset[i];\n }\n break;\n case 2:\n /* second order (quadratic) 1D interpolation */\n for (int i = 0; i < num_dims; i++)\n {\n coeff[i][0] = (1-offset[i]) * (2-offset[i]) / ( 2 * 1 );\n coeff[i][1] = ( -offset[i]) * (2-offset[i]) / ( 1 * (-1));\n coeff[i][2] = ( -offset[i]) * (1-offset[i]) / ((-1) * (-2));\n }\n break;\n case 3:\n /* third order (cubic) 1D interpolation */\n for (int i = 0; i < num_dims; i++)\n {\n coeff[i][0] = (1-offset[i]) * (2-offset[i]) * (3-offset[i]) /\n ( 3 * 2 * 1 );\n coeff[i][1] = ( -offset[i]) * (2-offset[i]) * (3-offset[i]) /\n ( 2 * 1 * (-1));\n coeff[i][2] = ( -offset[i]) * (1-offset[i]) * (3-offset[i]) /\n ( 1 * (-1) * (-2));\n coeff[i][3] = ( -offset[i]) * (1-offset[i]) * (2-offset[i]) /\n ((-1) * (-2) * (-3));\n }\n break;\n default:\n#pragma omp critical\n {\n CCTK_VError (__LINE__,__FILE__,CCTK_THORNSTRING,\n \"Implementation error. Unexpected interpolation order %d\",\n order);\n }\n break;\n }\n\n#ifdef LOCALINTERP_VERBOSE_DEBUG\nif (n == LocalInterp_verbose_debug_n)\n#pragma omp critical\n {\n int ii,mm;\n for (ii = 0 ; ii < num_dims ; ++ii)\n {\n for (mm = 0 ; mm <= order ; ++mm)\n {\n printf(\"coeff[%d][%d] = %g\\n\",\n ii, mm, (double) coeff[ii][mm]);\n }\n }\n }\n#endif /* LOCALINTERP_VERBOSE_DEBUG */\n\n /* now loop over all arrays to interpolate at the current point */\n for (int a = 0; a < num_arrays; a++)\n {\n /* check for valid input and output array type */\n if (in_types[a] < 0 || out_types[a] < 0)\n {\n#pragma omp critical\n CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Datatype for input and/or output array with index %d \"\n \"is invalid\", a);\n myretval = UTIL_ERROR_BAD_INPUT;\n continue;\n }\n\n /* sorry, for now input and output arrays must be of same type */\n if (in_types[a] != out_types[a])\n {\n#pragma omp critical\n CCTK_WARN (1, \"Type casting of interpolation results not implemented\");\n myretval = UTIL_ERROR_BAD_INPUT;\n continue;\n }\n\n /* skip this array if it's a query call only */\n if (! out_arrays[a])\n {\n continue;\n }\n\n /* now do the interpolation according to the array type\n we support all kinds of CCTK_REAL* and CCTK_COMPLEX* types here */\n if (in_types[a] == CCTK_VARIABLE_REAL)\n {\n INTERPOLATE (CCTK_REAL, in_arrays[a],\n out_arrays[a], order, point, max_dims, n, coeff);\n }\n else if (in_types[a] == CCTK_VARIABLE_COMPLEX)\n {\n INTERPOLATE (CCTK_COMPLEX, in_arrays[a],\n out_arrays[a], order, point, max_dims, n, coeff);\n }\n#ifdef HAVE_CCTK_REAL4\n else if (in_types[a] == CCTK_VARIABLE_REAL4)\n {\n INTERPOLATE (CCTK_REAL4, in_arrays[a],\n out_arrays[a], order, point, max_dims, n, coeff);\n }\n else if (in_types[a] == CCTK_VARIABLE_COMPLEX8)\n {\n INTERPOLATE (CCTK_COMPLEX8, in_arrays[a],\n out_arrays[a], order, point, max_dims, n, coeff);\n }\n#endif\n#ifdef HAVE_CCTK_REAL8\n else if (in_types[a] == CCTK_VARIABLE_REAL8)\n {\n INTERPOLATE (CCTK_REAL8, in_arrays[a],\n out_arrays[a], order, point, max_dims, n, coeff);\n }\n else if (in_types[a] == CCTK_VARIABLE_COMPLEX16)\n {\n INTERPOLATE (CCTK_COMPLEX16, in_arrays[a],\n out_arrays[a], order, point, max_dims, n, coeff);\n }\n#endif\n#ifdef HAVE_CCTK_REAL16\n else if (in_types[a] == CCTK_VARIABLE_REAL16)\n {\n INTERPOLATE (CCTK_REAL16, in_arrays[a],\n out_arrays[a], order, point, max_dims, n, coeff);\n }\n else if (in_types[a] == CCTK_VARIABLE_COMPLEX32)\n {\n INTERPOLATE (CCTK_COMPLEX32, in_arrays[a],\n out_arrays[a], order, point, max_dims, n, coeff);\n }\n#endif\n else\n {\n#pragma omp critical\n CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,\n \"Unsupported variable type %d\", (int) in_types[a]);\n }\n } /* end of loop over all arrays */\n\n } /* end of loop over all points to interpolate at */\n#pragma omp critical\n if (myretval != RETURN_SUCCESS && retval == RETURN_SUCCESS)\n {\n retval = myretval; /* return one of the error conditions that occured */\n }\n } /* end of parallel section */\n\n /* we're done */\n return (retval);\n}\n", |
| "documentation.tex": "% *======================================================================*\n% Cactus Thorn template for ThornGuide documentation\n% Author: Ian Kelley\n% Date: Sun Jun 02, 2002\n% $Header$ \n%\n% Thorn documentation in the latex file doc/documentation.tex \n% will be included in ThornGuides built with the Cactus make system.\n% The scripts employed by the make system automatically include \n% pages about variables, parameters and scheduling parsed from the \n% relevent thorn CCL files.\n% \n% This template contains guidelines which help to assure that your \n% documentation will be correctly added to ThornGuides. More \n% information is available in the Cactus UsersGuide.\n% \n% Guidelines:\n% - Do not change anything before the line\n% % BEGIN CACTUS THORNGUIDE\",\n% except for filling in the title, author, date etc. fields.\n% - You can define your own macros are OK, but they must appear after\n% the BEGIN CACTUS THORNGUIDE line, and do not redefine standard \n% latex commands.\n% - To avoid name clashes with other thorns, 'labels', 'citations', \n% 'references', and 'image' names should conform to the following \n% convention: \n% ARRANGEMENT_THORN_LABEL\n% For example, an image wave.eps in the arrangement CactusWave and \n% thorn WaveToyC should be renamed to CactusWave_WaveToyC_wave.eps\n% - Graphics should only be included using the graphix package. \n% More specifically, with the \"includegraphics\" command. Do\n% not specify any graphic file extensions in your .tex file. This \n% will allow us (later) to create a PDF version of the ThornGuide\n% via pdflatex. |\n% - References should be included with the latex \"bibitem\" command. \n% - For the benefit of our Perl scripts, and for future extensions, \n% please use simple latex. \n%\n% *======================================================================* \n% \n% Example of including a graphic image:\n% \\begin{figure}[ht]\n% \t\\begin{center}\n% \t \\includegraphics[width=6cm]{MyArrangement_MyThorn_MyFigure}\n% \t\\end{center}\n% \t\\caption{Illustration of this and that}\n% \t\\label{MyArrangement_MyThorn_MyLabel}\n% \\end{figure}\n%\n% Example of using a label:\n% \\label{MyArrangement_MyThorn_MyLabel}\n%\n% Example of a citation:\n% \\cite{MyArrangement_MyThorn_Author99}\n%\n% Example of including a reference\n% \\bibitem{MyArrangement_MyThorn_Author99}\n% {J. Author, {\\em The Title of the Book, Journal, or periodical}, 1 (1999), \n% 1--16. {\\tt http://www.nowhere.com/}}\n%\n% *======================================================================* \n\n% If you are using CVS use this line to give version information\n% $Header$\n\n\\documentclass{article}\n\n% Use the Cactus ThornGuide style file\n% (Automatically used from Cactus distribution, if you have a \n% thorn without the Cactus Flesh download this from the Cactus\n% homepage at www.cactuscode.org)\n\\usepackage{../../../../doc/latex/cactus}\n\n\\begin{document}\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% The author of the documentation\n\\author{Thomas Radke} \n\n% The title of the document (not necessarily the name of the Thorn)\n\\title{Thorn Guide for the {\\bf LocalInterp} Thorn}\n\n% the date your document was last changed, if your document is in CVS, \n% please us:\n% \\date{$ $Date$ $}\n\\date{$ $Date$ $}\n\n\\maketitle\n\n% Do not delete next line\n% START CACTUS THORNGUIDE\n\n% Add all definitions used in this documentation here \n% \\def\\mydef etc\n\n% Add an abstract for this thorn's documentation\n\\begin{abstract}\nThis thorn does processor-local interpolation of N-dimensional data\narrays. In general there may be many input arrays (all defined on the\nsame uniform Cartesian grid) all being interpolated to the same set\nof interpolation points.\n\\end{abstract}\n\n% The following sections are suggestive only.\n% Remove them or add your own.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Introduction}\n\nThis thorn provides processor-local interpolation, using the interpolation\noperator\n\\begin{verbatim}\n \"uniform cartesian\"\n\\end{verbatim}\nfor the Cactus local interpolation API \\verb|CCTK_InterpLocalUniform()|.\n(Note that the word ``{\\tt cartesian}'' is in lower case here!)\nIt supports 1, 2, and 3-dimensional interpolation.\n\nSee the Cactus Reference Manual\nfor a full description of the \\verb|CCTK_InterpLocalUniform()| API,\nand some examples of how to use it.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\subsection{History}\n\nThis interpolator was written by Thomas Radke in early 2001 (drawing\non older code by Paul Walker). It originally lived in the PUGHInterp\nthorn, but it turned to have very little to do with PUGH, so was moved\nhere in winter 2001-2002.\n\nFrom winter 2001-2002 to July 2003 this thorn also contained another\ninterpolator written by Jonathan Thornburg, but in July 2003 that\ninterpolator was moved to {\\bf AEIThorns/AEILocalInterp/} because it was\n(is) GPL and Cactus policies are that this arrangement ({\\bf CactusBase})\nis reserved for code under the Cactus-flesh license (= GPL except\nthat it's like LGPL for linking with other thorns).\n\nBecause CVS can't delete directories, this thorn still contains a lot\nof empty-except-for-CVS-directories directory trees left over from\nJonathan Thornburg's interpolator. You can/should ignore these.\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n\\section{Implementation}\n\nInternally, this interpolator always does 3-D interpolation, inserting\nzero coordinates as appropriate for lower dimensionalities. The\ninterpolation is done by successive 1-D interpolations along each\naxis.%%%\n\\footnote{%%%\n\t Note that this means that different axes are treated\n\t slightly differently by the interpolator. In other\n\t words, at the level of finite differencing errors,\n\t interpolation does {\\em not\\/} commute with permuting\n\t the axes. However, in practice the differences are\n\t likely to be small, at least for smooth input data.\n\t }%%%\n{} See the \\verb|README| file in the \\verb|src/| directory\nfor further details.\n\n\\subsection{Additional information passed in as table options}\n\nThe \\verb|CCTK_InterpLocalUniform()| API accepts a table handle as one of its\narguments which can be used to pass additional information to the local\ninterpolator via table options.\n\nThe only table option supported so far by {\\bf LocalInterp}'s {\\tt \"uniform\ncartesian\"} operator is the interpolation order which must be\npassed as a CCTK\\_INT value with key {\\tt \"order\"}. Options with keys\n{\\tt \"N\\_boundary\\_points\\_to\\_omit\", \"boundary\\_off\\_centering\\_tolerance\"}, or\n{\\tt \"boundary\\_extrapolation\\_tolerance\"} (which are usually passed by a\nglobal interpolator) are also recognized but silently ignored (a level-4 warning\nmessage will be issued in this case).\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n% Do not delete next line\n% END CACTUS THORNGUIDE\n\n\\end{document}\n" |