From b4ca151f9fa833902d15234ea8f1107577bcf762 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 3 Oct 2008 16:17:01 -0500 Subject: CarpetInterp2: Export a simple interpolator API as aliased function --- Carpet/CarpetInterp2/interface.ccl | 23 ++++++++-- Carpet/CarpetInterp2/src/interp2.cc | 78 +++++++++++++++++++++++++++++++++ Carpet/CarpetInterp2/src/make.code.defn | 2 +- 3 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 Carpet/CarpetInterp2/src/interp2.cc (limited to 'Carpet/CarpetInterp2') diff --git a/Carpet/CarpetInterp2/interface.ccl b/Carpet/CarpetInterp2/interface.ccl index fc822c9e1..1a8e1c177 100644 --- a/Carpet/CarpetInterp2/interface.ccl +++ b/Carpet/CarpetInterp2/interface.ccl @@ -41,7 +41,24 @@ CCTK_INT FUNCTION \ CCTK_INT IN npoints, \ CCTK_POINTER_TO_CONST IN globalcoords, \ CCTK_INT ARRAY OUT patch, \ - CCTK_POINTER IN localcoords, \ - CCTK_POINTER IN dadx, \ - CCTK_POINTER IN ddadxdx) + CCTK_POINTER IN localcoords, \ + CCTK_POINTER IN dadx, \ + CCTK_POINTER IN ddadxdx) USES FUNCTION MultiPatch_GlobalToLocal + + + +CCTK_INT FUNCTION \ + InterpGridArrays \ + (CCTK_POINTER_TO_CONST IN cctkGH, \ + CCTK_INT IN N_dims, \ + CCTK_INT IN order, \ + CCTK_INT IN N_interp_points, \ + CCTK_POINTER_TO_CONST IN interp_coords, \ + CCTK_INT IN N_input_arrays, \ + CCTK_INT ARRAY IN input_array_indices, \ + CCTK_INT IN N_output_arrays, \ + CCTK_POINTER IN output_arrays) +PROVIDES FUNCTION InterpGridArrays \ + WITH CarpetInterp2_InterpGridArrays \ + LANGUAGE C diff --git a/Carpet/CarpetInterp2/src/interp2.cc b/Carpet/CarpetInterp2/src/interp2.cc new file mode 100644 index 000000000..f8a17df99 --- /dev/null +++ b/Carpet/CarpetInterp2/src/interp2.cc @@ -0,0 +1,78 @@ +#include + +#include "fasterp.hh" + + + +namespace CarpetInterp2 { + + extern "C" + CCTK_INT + CarpetInterp2_InterpGridArrays (CCTK_POINTER_TO_CONST const cctkGH_, + CCTK_INT const N_dims, + CCTK_INT const order, + CCTK_INT const N_interp_points, + CCTK_POINTER_TO_CONST const interp_coords_, + CCTK_INT const N_input_arrays, + CCTK_INT const * const input_array_indices, + CCTK_INT const N_output_arrays, + CCTK_POINTER const output_arrays_) + { + // Check input values and convert types + cGH const * const cctkGH = static_cast (cctkGH_); + assert (cctkGH); + + assert (N_dims == dim); + + assert (N_interp_points >= 0); + + CCTK_REAL const * const * const interp_coords = + static_cast (interp_coords_); + assert (interp_coords); + for (int d=0; d= 0); + + assert (input_array_indices); + for (int n=0; n=0 and + input_array_indices[n]= 0); + assert (N_output_arrays == N_input_arrays); + + CCTK_REAL * const * const output_arrays = + static_cast (output_arrays_); + assert (output_arrays); + for (int n=0; n varinds (N_input_arrays); + for (int n=0; n values (N_input_arrays); + for (int n=0; n