From cd2dff3b7cd7a57223855b198d041379adf65a06 Mon Sep 17 00:00:00 2001 From: schnetter Date: Wed, 22 Apr 2009 22:36:12 +0000 Subject: Add parallel (distributed) arrays, and facilities to interpolate to them. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/InterpToArray/trunk@10 6ca9aeac-0e4f-0410-a746-fe4df63e9d0c --- interface.ccl | 5 + param.ccl | 216 +++++++++++++++++++++++++++++++++++- schedule.ccl | 4 +- src/interp.c | 351 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 528 insertions(+), 48 deletions(-) diff --git a/interface.ccl b/interface.ccl index 551200d..2a4d687 100644 --- a/interface.ccl +++ b/interface.ccl @@ -5,6 +5,11 @@ IMPLEMENTS: InterpToArray PUBLIC: REAL scalars[nscalars] TYPE=scalar + REAL arrays1d[narrays1d] TYPE=array DIM=1 DISTRIB=constant SIZE=array1d_npoints_i REAL arrays2d[narrays2d] TYPE=array DIM=2 DISTRIB=constant SIZE=array2d_npoints_i,array2d_npoints_j REAL arrays3d[narrays3d] TYPE=array DIM=3 DISTRIB=constant SIZE=array3d_npoints_i,array3d_npoints_j,array3d_npoints_k + +REAL parrays1d[nparrays1d] TYPE=array DIM=1 DISTRIB=default SIZE=parray1d_npoints_i +REAL parrays2d[nparrays2d] TYPE=array DIM=2 DISTRIB=default SIZE=parray2d_npoints_i,parray2d_npoints_j +REAL parrays3d[nparrays3d] TYPE=array DIM=3 DISTRIB=default SIZE=parray3d_npoints_i,parray3d_npoints_j,parray3d_npoints_k diff --git a/param.ccl b/param.ccl index aa045d7..83f682a 100644 --- a/param.ccl +++ b/param.ccl @@ -52,7 +52,7 @@ INT narrays1d "Number of 1D grid arrays" 0:100 :: "" } 0 -STRING array1d_vars[100] "Names of the grid functions that should be interpolated on a line point" STEERABLE=always +STRING array1d_vars[100] "Names of the grid functions that should be interpolated on a line" STEERABLE=always { "^$" :: "do not interpolate" "^[A-Za-z][A-Za-z0-9_]*[:][:][A-Za-z][A-Za-z0-9_]*$" :: "grid function name" @@ -258,3 +258,217 @@ REAL array3d_dz_k "Spacing" STEERABLE=always { 0.0:* :: "" } 0.0 + + + +INT nparrays1d "Number of 1D parallel grid arrays" +{ + 0:100 :: "" +} 0 + +STRING parray1d_vars[100] "Names of the grid functions that should be interpolated on a line" STEERABLE=always +{ + "^$" :: "do not interpolate" + "^[A-Za-z][A-Za-z0-9_]*[:][:][A-Za-z][A-Za-z0-9_]*$" :: "grid function name" +} "" + +INT parray1d_spacederivs[100] "Space derivative orders for each grid function" +{ + 0:* :: "" +} 0 + +INT parray1d_timederivs[100] "Time derivative order for each grid function" +{ + 0:* :: "" +} 0 + +REAL parray1d_x0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL parray1d_y0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL parray1d_z0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +INT parray1d_npoints_i "Number of grid points for the 1D grid parrays in the i direction" +{ + 0:100 :: "" +} 10 + +REAL parray1d_dx_i "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray1d_dy_i "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray1d_dz_i "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + + + +INT nparrays2d "Number of 2D parallel grid arrays" +{ + 0:100 :: "" +} 0 + +STRING parray2d_vars[100] "Names of the grid functions that should be interpolated on a 2D grid" STEERABLE=always +{ + "^$" :: "do not interpolate" + "^[A-Za-z][A-Za-z0-9_]*[:][:][A-Za-z][A-Za-z0-9_]*$" :: "grid function name" +} "" + +REAL parray2d_x0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL parray2d_y0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL parray2d_z0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +INT parray2d_npoints_i "Number of grid points for the 2D parallel grid arrays in the i direction" +{ + 0:100 :: "" +} 10 + +REAL parray2d_dx_i "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray2d_dy_i "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray2d_dz_i "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +INT parray2d_npoints_j "Number of grid points for the 2D parallel grid arrays in the j direction" +{ + 0:100 :: "" +} 10 + +REAL parray2d_dx_j "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray2d_dy_j "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray2d_dz_j "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + + + +INT nparrays3d "Number of 3D grid parrays" +{ + 0:100 :: "" +} 0 + +STRING parray3d_vars[100] "Names of the grid functions that should be interpolated on a 3D grid" STEERABLE=always +{ + "^$" :: "do not interpolate" + "^[A-Za-z][A-Za-z0-9_]*[:][:][A-Za-z][A-Za-z0-9_]*$" :: "grid function name" +} "" + +REAL parray3d_x0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL parray3d_y0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +REAL parray3d_z0 "Origin" STEERABLE=always +{ + *:* :: "" +} 0.0 + +INT parray3d_npoints_i "Number of grid points for the 3D parallel grid arrays in the i direction" +{ + 0:100 :: "" +} 10 + +REAL parray3d_dx_i "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray3d_dy_i "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray3d_dz_i "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +INT parray3d_npoints_j "Number of grid points for the 3D parallel grid arrays in the j direction" +{ + 0:100 :: "" +} 10 + +REAL parray3d_dx_j "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray3d_dy_j "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray3d_dz_j "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +INT parray3d_npoints_k "Number of grid points for the 3D parallel grid arrays in the k direction" +{ + 0:100 :: "" +} 10 + +REAL parray3d_dx_k "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray3d_dy_k "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 + +REAL parray3d_dz_k "Spacing" STEERABLE=always +{ + 0.0:* :: "" +} 0.0 diff --git a/schedule.ccl b/schedule.ccl index 1ae3eb1..bafca8c 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -4,6 +4,6 @@ SCHEDULE InterpToArray AT analysis { LANG: C OPTIONS: global - STORAGE: scalars arrays1d arrays2d arrays3d - TRIGGERS: scalars arrays1d arrays2d arrays3d + STORAGE: scalars arrays1d arrays2d arrays3d parrays1d parrays2d parrays3d + TRIGGERS: scalars arrays1d arrays2d arrays3d parrays1d parrays2d parrays3d } "Interpolate to grid arrays" diff --git a/src/interp.c b/src/interp.c index e2dbbec..69aac42 100644 --- a/src/interp.c +++ b/src/interp.c @@ -29,12 +29,14 @@ InterpToArray (CCTK_ARGUMENTS) CCTK_INT * restrict operation_codes; CCTK_INT * restrict time_deriv_order; + int group; + cGroupDynamicData dyndata; + int nvars; int npoints; int n; int i, j, k; - int d; int ierr; @@ -73,37 +75,38 @@ InterpToArray (CCTK_ARGUMENTS) coordsz[n] = scalar_z0; ++n; assert (n == npoints); - + inputs = malloc (nvars * sizeof * inputs); assert (inputs); - + for (n=0; n= 0); @@ -151,56 +154,56 @@ InterpToArray (CCTK_ARGUMENTS) inputs[n] = -1; } } - + output_types = malloc (nvars * sizeof * output_types); assert (output_types); - + for (n=0; n 0) { npoints = array2d_npoints_i * array2d_npoints_j; - + coordsx = malloc (npoints * sizeof * coordsx); assert (coordsx); coordsy = malloc (npoints * sizeof * coordsy); @@ -229,7 +232,7 @@ InterpToArray (CCTK_ARGUMENTS) coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; - + n = 0; for (j=0; j 0) { npoints = array3d_npoints_i * array3d_npoints_j * array3d_npoints_k; - + coordsx = malloc (npoints * sizeof * coordsx); assert (coordsx); coordsy = malloc (npoints * sizeof * coordsy); @@ -298,7 +302,7 @@ InterpToArray (CCTK_ARGUMENTS) coords[0] = coordsx; coords[1] = coordsy; coords[2] = coordsz; - + n = 0; for (k=0; k 0) { + group = CCTK_GroupIndex ("InterpToArray::parray1d"); + assert (group >= 0); + ierr = CCTK_GroupDynamicData (cctkGH, group, &dyndata); + assert (! ierr); + assert (dyndata.dim == 1); + npoints = dyndata.lsh[0]; + + coordsx = malloc (npoints * sizeof * coordsx); + assert (coordsx); + coordsy = malloc (npoints * sizeof * coordsy); + assert (coordsy); + coordsz = malloc (npoints * sizeof * coordsz); + assert (coordsz); + coords[0] = coordsx; + coords[1] = coordsy; + coords[2] = coordsz; + + n = 0; + for (i=0; i= 0); + if (inputs[n] < 0) { + inputs[n] = -1; + } + } + + output_types = malloc (nvars * sizeof * output_types); + assert (output_types); + + for (n=0; n 0) { + group = CCTK_GroupIndex ("InterpToArray::parray2d"); + assert (group >= 0); + ierr = CCTK_GroupDynamicData (cctkGH, group, &dyndata); + assert (! ierr); + assert (dyndata.dim == 2); + npoints = dyndata.lsh[0] * dyndata.lsh[1]; + + coordsx = malloc (npoints * sizeof * coordsx); + assert (coordsx); + coordsy = malloc (npoints * sizeof * coordsy); + assert (coordsy); + coordsz = malloc (npoints * sizeof * coordsz); + assert (coordsz); + coords[0] = coordsx; + coords[1] = coordsy; + coords[2] = coordsz; + + n = 0; + for (j=0; j 0) { + group = CCTK_GroupIndex ("InterpToArray::parray3d"); + assert (group >= 0); + ierr = CCTK_GroupDynamicData (cctkGH, group, &dyndata); + assert (! ierr); + assert (dyndata.dim == 3); + npoints = dyndata.lsh[0] * dyndata.lsh[1] * dyndata.lsh[2]; + + coordsx = malloc (npoints * sizeof * coordsx); + assert (coordsx); + coordsy = malloc (npoints * sizeof * coordsy); + assert (coordsy); + coordsz = malloc (npoints * sizeof * coordsz); + assert (coordsz); + coords[0] = coordsx; + coords[1] = coordsy; + coords[2] = coordsz; + + n = 0; + for (k=0; k