// patch_info.cc -- POD struct of minimal info varying from one patch to another // $Header$ // // patch_info::grid_array_pars // patch_info::grid_pars // #include #include #include #include "cctk.h" #include "config.h" #include "stdc.h" #include "../jtutil/util.hh" #include "../jtutil/array.hh" #include "../jtutil/cpm_map.hh" #include "../jtutil/linear_map.hh" #include "coords.hh" #include "grid.hh" #include "patch_info.hh" //****************************************************************************** //****************************************************************************** //****************************************************************************** // // This function computes, and returns a reference to, a // struct grid_arrays::grid_array_pars from the info in a // struct patch_info and the additional information in the arguments. // // The result refers to an internal static buffer in this function; the // usual caveats about lifetimes/overwriting apply. // // Arguments: // N_ghost_points = Width in grid points of all ghost zones. // N_extend_points = Number of grid points to extend each patch past // "just touching" so as to overlap neighboring patches. // Thus patches overlap by // N_overlap_points = 2*N_extend_points + 1 // grid points. For example, with N_extend_points == 2, // here are the grid points of two neighboring patches: // x x x x x X X // | // O O o o o o o // Here | marks the "just touching" boundary, // x and o the grid points before this extension, // and X and O the extra grid points added by this // extension. // delta_drho_dsigma = Grid spacing (both rho and sigma) in degrees. // const grid_arrays::grid_array_pars& patch_info::grid_array_pars(int N_ghost_points, int N_extend_points, fp delta_drho_dsigma) const { static struct grid_arrays::grid_array_pars grid_array_pars_buffer; grid_array_pars_buffer.min_irho = jtutil::round::to_integer(min_drho /delta_drho_dsigma); grid_array_pars_buffer.min_isigma = jtutil::round::to_integer(min_dsigma/delta_drho_dsigma); grid_array_pars_buffer.max_irho = grid_array_pars_buffer.min_irho + jtutil::round::to_integer( (max_drho -min_drho ) / delta_drho_dsigma ); grid_array_pars_buffer.max_isigma = grid_array_pars_buffer.min_isigma + jtutil::round::to_integer( (max_dsigma-min_dsigma) / delta_drho_dsigma ); grid_array_pars_buffer.min_irho -= N_extend_points; grid_array_pars_buffer.min_isigma -= N_extend_points; grid_array_pars_buffer.max_irho += N_extend_points; grid_array_pars_buffer.max_isigma += N_extend_points; grid_array_pars_buffer.min_rho_N_ghost_points = N_ghost_points; grid_array_pars_buffer.max_rho_N_ghost_points = N_ghost_points; grid_array_pars_buffer.min_sigma_N_ghost_points = N_ghost_points; grid_array_pars_buffer.max_sigma_N_ghost_points = N_ghost_points; return grid_array_pars_buffer; } //****************************************************************************** // // // This function computes, and returns a reference to, a // struct grid_arrays::grid_pars from the info in a struct patch_info // and the additional information in the arguments. // // The result refers to an internal static buffer in this function; the // usual caveats about lifetimes/overwriting apply. // // Arguments: // N_extend_points = Number of grid points to extend each patch past // "just touching" so as to overlap neighboring patches. // Thus patches overlap by 2*N_extend_points + 1 grid // points. For example, with N_extend_points == 2, here // are the grid points of two neighboring patches: // x x x x x X X // | // O O o o o o o // Here | marks the "just touching" boundary, // x and o the grid points before this extension, // and X and O the extra grid points added by this // extension. // delta_drho_dsigma = Grid spacing (both rho and sigma) in degrees. // const grid::grid_pars& patch_info::grid_pars(int N_extend_points, fp delta_drho_dsigma) const { static struct grid::grid_pars grid_pars_buffer; const fp extend_drho_dsigma = fp(N_extend_points) * delta_drho_dsigma; grid_pars_buffer. min_drho = min_drho - extend_drho_dsigma; grid_pars_buffer.delta_drho = delta_drho_dsigma; grid_pars_buffer. max_drho = max_drho + extend_drho_dsigma; grid_pars_buffer. min_dsigma = min_dsigma - extend_drho_dsigma; grid_pars_buffer.delta_dsigma = delta_drho_dsigma; grid_pars_buffer. max_dsigma = max_dsigma + extend_drho_dsigma; return grid_pars_buffer; }