#include #include #include "cctk.h" #include "cctk_Arguments.h" #include "cctk_Parameters.h" #include "util_Table.h" void InterpToArray (CCTK_ARGUMENTS) { DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; int const interpolator = CCTK_InterpHandle (interpolator_name); assert (interpolator >= 0); int const options_table = Util_TableCreateFromString (interpolator_options); assert (options_table >= 0); int const coord_handle = CCTK_CoordSystemHandle (interpolator_coordinates); assert (coord_handle >= 0); /* Scalars */ { int const nvars = nscalars; if (nvars > 0) { int const npoints = 1; CCTK_REAL * restrict const coordsx = malloc (npoints * sizeof * coordsx); assert (npoints==0 || coordsx); CCTK_REAL * restrict const coordsy = malloc (npoints * sizeof * coordsy); assert (npoints==0 || coordsy); CCTK_REAL * restrict const coordsz = malloc (npoints * sizeof * coordsz); assert (npoints==0 || coordsz); CCTK_POINTER_TO_CONST coords[3]; coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; { int const n = 0; coordsx[n] = scalar_x0; coordsy[n] = scalar_y0; coordsz[n] = scalar_z0; } CCTK_INT * restrict const inputs = malloc (nvars * sizeof * inputs); assert (inputs); for (int n=0; n 0) { int const npoints = array1d_npoints_i; CCTK_REAL * restrict const coordsx = malloc (npoints * sizeof * coordsx); assert (npoints==0 || coordsx); CCTK_REAL * restrict const coordsy = malloc (npoints * sizeof * coordsy); assert (npoints==0 || coordsy); CCTK_REAL * restrict const coordsz = malloc (npoints * sizeof * coordsz); assert (npoints==0 || coordsz); CCTK_POINTER_TO_CONST coords[3]; coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; #pragma omp parallel for for (int i=0; i= 0); if (inputs[n] < 0) { inputs[n] = -1; } } CCTK_INT * restrict const output_types = malloc (nvars * sizeof * output_types); assert (output_types); for (int n=0; n 0) { int const npoints = array2d_npoints_i * array2d_npoints_j; CCTK_REAL * restrict const coordsx = malloc (npoints * sizeof * coordsx); assert (npoints==0 || coordsx); CCTK_REAL * restrict const coordsy = malloc (npoints * sizeof * coordsy); assert (npoints==0 || coordsy); CCTK_REAL * restrict const coordsz = malloc (npoints * sizeof * coordsz); assert (npoints==0 || coordsz); CCTK_POINTER_TO_CONST coords[3]; coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; #pragma omp parallel for for (int j=0; j 0) { int const npoints = array3d_npoints_i * array3d_npoints_j * array3d_npoints_k; CCTK_REAL * restrict const coordsx = malloc (npoints * sizeof * coordsx); assert (npoints==0 || coordsx); CCTK_REAL * restrict const coordsy = malloc (npoints * sizeof * coordsy); assert (npoints==0 || coordsy); CCTK_REAL * restrict const coordsz = malloc (npoints * sizeof * coordsz); assert (npoints==0 || coordsz); CCTK_POINTER_TO_CONST coords[3]; coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; #pragma omp parallel for for (int k=0; k 0) { int const group = CCTK_GroupIndex ("InterpToArray::parrays1d"); assert (group >= 0); cGroupDynamicData dyndata; { int const ierr = CCTK_GroupDynamicData (cctkGH, group, &dyndata); assert (! ierr); } assert (dyndata.dim == 1); int const npoints = dyndata.lsh[0]; CCTK_REAL * restrict const coordsx = malloc (npoints * sizeof * coordsx); assert (npoints==0 || coordsx); CCTK_REAL * restrict const coordsy = malloc (npoints * sizeof * coordsy); assert (npoints==0 || coordsy); CCTK_REAL * restrict const coordsz = malloc (npoints * sizeof * coordsz); assert (npoints==0 || coordsz); CCTK_POINTER_TO_CONST coords[3]; coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; #pragma omp parallel for for (int i=0; i= 0); if (inputs[n] < 0) { inputs[n] = -1; } } CCTK_INT * restrict const output_types = malloc (nvars * sizeof * output_types); assert (output_types); for (int n=0; n 0) { int const group = CCTK_GroupIndex ("InterpToArray::parrays2d"); assert (group >= 0); cGroupDynamicData dyndata; { int const ierr = CCTK_GroupDynamicData (cctkGH, group, &dyndata); assert (! ierr); } assert (dyndata.dim == 2); int const npoints = dyndata.lsh[0] * dyndata.lsh[1]; CCTK_REAL * restrict const coordsx = malloc (npoints * sizeof * coordsx); assert (npoints==0 || coordsx); CCTK_REAL * restrict const coordsy = malloc (npoints * sizeof * coordsy); assert (npoints==0 || coordsy); CCTK_REAL * restrict const coordsz = malloc (npoints * sizeof * coordsz); assert (npoints==0 || coordsz); CCTK_POINTER_TO_CONST coords[3]; coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; #pragma omp parallel for for (int j=0; j 0) { int const group = CCTK_GroupIndex ("InterpToArray::parrays3d"); assert (group >= 0); cGroupDynamicData dyndata; { int const ierr = CCTK_GroupDynamicData (cctkGH, group, &dyndata); assert (! ierr); } assert (dyndata.dim == 3); int const npoints = dyndata.lsh[0] * dyndata.lsh[1] * dyndata.lsh[2]; CCTK_REAL * restrict const coordsx = malloc (npoints * sizeof * coordsx); assert (npoints==0 || coordsx); CCTK_REAL * restrict const coordsy = malloc (npoints * sizeof * coordsy); assert (npoints==0 || coordsy); CCTK_REAL * restrict const coordsz = malloc (npoints * sizeof * coordsz); assert (npoints==0 || coordsz); CCTK_POINTER_TO_CONST coords[3]; coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; #pragma omp parallel for for (int k=0; k