aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@1c20744c-e24a-42ec-9533-f5004cb800e5>2003-01-21 09:33:12 +0000
committertradke <tradke@1c20744c-e24a-42ec-9533-f5004cb800e5>2003-01-21 09:33:12 +0000
commit2ba08865cac2446f15dcd20bedf34d52bec4512b (patch)
tree73851819195d77387e359f52f3b4c657db093046
parent888354afcc2ef240911b763e42d50208b44e6129 (diff)
Evaluate the 'input_arrays_time_levels' option in the parameter table.
This lets you specify other timelevels than the default current one for interpolation. This closes PR Cactus/843. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHInterp/trunk@43 1c20744c-e24a-42ec-9533-f5004cb800e5
-rw-r--r--src/InterpGridArrays.c108
1 files changed, 71 insertions, 37 deletions
diff --git a/src/InterpGridArrays.c b/src/InterpGridArrays.c
index 507c5d2..9854c41 100644
--- a/src/InterpGridArrays.c
+++ b/src/InterpGridArrays.c
@@ -78,7 +78,8 @@ typedef struct
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
-static int CreateParameterTable (int param_table_handle);
+static int EvaluateParameterTable (int param_table_handle, int N_input_arrays,
+ CCTK_INT *input_array_time_levels);
/*@@
@@ -179,7 +180,7 @@ int PUGHInterp_InterpGridArrays (const cGH *GH,
{
int i, retval;
CCTK_REAL *origin_local, *delta_local;
- CCTK_INT *input_array_dims, *input_array_types;
+ CCTK_INT *input_array_dims, *input_array_types, *input_array_time_levels;
const void **input_arrays;
const char *coord_system_name;
const pGH *pughGH;
@@ -256,25 +257,30 @@ int PUGHInterp_InterpGridArrays (const cGH *GH,
return (UTIL_ERROR_BAD_INPUT);
}
- /* create the parameter table for the local interpolator from the
- user-supplied parameter table */
- param_table_handle = CreateParameterTable (param_table_handle);
- if (param_table_handle < 0)
+ /* allocate some temporary arrays */
+ origin_local = malloc (2 * N_dims * sizeof (CCTK_REAL));
+ delta_local = origin_local + N_dims;
+ input_arrays = malloc (N_input_arrays * sizeof (void *));
+ input_array_dims = malloc ((N_dims + 2*N_input_arrays) * sizeof (CCTK_INT));
+ input_array_types = input_array_dims + N_dims;
+ input_array_time_levels = input_array_dims + N_dims + N_input_arrays;
+
+ /* evaluate the options from the user-supplied parameter table */
+ retval = EvaluateParameterTable (param_table_handle, N_input_arrays,
+ input_array_time_levels);
+ if (retval < 0)
{
- return (param_table_handle);
+ free (origin_local);
+ free (input_arrays);
+ free (input_array_dims);
+
+ return (retval);
}
/*************************************************************************/
- /* allocate some temporary arrays */
- origin_local = malloc (2 * N_dims * sizeof (CCTK_REAL));
- delta_local = origin_local + N_dims;
- input_arrays = malloc (N_input_arrays * sizeof (void *));
- input_array_dims = malloc ((N_dims + N_input_arrays) * sizeof (CCTK_INT));
- input_array_types = input_array_dims + N_dims;
-
/* get the extras pointer of the first coordinate
This is used later on to verify the layout of the input arrays as well
as for mapping points to processors. */
@@ -323,11 +329,21 @@ int PUGHInterp_InterpGridArrays (const cGH *GH,
"doesn't match with coordinate system '%s'",
input_array_indices[i], coord_system_name);
retval = UTIL_ERROR_BAD_INPUT;
+ continue;
}
- /* get the data pointer to the input array (use current timelevel)
- and datatype */
- input_arrays[i] = CCTK_VarDataPtrI (GH, 0, input_array_indices[i]);
+ /* get the data pointer to the input array and its datatype */
+ input_arrays[i] = CCTK_VarDataPtrI (GH, input_array_time_levels[i],
+ input_array_indices[i]);
+ if (! input_arrays[i])
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Couldn't get data pointer of input array variable with "
+ "index %d timelevel %d",
+ input_array_indices[i], input_array_time_levels[i]);
+ retval = UTIL_ERROR_BAD_INPUT;
+ continue;
+ }
input_array_types[i] = CCTK_VarTypeI (input_array_indices[i]);
}
@@ -878,16 +894,11 @@ int PUGHInterp_InterpGridArrays (const cGH *GH,
******************** Internal Routines ************************
********************************************************************/
/*@@
- @routine CreateParameterTable
+ @routine EvaluateParameterTable
@date Fri 20 Dec 2002
@author Thomas Radke
@desc
- Parses the options given in the user-supplied parameter table
- and creates a parameter table to be passed to the local
- interpolator. If the user-supplied parameter table is invalid,
- a new table will be created.
- The table will be completed with necessary options from the
- global interpolator.
+ Parses the options given in the user-supplied parameter table.
@enddesc
@var param_table_handle
@@ -895,32 +906,55 @@ int PUGHInterp_InterpGridArrays (const cGH *GH,
@vtype int
@vio in
@endvar
+ @var N_input_arrays
+ @vdesc total number of input arrays
+ @vtype int
+ @vio in
+ @endvar
+ @var input_array_time_levels
+ @vdesc pointer to array of timelevels for input arrays
+ @vtype CCTK_INT *
+ @vio out
+ @endvar
@returntype int
@returndesc
- handle to the new local parameter table, or<BR>
- one of the UTIL_ERROR_TABLE_* error codes
+ 0 for success, or one of the UTIL_ERROR_TABLE_* error codes
@endreturndesc
@@*/
-static int CreateParameterTable (int param_table_handle)
+static int EvaluateParameterTable (int param_table_handle, int N_input_arrays,
+ CCTK_INT *input_array_time_levels)
{
- int retval;
+ int N_elements, retval;
- retval = param_table_handle >= 0 ? param_table_handle : Util_TableCreate (0);
- if (retval < 0)
+ if (param_table_handle < 0)
{
- CCTK_WARN (1, "couldn't create interpolator parameter table");
+ CCTK_WARN (1, "Invalid parameter table handle passed");
+ return (UTIL_ERROR_BAD_HANDLE);
}
-#if 0
- /* FIXME: must evaluate options from parameter table */
- if (Util_TableQueryNKeys (param_table_handle) > 0)
+ retval = 0;
+ N_elements = Util_TableGetIntArray (param_table_handle, N_input_arrays,
+ input_array_time_levels,
+ "input_array_time_levels");
+ if (N_elements == UTIL_ERROR_TABLE_NO_SUCH_KEY)
{
- CCTK_WARN (1, "options in global interpolator parameter table are ignored "
- "so far");
+ /* if no such option was specified, take the current timelevel as default */
+ memset (input_array_time_levels, 0, N_input_arrays * sizeof (CCTK_INT));
+ }
+ else if (N_elements < 0)
+ {
+ CCTK_WARN (1, "Array with key 'input_array_time_levels' must be of "
+ "CCTK_INT datatype");
+ retval = UTIL_ERROR_BAD_INPUT;
+ }
+ else if (N_elements < N_input_arrays)
+ {
+ CCTK_WARN (1, "Array with key 'input_array_time_levels' has fewer elements "
+ "than total number of input arrays");
+ retval = UTIL_ERROR_BAD_INPUT;
}
-#endif
return (retval);
}