diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gr/expansion.cc | 5 | ||||
-rw-r--r-- | src/gr/gr.hh | 32 |
2 files changed, 31 insertions, 6 deletions
diff --git a/src/gr/expansion.cc b/src/gr/expansion.cc index 054e216..6bdb439 100644 --- a/src/gr/expansion.cc +++ b/src/gr/expansion.cc @@ -615,12 +615,13 @@ case geometry__local_interp_from_Cactus_grid: status = CCTK_InterpLocalUniform(N_GRID_DIMS, gi.operator_handle, gi.param_table_handle, - cgi.coord_origin, cgi.coord_delta, + cgi.global_coord_origin, + cgi.coord_delta, N_interp_points, interp_coords_type_code, interp_coords, N_input_arrays_use, - cgi.gridfn_dims, + cgi.local_gridfn_dims, input_array_type_codes, input_arrays, N_output_arrays_use, diff --git a/src/gr/gr.hh b/src/gr/gr.hh index 599008a..b6720ae 100644 --- a/src/gr/gr.hh +++ b/src/gr/gr.hh @@ -78,14 +78,38 @@ struct cactus_grid_info bool Cactus_conformal_metric; // Cactus coordinate system - fp coord_origin[N_GRID_DIMS]; // (x,y,z) of grid posn (0,0,0) - fp coord_delta[N_GRID_DIMS]; // (x,y,z) grid spacing + fp global_coord_origin[N_GRID_DIMS]; // global (x,y,z) + // = global origin + ijk*delta + fp local_coord_origin[N_GRID_DIMS]; // global (x,y,z) + // of (i,j,k) = (0,0,0) + // on this processor + fp coord_delta[N_GRID_DIMS]; // (x,y,z) grid spacing fp mean_coord_delta; // geometric mean of x,y,z grid spacings - // dimensions of gridfn data, viewed as a 3-D array + // dimensions of gridfn data on this processor, viewed as a 3-D array // n.b. storage ordering is Fortran, // i.e. i is contiguous, j has stride Ni, k has stride Ni*Nj - CCTK_INT gridfn_dims[N_GRID_DIMS]; + CCTK_INT local_gridfn_dims[N_GRID_DIMS]; + + // + // coordinate conversion functions + // here ijk = gridfn array indices on this processor + // xyz = floating-point global coordinates + // + + // convert integer ijk --> floating-point global xyz coordinates + fp global_xyz_of_ijk(int axis, int ijk) const + { return local_coord_origin[axis] + ijk*coord_delta[axis]; } + // convert floating-point global xyz --> integer ijk coordinates + // ... but as a floating-point number + fp fp_ijk_of_global_xyz(int axis, fp xyz) const + { return (xyz - local_coord_origin[axis]) / coord_delta[axis]; } + // convert floating-point global_xyz --> integer ijk coordinates + // ... rounding down/up to the next integer (= to the next grid point) + int ijk_floor_of_global_xyz(int axis, fp xyz) const + { return jtutil::ifloor(fp_ijk_of_global_xyz(axis, xyz)); } + int ijk_ceil_of_global_xyz (int axis, fp xyz) const + { return jtutil::iceil(fp_ijk_of_global_xyz(axis, xyz)); } // // stuff for doing a global interpolation via CCTK_InterpGridArrays() |