aboutsummaryrefslogtreecommitdiff
path: root/src/Startup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Startup.c')
-rw-r--r--src/Startup.c93
1 files changed, 90 insertions, 3 deletions
diff --git a/src/Startup.c b/src/Startup.c
index f5ff5f2..3cb3226 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include "cctk.h"
+#include "util_Table.h"
#include "cctk_Interp.h"
#include "pughInterpGH.h"
@@ -61,6 +62,18 @@ static int InterpGV_3rdOrder (cGH *GH,
const int in_array_indices[],
void *const out_arrays[],
const int out_array_types[]);
+static int PUGHInterp_InterpGV (cGH *GH,
+ int order,
+ const char *local_interpolator,
+ const char *coord_system_name,
+ int N_points,
+ int N_input_arrays,
+ int N_output_arrays,
+ const void *const interp_coord_arrays[],
+ const int interp_coord_array_types[],
+ const int input_array_indices[],
+ void *const output_arrays[],
+ const int output_array_types[]);
/*@@
@@ -168,7 +181,8 @@ static int InterpGV_1stOrder (cGH *GH,
void *const out_arrays[],
const int out_array_types[])
{
- return (PUGHInterp_InterpGV (GH, 1, coord_system, num_points,
+ return (PUGHInterp_InterpGV (GH, 1, "first-order uniform cartesian",
+ coord_system, num_points,
num_in_array_indices, num_out_arrays,
interp_coord_arrays, interp_coord_array_types,
in_array_indices, out_arrays, out_array_types));
@@ -186,7 +200,8 @@ static int InterpGV_2ndOrder (cGH *GH,
void *const out_arrays[],
const int out_array_types[])
{
- return (PUGHInterp_InterpGV (GH, 2, coord_system, num_points,
+ return (PUGHInterp_InterpGV (GH, 2, "second-order uniform cartesian",
+ coord_system, num_points,
num_in_array_indices, num_out_arrays,
interp_coord_arrays, interp_coord_array_types,
in_array_indices, out_arrays, out_array_types));
@@ -204,8 +219,80 @@ static int InterpGV_3rdOrder (cGH *GH,
void *const out_arrays[],
const int out_array_types[])
{
- return (PUGHInterp_InterpGV (GH, 3, coord_system, num_points,
+ return (PUGHInterp_InterpGV (GH, 3, "third-order uniform cartesian",
+ coord_system, num_points,
num_in_array_indices, num_out_arrays,
interp_coord_arrays, interp_coord_array_types,
in_array_indices, out_arrays, out_array_types));
}
+
+
+static int PUGHInterp_InterpGV (cGH *GH,
+ int order,
+ const char *local_interpolator,
+ const char *coord_system_name,
+ int N_points,
+ int N_input_arrays,
+ int N_output_arrays,
+ const void *const interp_coord_arrays[],
+ const int interp_coord_array_types[],
+ const int input_array_indices[],
+ void *const output_arrays[],
+ const int output_array_types[])
+{
+ int i, N_dims, retval;
+ int local_interp_handle, param_table_handle, coord_system_handle;
+ char table_string[64];
+ CCTK_INT *_input_array_indices, *_output_array_types;
+ struct
+ {
+ const cGH *const_GH;
+ cGH *non_const_GH;
+ } _GH;
+
+
+ _GH.non_const_GH = GH;
+
+ /* get dimensionality of the coordinate system */
+ N_dims = CCTK_CoordSystemDim (coord_system_name);
+ if (N_dims <= 0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Cannot get dimensions of coordinate system '%s'",
+ coord_system_name);
+ return (-1);
+ }
+ coord_system_handle = CCTK_CoordSystemHandle (coord_system_name);
+ local_interp_handle = CCTK_InterpHandle (local_interpolator);
+
+ /* turn native datatype arrays into CCTK_ datatypes */
+ _input_array_indices = malloc (2 * N_dims * sizeof (CCTK_INT));
+ _output_array_types = _input_array_indices + N_dims;
+ for (i = 0; i < N_dims; i++)
+ {
+ _input_array_indices[i] = input_array_indices[i];
+ _output_array_types[i] = output_array_types[i];
+ }
+
+ /* set up the parameter table (only supported option is "order") */
+ sprintf (table_string, "order = %d", order);
+ param_table_handle = Util_TableCreateFromString (table_string);
+
+ retval = PUGHInterp_InterpGridArrays (_GH.const_GH, N_dims,
+ local_interp_handle, param_table_handle,
+ coord_system_handle,
+ N_points,
+ interp_coord_array_types[0],
+ interp_coord_arrays,
+ N_input_arrays,
+ _input_array_indices,
+ N_output_arrays,
+ _output_array_types,
+ output_arrays);
+
+ /* release resources */
+ Util_TableDestroy (param_table_handle);
+ free (_input_array_indices);
+
+ return (retval);
+}