From ef1462ab3f09add36d2997aeef30b62ace522ed7 Mon Sep 17 00:00:00 2001 From: rhaas Date: Thu, 31 May 2012 06:10:26 +0000 Subject: add support for CarpetInterp2 to InterpToArray git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/InterpToArray/trunk@27 6ca9aeac-0e4f-0410-a746-fe4df63e9d0c --- interface.ccl | 13 +++++ param.ccl | 14 +++++ src/interp.c | 94 ++++++++++++++++++++++++++++++--- test/test.ccl | 5 ++ test/wavetoy2.par | 88 ++++++++++++++++++++++++++++++ test/wavetoy2/arrays2d[0].maximum.asc | 3 ++ test/wavetoy2/arrays2d[0].minimum.asc | 3 ++ test/wavetoy2/arrays2d[0].norm1.asc | 3 ++ test/wavetoy2/arrays2d[0].norm2.asc | 3 ++ test/wavetoy2/arrays2d[0].norm_inf.asc | 3 ++ test/wavetoy2/arrays2d[0].x.asc | 6 +++ test/wavetoy2/arrays2d[0].y.asc | 7 +++ test/wavetoy2/arrays2d[0].z.asc | 3 ++ test/wavetoy2/parrays3d[0].d.asc | 5 ++ test/wavetoy2/parrays3d[0].maximum.asc | 3 ++ test/wavetoy2/parrays3d[0].minimum.asc | 3 ++ test/wavetoy2/parrays3d[0].norm1.asc | 3 ++ test/wavetoy2/parrays3d[0].norm2.asc | 3 ++ test/wavetoy2/parrays3d[0].norm_inf.asc | 3 ++ test/wavetoy2/parrays3d[0].x.asc | 6 +++ test/wavetoy2/parrays3d[0].y.asc | 7 +++ test/wavetoy2/parrays3d[0].z.asc | 9 ++++ 22 files changed, 280 insertions(+), 7 deletions(-) create mode 100644 test/test.ccl create mode 100644 test/wavetoy2.par create mode 100644 test/wavetoy2/arrays2d[0].maximum.asc create mode 100644 test/wavetoy2/arrays2d[0].minimum.asc create mode 100644 test/wavetoy2/arrays2d[0].norm1.asc create mode 100644 test/wavetoy2/arrays2d[0].norm2.asc create mode 100644 test/wavetoy2/arrays2d[0].norm_inf.asc create mode 100644 test/wavetoy2/arrays2d[0].x.asc create mode 100644 test/wavetoy2/arrays2d[0].y.asc create mode 100644 test/wavetoy2/arrays2d[0].z.asc create mode 100644 test/wavetoy2/parrays3d[0].d.asc create mode 100644 test/wavetoy2/parrays3d[0].maximum.asc create mode 100644 test/wavetoy2/parrays3d[0].minimum.asc create mode 100644 test/wavetoy2/parrays3d[0].norm1.asc create mode 100644 test/wavetoy2/parrays3d[0].norm2.asc create mode 100644 test/wavetoy2/parrays3d[0].norm_inf.asc create mode 100644 test/wavetoy2/parrays3d[0].x.asc create mode 100644 test/wavetoy2/parrays3d[0].y.asc create mode 100644 test/wavetoy2/parrays3d[0].z.asc diff --git a/interface.ccl b/interface.ccl index d6492de..2dfb8ca 100644 --- a/interface.ccl +++ b/interface.ccl @@ -2,6 +2,19 @@ IMPLEMENTS: InterpToArray +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) +USES FUNCTION InterpGridArrays + PUBLIC: REAL scalars[nscalars] TYPE=scalar diff --git a/param.ccl b/param.ccl index 5a1925a..8653b79 100644 --- a/param.ccl +++ b/param.ccl @@ -2,6 +2,8 @@ RESTRICTED: +# CCTK_InterpGridArrays parameters + STRING interpolator_name "Name of the interpolator" STEERABLE=always { ".*" :: "must be a registered interpolator" @@ -17,7 +19,19 @@ STRING interpolator_coordinates "Coordinate system" STEERABLE=always ".*" :: "must be a registered coordinate system" } "cart3d" +# InterpGridArrays ie. CarpetInterp2 parameters + +BOOLEAN use_carpetinterp2 "Use InterpGridArrays rather than CCTK_InterpGridArrays" STEERABLE=always +{ +} "no" + +INT carpetinterp2_interpolator_order "Order of interpolation for CarpetInterp2" STEERABLE=always +{ + 0:* :: "any order supported by CarpetInterp2" +} 2 + +# Common parameters INT nghosts "Number of ghost zones" { diff --git a/src/interp.c b/src/interp.c index d5d67b5..51c76a7 100644 --- a/src/interp.c +++ b/src/interp.c @@ -17,17 +17,26 @@ InterpToArray (CCTK_ARGUMENTS) - int const interpolator = CCTK_InterpHandle (interpolator_name); - assert (interpolator >= 0); - - int const options_table = Util_TableCreateFromString (interpolator_options); - assert (options_table >= 0); + int interpolator = -1; + if (!use_carpetinterp2) { + interpolator = CCTK_InterpHandle (interpolator_name); + assert (interpolator >= 0); + } - int const coord_handle = CCTK_CoordSystemHandle (interpolator_coordinates); - assert (coord_handle >= 0); + int options_table = -1; + if (!use_carpetinterp2) { + options_table = Util_TableCreateFromString (interpolator_options); + assert (options_table >= 0); + } + int coord_handle = -1; + if (!use_carpetinterp2) { + coord_handle = CCTK_CoordSystemHandle (interpolator_coordinates); + assert (coord_handle >= 0); + } + /* Scalars */ { int const nvars = nscalars; @@ -81,6 +90,16 @@ InterpToArray (CCTK_ARGUMENTS) outputs[n] = &scalars[npoints * n]; } + if (use_carpetinterp2) + { + int const ierr = InterpGridArrays + (cctkGH, 3, carpetinterp2_interpolator_order, + npoints, coords, + nvars, inputs, + nvars, outputs); + assert (! ierr); + } + else { int const ierr = CCTK_InterpGridArrays (cctkGH, 3, interpolator, options_table, coord_handle, @@ -185,6 +204,16 @@ InterpToArray (CCTK_ARGUMENTS) assert (! ierr); } + if (use_carpetinterp2) + { + int const ierr = InterpGridArrays + (cctkGH, 3, carpetinterp2_interpolator_order, + npoints, coords, + nvars, inputs, + nvars, outputs); + assert (! ierr); + } + else { int const ierr = CCTK_InterpGridArrays (cctkGH, 3, interpolator, options_table, coord_handle, @@ -275,6 +304,16 @@ InterpToArray (CCTK_ARGUMENTS) outputs[n] = &arrays2d[npoints * n]; } + if (use_carpetinterp2) + { + int const ierr = InterpGridArrays + (cctkGH, 3, carpetinterp2_interpolator_order, + npoints, coords, + nvars, inputs, + nvars, outputs); + assert (! ierr); + } + else { int const ierr = CCTK_InterpGridArrays (cctkGH, 3, interpolator, options_table, coord_handle, @@ -355,6 +394,16 @@ InterpToArray (CCTK_ARGUMENTS) outputs[n] = &arrays3d[npoints * n]; } + if (use_carpetinterp2) + { + int const ierr = InterpGridArrays + (cctkGH, 3, carpetinterp2_interpolator_order, + npoints, coords, + nvars, inputs, + nvars, outputs); + assert (! ierr); + } + else { int const ierr = CCTK_InterpGridArrays (cctkGH, 3, interpolator, options_table, coord_handle, @@ -470,6 +519,16 @@ InterpToArray (CCTK_ARGUMENTS) assert (! ierr); } + if (use_carpetinterp2) + { + int const ierr = InterpGridArrays + (cctkGH, 3, carpetinterp2_interpolator_order, + npoints, coords, + nvars, inputs, + nvars, outputs); + assert (! ierr); + } + else { int const ierr = CCTK_InterpGridArrays (cctkGH, 3, interpolator, options_table, coord_handle, @@ -574,6 +633,16 @@ InterpToArray (CCTK_ARGUMENTS) outputs[n] = &parrays2d[npoints * n]; } + if (use_carpetinterp2) + { + int const ierr = InterpGridArrays + (cctkGH, 3, carpetinterp2_interpolator_order, + npoints, coords, + nvars, inputs, + nvars, outputs); + assert (! ierr); + } + else { int const ierr = CCTK_InterpGridArrays (cctkGH, 3, interpolator, options_table, coord_handle, @@ -670,6 +739,16 @@ InterpToArray (CCTK_ARGUMENTS) outputs[n] = &parrays3d[npoints * n]; } + if (use_carpetinterp2) + { + int const ierr = InterpGridArrays + (cctkGH, 3, carpetinterp2_interpolator_order, + npoints, coords, + nvars, inputs, + nvars, outputs); + assert (! ierr); + } + else { int const ierr = CCTK_InterpGridArrays (cctkGH, 3, interpolator, options_table, coord_handle, @@ -690,6 +769,7 @@ InterpToArray (CCTK_ARGUMENTS) + if (options_table >= 0) { int const ierr = Util_TableDestroy (options_table); assert (! ierr); diff --git a/test/test.ccl b/test/test.ccl new file mode 100644 index 0000000..7202173 --- /dev/null +++ b/test/test.ccl @@ -0,0 +1,5 @@ +# Carpet output contains empty lines whose number depends the number of processes +TEST wavetoy2 +{ + NPROCS 2 +} diff --git a/test/wavetoy2.par b/test/wavetoy2.par new file mode 100644 index 0000000..a32dddf --- /dev/null +++ b/test/wavetoy2.par @@ -0,0 +1,88 @@ +!DESC "Test InterpToArray with WaveToy initial data" + +ActiveThorns = " + Boundary + CartGrid3D + CoordBase + IDScalarWaveC + CarpetIOASCII + CarpetIOBasic + CarpetIOScalar + IOUtil + InterpToArray + LocalReduce + Carpet + CarpetLib + GSl + LoopControl + InitBase + CarpetInterp2 + CarpetReduce + CarpetSlab + SymBase + WaveToyC +" + +Cactus::cctk_itlast = 0 + +driver::global_nx = 15 +driver::global_ny = 15 +driver::global_nz = 15 +driver::ghost_size = 2 + +grid::type = "byspacing" +grid::dxyz = 0.6 + +IDScalarWave::initial_data = "Gaussian" +IDScalarWave::sigma = 2.8 +IDScalarWave::radius = 5.0 + + + +InterpToArray::use_carpetinterp2 = "yes" +InterpToArray::carpetinterp2_interpolator_order = 2 + +InterpToArray::narrays2d = 1 +InterpToArray::array2d_vars[0] = "wavetoy::phi" +InterpToArray::array2d_x0 = -1.0 +InterpToArray::array2d_y0 = -1.0 +InterpToArray::array2d_z0 = -1.0 +InterpToArray::array2d_dx_i = 0.5 +InterpToArray::array2d_dy_j = 0.4 +InterpToArray::array2d_dz_j = 0.1 +InterpToArray::array2d_npoints_i = 3 +InterpToArray::array2d_npoints_j = 4 + +InterpToArray::nparrays3d = 1 +InterpToArray::parray3d_vars[0] = "wavetoy::phi" +InterpToArray::parray3d_x0 = -1.0 +InterpToArray::parray3d_y0 = -1.0 +InterpToArray::parray3d_z0 = -1.0 +InterpToArray::parray3d_dx_i = 0.5 +InterpToArray::parray3d_dy_j = 0.5 +InterpToArray::parray3d_dz_k = 0.5 +InterpToArray::parray3d_npoints_i = 3 +InterpToArray::parray3d_npoints_j = 4 +InterpToArray::parray3d_npoints_k = 5 + + + +IO::out_dir = $parfile +IO::parfile_write = "no" +IO::out_fileinfo = "none" + +IOScalar::outScalar_reductions = "norm1 norm2 minimum maximum norm_inf" +IOScalar::outScalar_every = 1 +IOScalar::outScalar_vars = " + InterpToArray::arrays2d[0] + InterpToArray::parrays3d[0] +" + +IOASCII::out1D_every = 1 +IOASCII::compact_format = "yes" +IOASCII::output_ghost_points = "no" +IOASCII::out1D_vars = " + InterpToArray::scalars + InterpToArray::arrays2d + InterpToArray::parrays3d +" diff --git a/test/wavetoy2/arrays2d[0].maximum.asc b/test/wavetoy2/arrays2d[0].maximum.asc new file mode 100644 index 0000000..a0f9244 --- /dev/null +++ b/test/wavetoy2/arrays2d[0].maximum.asc @@ -0,0 +1,3 @@ +# Scalar ASCII output created by CarpetIOScalar +# +0 0 0.255929043803271 diff --git a/test/wavetoy2/arrays2d[0].minimum.asc b/test/wavetoy2/arrays2d[0].minimum.asc new file mode 100644 index 0000000..eb12060 --- /dev/null +++ b/test/wavetoy2/arrays2d[0].minimum.asc @@ -0,0 +1,3 @@ +# Scalar ASCII output created by CarpetIOScalar +# +0 0 0.0981997271447794 diff --git a/test/wavetoy2/arrays2d[0].norm1.asc b/test/wavetoy2/arrays2d[0].norm1.asc new file mode 100644 index 0000000..8845a35 --- /dev/null +++ b/test/wavetoy2/arrays2d[0].norm1.asc @@ -0,0 +1,3 @@ +# Scalar ASCII output created by CarpetIOScalar +# +0 0 0.162223918469515 diff --git a/test/wavetoy2/arrays2d[0].norm2.asc b/test/wavetoy2/arrays2d[0].norm2.asc new file mode 100644 index 0000000..69182e8 --- /dev/null +++ b/test/wavetoy2/arrays2d[0].norm2.asc @@ -0,0 +1,3 @@ +# Scalar ASCII output created by CarpetIOScalar +# +0 0 0.168525955789019 diff --git a/test/wavetoy2/arrays2d[0].norm_inf.asc b/test/wavetoy2/arrays2d[0].norm_inf.asc new file mode 100644 index 0000000..a0f9244 --- /dev/null +++ b/test/wavetoy2/arrays2d[0].norm_inf.asc @@ -0,0 +1,3 @@ +# Scalar ASCII output created by CarpetIOScalar +# +0 0 0.255929043803271 diff --git a/test/wavetoy2/arrays2d[0].x.asc b/test/wavetoy2/arrays2d[0].x.asc new file mode 100644 index 0000000..d821c81 --- /dev/null +++ b/test/wavetoy2/arrays2d[0].x.asc @@ -0,0 +1,6 @@ +# 1D ASCII output created by CarpetIOASCII +# +0 0 0 0 0.255929043803271 +0 1 0 0 0.20945834089817 +0 2 0 0 0.193918918322488 + diff --git a/test/wavetoy2/arrays2d[0].y.asc b/test/wavetoy2/arrays2d[0].y.asc new file mode 100644 index 0000000..a7fd7ef --- /dev/null +++ b/test/wavetoy2/arrays2d[0].y.asc @@ -0,0 +1,7 @@ +# 1D ASCII output created by CarpetIOASCII +# +0 0 0 0 0.255929043803271 +0 0 1 0 0.204490368041785 +0 0 2 0 0.173853957866224 +0 0 3 0 0.164387756102711 + diff --git a/test/wavetoy2/arrays2d[0].z.asc b/test/wavetoy2/arrays2d[0].z.asc new file mode 100644 index 0000000..98bbcc6 --- /dev/null +++ b/test/wavetoy2/arrays2d[0].z.asc @@ -0,0 +1,3 @@ +# 1D ASCII output created by CarpetIOASCII +# +0 0 0 0 0.255929043803271 diff --git a/test/wavetoy2/parrays3d[0].d.asc b/test/wavetoy2/parrays3d[0].d.asc new file mode 100644 index 0000000..d537add --- /dev/null +++ b/test/wavetoy2/parrays3d[0].d.asc @@ -0,0 +1,5 @@ +# 1D ASCII output created by CarpetIOASCII +# +0 0 0 0 0 0 0 0 0.255929043803271 +0 1 1 1 0 1 1 1 0.111155027559738 +0 2 2 2 0 2 2 2 0.0575070381476306 diff --git a/test/wavetoy2/parrays3d[0].maximum.asc b/test/wavetoy2/parrays3d[0].maximum.asc new file mode 100644 index 0000000..a0f9244 --- /dev/null +++ b/test/wavetoy2/parrays3d[0].maximum.asc @@ -0,0 +1,3 @@ +# Scalar ASCII output created by CarpetIOScalar +# +0 0 0.255929043803271 diff --git a/test/wavetoy2/parrays3d[0].minimum.asc b/test/wavetoy2/parrays3d[0].minimum.asc new file mode 100644 index 0000000..b779824 --- /dev/null +++ b/test/wavetoy2/parrays3d[0].minimum.asc @@ -0,0 +1,3 @@ +# Scalar ASCII output created by CarpetIOScalar +# +0 0 0.0575070381476306 diff --git a/test/wavetoy2/parrays3d[0].norm1.asc b/test/wavetoy2/parrays3d[0].norm1.asc new file mode 100644 index 0000000..d3cbda7 --- /dev/null +++ b/test/wavetoy2/parrays3d[0].norm1.asc @@ -0,0 +1,3 @@ +# Scalar ASCII output created by CarpetIOScalar +# +0 0 0.147238120771799 diff --git a/test/wavetoy2/parrays3d[0].norm2.asc b/test/wavetoy2/parrays3d[0].norm2.asc new file mode 100644 index 0000000..bb2d29f --- /dev/null +++ b/test/wavetoy2/parrays3d[0].norm2.asc @@ -0,0 +1,3 @@ +# Scalar ASCII output created by CarpetIOScalar +# +0 0 0.154432972668436 diff --git a/test/wavetoy2/parrays3d[0].norm_inf.asc b/test/wavetoy2/parrays3d[0].norm_inf.asc new file mode 100644 index 0000000..a0f9244 --- /dev/null +++ b/test/wavetoy2/parrays3d[0].norm_inf.asc @@ -0,0 +1,3 @@ +# Scalar ASCII output created by CarpetIOScalar +# +0 0 0.255929043803271 diff --git a/test/wavetoy2/parrays3d[0].x.asc b/test/wavetoy2/parrays3d[0].x.asc new file mode 100644 index 0000000..729d4a3 --- /dev/null +++ b/test/wavetoy2/parrays3d[0].x.asc @@ -0,0 +1,6 @@ +# 1D ASCII output created by CarpetIOASCII +# +0 0 0 0 0 0.255929043803271 +0 1 0 0 0 0.20945834089817 +0 2 0 0 0 0.193918918322488 + diff --git a/test/wavetoy2/parrays3d[0].y.asc b/test/wavetoy2/parrays3d[0].y.asc new file mode 100644 index 0000000..282ade5 --- /dev/null +++ b/test/wavetoy2/parrays3d[0].y.asc @@ -0,0 +1,7 @@ +# 1D ASCII output created by CarpetIOASCII +# +0 0 0 0 0 0.255929043803271 +0 0 1 0 0 0.20945834089817 +0 0 2 0 0 0.193918918322488 +0 0 3 0 0 0.20945834089817 + diff --git a/test/wavetoy2/parrays3d[0].z.asc b/test/wavetoy2/parrays3d[0].z.asc new file mode 100644 index 0000000..e9c5ced --- /dev/null +++ b/test/wavetoy2/parrays3d[0].z.asc @@ -0,0 +1,9 @@ +# 1D ASCII output created by CarpetIOASCII +# +0 0 0 0 0 0.255929043803271 +0 0 0 1 0 0.20945834089817 +0 0 0 2 0 0.193918918322488 + +0 0 0 3 0 0.20945834089817 +0 0 0 4 0 0.255929043803271 + -- cgit v1.2.3