diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-04-07 13:13:26 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-04-07 13:13:26 +0000 |
commit | ec7974cd2a9ed540cc0022e365a13ff961c128aa (patch) | |
tree | 1200a74d20f1e0e1c852d98c3b0928e811f89a45 /src/patch | |
parent | 663881c6bbe0e73086237c8b932cda6fd1a41f7c (diff) |
many small mods to fix compiler-detected errors in 1st compiles after
the last few weeks rewrites --> not quite "clean compile" yet :(
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@457 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/patch')
-rw-r--r-- | src/patch/coords.cc | 2 | ||||
-rw-r--r-- | src/patch/coords.hh | 2 | ||||
-rw-r--r-- | src/patch/fd_grid.cc | 16 | ||||
-rw-r--r-- | src/patch/fd_grid.hh | 19 | ||||
-rw-r--r-- | src/patch/ghost_zone.cc | 45 | ||||
-rw-r--r-- | src/patch/ghost_zone.hh | 21 | ||||
-rw-r--r-- | src/patch/grid.cc | 40 | ||||
-rw-r--r-- | src/patch/grid.hh | 43 | ||||
-rw-r--r-- | src/patch/patch.cc | 77 | ||||
-rw-r--r-- | src/patch/patch.hh | 105 | ||||
-rw-r--r-- | src/patch/patch_edge.hh | 14 | ||||
-rw-r--r-- | src/patch/patch_interp.cc | 75 | ||||
-rw-r--r-- | src/patch/patch_interp.hh | 30 | ||||
-rw-r--r-- | src/patch/patch_system.cc | 9 | ||||
-rw-r--r-- | src/patch/patch_system.hh | 6 | ||||
-rw-r--r-- | src/patch/test_coords.cc | 4 | ||||
-rw-r--r-- | src/patch/test_coords2.cc | 2 | ||||
-rw-r--r-- | src/patch/test_patch_system.cc | 4 |
18 files changed, 266 insertions, 248 deletions
diff --git a/src/patch/coords.cc b/src/patch/coords.cc index d5417f3..aa20418 100644 --- a/src/patch/coords.cc +++ b/src/patch/coords.cc @@ -396,7 +396,7 @@ assert( fuzzy_EQ_ang(phi, ps_phi) ); // This function computes a human-readable name from a (mu,nu,phi) // coordinates set. // -const char *local_coords::name_of_coords_set(coords_set S) +const char* local_coords::name_of_coords_set(coords_set S) { // // we have to use an if-else chain because the local_coords::set_* diff --git a/src/patch/coords.hh b/src/patch/coords.hh index e795816..7a0b624 100644 --- a/src/patch/coords.hh +++ b/src/patch/coords.hh @@ -179,7 +179,7 @@ static const int set_empty = 0x0; static const int set_all = set_mu | set_nu | set_phi; // human-readable coordinate names for debugging etc -const char *name_of_coords_set(coords_set S); +const char* name_of_coords_set(coords_set S); // set complement of coordinates inline diff --git a/src/patch/fd_grid.cc b/src/patch/fd_grid.cc index 5748b4e..4bb9480 100644 --- a/src/patch/fd_grid.cc +++ b/src/patch/fd_grid.cc @@ -10,10 +10,10 @@ #include <math.h> #include "jt/stdc.h" -#include "jt/util.hh" // jtutil::how_many_in_range(), - // round<fp>::, fuzzy<fp>:: +#include "jt/util.hh" #include "jt/array.hh" #include "jt/linear_map.hh" +using jtutil::error_exit; #include "fp.hh" #include "coords.hh" @@ -26,8 +26,8 @@ // This function computes a single coefficient of a 1st derivative // molecule, for unit grid spacing. // -fp dx_coeff(int m) - const +//static + fp fd_grid::dx_coeff(int m) { #ifndef FINITE_DIFF_ORDER #error "must define FINITE_DIFF_ORDER!" @@ -51,7 +51,7 @@ switch (m) default: error_exit(ERROR_EXIT, "***** fd_grid::dx_coeff(): m=%d is outside order=%d molecule radius=%d\n", - m, FD_GRID__ORDER, FD_GRID__ORDER2__MOL_RADIUS); + m, FINITE_DIFF_ORDER, FD_GRID__MOL_RADIUS); } } @@ -61,8 +61,8 @@ default: // This function computes a single coefficient of a 2nd derivative // molecule, for unit grid spacing. // -fp dxx_coeff(int m) - const +//static + fp fd_grid::dxx_coeff(int m) { #ifndef FINITE_DIFF_ORDER #error "must define FINITE_DIFF_ORDER!" @@ -86,6 +86,6 @@ switch (m) default: error_exit(ERROR_EXIT, "***** fd_grid::dxx_coeff(): m=%d is outside order=%d molecule radius=%d\n", - m, FINITE_DIFF_ORDER, FD_GRID__ORDER2__MOL_RADIUS); + m, FINITE_DIFF_ORDER, FD_GRID__MOL_RADIUS); } } diff --git a/src/patch/fd_grid.hh b/src/patch/fd_grid.hh index 1d75c0c..c7741a5 100644 --- a/src/patch/fd_grid.hh +++ b/src/patch/fd_grid.hh @@ -356,11 +356,11 @@ class fd_grid : public grid { -private: // // helper functions to compute (irho,isigma) + [m] // along each axis // +private: static int rho_axis__irho_plus_m(int irho , int m) { return irho +m; } static @@ -371,10 +371,10 @@ private: int sigma_axis__isigma_plus_m(int isigma, int m) { return isigma+m; } -public: // // ***** finite differencing ***** // +public: // 1st derivatives fp partial_rho(int gfn, int irho, int isigma) @@ -425,12 +425,13 @@ public: // // ***** molecule orders, sizes, and coefficients ***** // +public: // n.b. this interface implicitly assumes that all molecules // are the same order and size int finite_diff_order() const { return FINITE_DIFF_ORDER; } - int molecule_radius() const { return FD_GRID__MOLECULE_RADIUS; } - int molecule_diameter() const { return FD_GRID__MOLECULE_DIAMETER; } + int molecule_radius() const { return FD_GRID__MOL_RADIUS; } + int molecule_diameter() const { return FD_GRID__MOL_DIAMETER; } // molecule coefficients // n.b. this interface implicitly assumes that all molecules @@ -448,15 +449,17 @@ public: return partial_rho_coeff(m_rho) * partial_sigma_coeff(m_sigma); } -private: // worker functions: molecule coefficients for unit grid spacing - fp dx_coeff(int m) const; - fp dxx_coeff(int m) const; +private: + static + fp dx_coeff(int m); + static + fp dxx_coeff(int m); -public: // // ***** constructor, destructor ***** // +public: // constructor: pass through to grid:: constructor fd_grid(const grid_array_pars& grid_array_pars_in, diff --git a/src/patch/ghost_zone.cc b/src/patch/ghost_zone.cc index bb3e99e..d41c26c 100644 --- a/src/patch/ghost_zone.cc +++ b/src/patch/ghost_zone.cc @@ -17,16 +17,17 @@ #include <stdio.h> #include <assert.h> +#include <stdlib.h> #include <limits.h> #include <math.h> +#include "cctk.h" + #include "jt/stdc.h" #include "jt/util.hh" #include "jt/array.hh" #include "jt/cpm_map.hh" #include "jt/linear_map.hh" -#include "jt/interpolate.hh" - using jtutil::error_exit; #include "fp.hh" @@ -164,7 +165,7 @@ interpatch_ghost_zone::interpatch_ghost_zone(const patch_edge& my_edge_in, : ghost_zone(my_edge_in, ghost_zone_is_interpatch), other_patch_(other_edge_in.my_patch()), other_edge_(other_edge_in), - other_frontier_(NULL), // set by setup_other_frontier() + other_frontier_(NULL), // set by setup_other_patch_frontier() // remaining subobjects are all set properly in ctor body other_iperp_(NULL), other_min_iperp_(0), other_max_iperp_(0), @@ -274,7 +275,7 @@ const fp fp_other_sample_iperp = other_edge() .fp_iperp_of_perp(other_sample_perp); // verify that this is fuzzily a grid point -if (! fuzzy<fp>::is_integer(fp_other_sample_iperp)) +if (! jtutil::fuzzy<fp>::is_integer(fp_other_sample_iperp)) then error_exit(ERROR_EXIT, "***** interpatch_ghost_zone::interpatch_ghost_zone:\n" " my_patch().name()=\"%s\" my_edge().name()=%s\n" @@ -321,12 +322,12 @@ other_max_iperp_ = jtutil::max(other_iperp(min_iperp()), // ... we will pass these arrays by reference to the other patch's // patch_frontier object, with ipar being parindex there // -min_ipar_used_ = new array1d<int>(other_min_iperp_, other_max_iperp_); -max_ipar_used_ = new array1d<int>(other_min_iperp_, other_max_iperp_); +min_ipar_used_ = new jtutil::array1d<int>(other_min_iperp_, other_max_iperp_); +max_ipar_used_ = new jtutil::array1d<int>(other_min_iperp_, other_max_iperp_); for (int iperp = min_iperp() ; iperp <= max_iperp() ; ++iperp) { - min_ipar_used_(other_iperp(iperp)) = min_ipar(iperp); - max_ipar_used_(other_iperp(iperp)) = max_ipar(iperp); + (*min_ipar_used_)(other_iperp(iperp)) = min_ipar(iperp); + (*max_ipar_used_)(other_iperp(iperp)) = max_ipar(iperp); } @@ -339,8 +340,9 @@ max_ipar_used_ = new array1d<int>(other_min_iperp_, other_max_iperp_); // (since that depends on the type of our patch's adjacent ghost zones) // ==> we include the corners on the chance we may want them later, // and use the appropriate parts of them in synchronize() below -other_par_ = new array2d<fp>(other_min_iperp_, other_max_iperp_, - ghost_zone_min_ipar(), ghost_zone_max_ipar()); +other_par_ = new jtutil::array2d<fp> + (other_min_iperp_, other_max_iperp_, + ghost_zone_min_ipar(), ghost_zone_max_ipar()); for (int iperp = min_iperp() ; iperp <= max_iperp() ; ++iperp) { @@ -362,7 +364,7 @@ other_par_ = new array2d<fp>(other_min_iperp_, other_max_iperp_, const fp other_par = other_patch() .modulo_reduce_ang(other_edge().par_is_rho(), tau); - other_par_(other_iperp(iperp),ipar) = other_par; + (*other_par_)(other_iperp(iperp),ipar) = other_par; } } @@ -371,8 +373,8 @@ other_par_ = new array2d<fp>(other_min_iperp_, other_max_iperp_, // set up interpolation result buffer // interp_result_buffer_ - = new array3d<fp> - (my_patch().min_ghosted_gfn(), my_patch().max_ghosted_gfn(), + = new jtutil::array3d<fp> + (my_patch().ghosted_min_gfn(), my_patch().ghosted_max_gfn(), other_min_iperp_, other_max_iperp_, ghost_zone_min_ipar(), ghost_zone_max_ipar()); } @@ -385,7 +387,7 @@ interp_result_buffer_ interpatch_ghost_zone::~interpatch_ghost_zone() { delete interp_result_buffer_; -deleete other_par_; +delete other_par_; delete max_ipar_used_; delete min_ipar_used_; delete other_iperp_; @@ -440,10 +442,9 @@ return max_par_adjacent_ghost_zone().is_symmetry() void interpatch_ghost_zone::setup_other_patch_frontier (int interp_handle, int interp_par_table_handle) { -const other_frontier_ +other_frontier_ = new patch_frontier(other_edge(), other_min_iperp_, other_max_iperp_, - ghost_zone_min_ipar(), ghost_zone_max_ipar(), *min_ipar_used_, *max_ipar_used_, *other_par_, interp_handle, interp_par_table_handle); @@ -500,16 +501,16 @@ if (! (want_min_par_corner && want_non_corner && want_max_par_corner)) " want_max_par_corner=(int)%d\n" , ghosted_min_gfn, ghosted_max_gfn, - bool want_min_par_corner, - bool want_non_corner, - bool want_max_par_corner); /*NOTREACHED*/ + want_min_par_corner, + want_non_corner, + want_max_par_corner); /*NOTREACHED*/ // do the interpolation into our result buffer other_frontier_->interpolate(ghosted_min_gfn, ghosted_max_gfn, - interp_result_buffer_); + *interp_result_buffer_); // store the results back into our gridfns - for (int gfn = ghosted_min_gfn, gfn <= ghosted_max_gfn ; ++gfn) + for (int gfn = ghosted_min_gfn ; gfn <= ghosted_max_gfn ; ++gfn) { for (int iperp = min_iperp() ; iperp <= max_iperp() ; ++iperp) { @@ -518,7 +519,7 @@ other_frontier_->interpolate(ghosted_min_gfn, ghosted_max_gfn, int irho = my_edge(). irho_of_iperp_ipar(iperp,ipar); int isigma = my_edge().isigma_of_iperp_ipar(iperp,ipar); my_patch().ghosted_gridfn(gfn, irho,isigma) - = interp_result_buffer_(gfn, iperp,ipar); + = (*interp_result_buffer_)(gfn, iperp,ipar); } } } diff --git a/src/patch/ghost_zone.hh b/src/patch/ghost_zone.hh index ef1bc32..6020166 100644 --- a/src/patch/ghost_zone.hh +++ b/src/patch/ghost_zone.hh @@ -396,8 +396,7 @@ public: bool want_min_par_corner, bool want_noncorner, bool want_max_par_corner) - const - = 0; + const; // low-level client interface: symmetry-map coordinates const patch& symmetry_patch() const { return symmetry_patch_; } @@ -443,8 +442,8 @@ private: // symmetry mappings for (iperp,ipar) // ... we own these objects - const jtutil::cpm_map<fp> *iperp_map_; - const jtutil::cpm_map<fp> *ipar_map_; + const jtutil::cpm_map<fp>* iperp_map_; + const jtutil::cpm_map<fp>* ipar_map_; }; //***************************************************************************** @@ -488,8 +487,7 @@ public: bool want_min_par_corner, bool want_noncorner, bool want_max_par_corner) - const - = 0; + const; // basic connectivity info const patch& other_patch() const @@ -512,8 +510,8 @@ public: // construct *other* patch's frontier, // interlink it with this ghost zone and the other patch - void setup_other_frontier(int interp_handle, - int interp_par_table_handle); + void setup_other_patch_frontier(int interp_handle, + int interp_par_table_handle); // assert() that frontier pointer is non-NULL, // that other patch has interpatch ghost zone on this edge, @@ -538,9 +536,10 @@ private: const patch_edge& other_edge_; // initialized to NULL in constructor, - // set to proper value by setup_other_frontier() + // set to proper value by setup_other_patch_frontier() // ... we do *not* own this object (the other patch does)! - const patch_frontier *other_frontier_; + // ... see comment in "patch_frontier.hh" for why this is "const" + const patch_frontier* other_frontier_; // // our remaining subobjects are all pointed-to because @@ -551,7 +550,7 @@ private: // other patch's iperp coordinates of our ghost zone points // ... maps my_iperp --> other_iperp - jtutil::cpm_map<fp> *other_iperp_; + jtutil::cpm_map<fp>* other_iperp_; // other patch's [min,max]_iperp of our ghost zone points int other_min_iperp_, other_max_iperp_; diff --git a/src/patch/grid.cc b/src/patch/grid.cc index dc58ea6..8812ab1 100644 --- a/src/patch/grid.cc +++ b/src/patch/grid.cc @@ -13,8 +13,7 @@ #include <math.h> #include "jt/stdc.h" -#include "jt/util.hh" // jtutil::how_many_in_range(), - // round<fp>::, fuzzy<fp>:: +#include "jt/util.hh" #include "jt/array.hh" #include "jt/linear_map.hh" @@ -34,10 +33,9 @@ grid_arrays::grid_arrays(const grid_array_pars& grid_array_pars_in) : gridfn_data_(NULL), ghosted_gridfn_data_(NULL), - min_gfn_(gridfn_pars_in.min_gfn_in), - max_gfn_(gridfn_pars_in.max_gfn_in), - ghosted_min_gfn_(gridfn_pars_in.ghosted_min_gfn_in), - ghosted_max_gfn_(gridfn_pars_in.ghosted_max_gfn_in), + // these are all set properly by setup_gridfn_storage() + min_gfn_(0), max_gfn_(0), + ghosted_min_gfn_(0), ghosted_max_gfn_(0), min_irho_(grid_array_pars_in.min_irho), max_irho_(grid_array_pars_in.max_irho), @@ -62,33 +60,25 @@ grid_arrays::grid_arrays(const grid_array_pars& grid_array_pars_in) // void grid_arrays::setup_gridfn_storage (const gridfn_pars& gridfn_pars_in, - const gridfn_pars& ghosted_gridfn_pars_in, + const gridfn_pars& ghosted_gridfn_pars_in) { assert(gridfn_data_ == NULL); -gridfn_data_ = new jtutil::array3d<fp>(gridfn_pars_in.min_gfn_in, - gridfn_pars_in.max_gfn_in, - grid_array_pars_in.min_irho, - grid_array_pars_in.max_irho, - grid_array_pars_in.min_isigma, - grid_array_pars_in.max_isigma, +gridfn_data_ = new jtutil::array3d<fp>(gridfn_pars_in.min_gfn, + gridfn_pars_in.max_gfn, + min_irho(), max_irho(), + min_isigma(), max_isigma(), gridfn_pars_in.storage_array, gridfn_pars_in.gfn_stride, gridfn_pars_in.irho_stride, gridfn_pars_in.isigma_stride); -assert(ghosted_gridfn_data == NULL); -ghosted_gridfn_data +assert(ghosted_gridfn_data_ == NULL); +ghosted_gridfn_data_ = new jtutil::array3d<fp> - (gridfn_pars_in.ghosted_min_gfn_in, - gridfn_pars_in.ghosted_max_gfn_in, - grid_array_pars_in.min_irho - - grid_array_pars_in.min_rho_N_ghost_points, - grid_array_pars_in.max_irho - + grid_array_pars_in.max_rho_N_ghost_points, - grid_array_pars_in.min_isigma - - grid_array_pars_in.min_sigma_N_ghost_points, - grid_array_pars_in.max_isigma - + grid_array_pars_in.max_sigma_N_ghost_points, + (ghosted_gridfn_pars_in.min_gfn, + ghosted_gridfn_pars_in.max_gfn, + ghosted_min_irho(), ghosted_max_irho(), + ghosted_min_isigma(), ghosted_max_isigma(), ghosted_gridfn_pars_in.storage_array, ghosted_gridfn_pars_in.gfn_stride, ghosted_gridfn_pars_in.irho_stride, diff --git a/src/patch/grid.hh b/src/patch/grid.hh index 804534f..a8220f4 100644 --- a/src/patch/grid.hh +++ b/src/patch/grid.hh @@ -94,9 +94,9 @@ public: static const bool side_is_sigma = false; // human-readable names for the sides (for debugging) - static const char *minmax_name(bool minmax) + static const char* minmax_name(bool minmax) { return minmax ? "min" : "max"; } - static const char *iang_name(bool want_rho) + static const char* iang_name(bool want_rho) { return want_rho ? "irho" : "isigma"; } @@ -406,7 +406,7 @@ public: // gridfn storage will be automatically allocated // if pointer is NULL; any 0 strides are automatically // set to C-style row-major subscripting - fp *storage_array; + fp* storage_array; int gfn_stride, irho_stride, isigma_stride; }; @@ -437,8 +437,8 @@ private: // n.b. these pointers are *first* data member in this class // ==> possibly slightly faster access (0 offset from pointer) // ... indices are (gfn, irho, isigma) - jtutil::array3d<fp> *gridfn_data_; - jtutil::array3d<fp> *ghosted_gridfn_data_; + jtutil::array3d<fp>* gridfn_data_; + jtutil::array3d<fp>* ghosted_gridfn_data_; // gfn bounds const int min_gfn_, max_gfn_; @@ -479,9 +479,9 @@ class grid public: // direct (read-only) access to the underlying linear_map objects // ... useful for (eg) passing to interpolators - const linear_map<fp>& rho_map() const { return rho_map_; } - const linear_map<fp>& sigma_map() const { return sigma_map_; } - const linear_map<fp>& ang_map(bool want_rho) const + const jtutil::linear_map<fp>& rho_map() const { return rho_map_; } + const jtutil::linear_map<fp>& sigma_map() const { return sigma_map_; } + const jtutil::linear_map<fp>& ang_map(bool want_rho) const { return want_rho ? rho_map() : sigma_map(); } @@ -501,14 +501,14 @@ public: fp fp_irho_of_rho(fp rho) const { return rho_map().fp_int_of_fp(rho); } - int irho_of_rho(fp rho, linear_map<fp>::noninteger_action - nia = linear_map<fp>::error) + int irho_of_rho(fp rho, jtutil::linear_map<fp>::noninteger_action + nia = jtutil::linear_map<fp>::error) const { return rho_map().int_of_fp(rho, nia); } fp fp_isigma_of_sigma(fp sigma) const { return sigma_map().fp_int_of_fp(sigma); } - int isigma_of_sigma(fp sigma, linear_map<fp>::noninteger_action - nia = linear_map<fp>::error) + int isigma_of_sigma(fp sigma, jtutil::linear_map<fp>::noninteger_action + nia = jtutil::linear_map<fp>::error) const { return sigma_map().int_of_fp(sigma, nia); } fp fp_iang_of_ang(bool want_rho, fp ang) @@ -518,8 +518,8 @@ public: : fp_isigma_of_sigma(ang); } int iang_of_ang(bool want_rho, - fp ang, linear_map<fp>::noninteger_action - nia = linear_map<fp>::error) + fp ang, jtutil::linear_map<fp>::noninteger_action + nia = jtutil::linear_map<fp>::error) const { return want_rho ? irho_of_rho(ang, nia) @@ -532,12 +532,13 @@ public: fp dsigma_of_isigma(int isigma) const { return jtutil::degrees_of_radians(sigma_of_isigma(isigma)); } - int irho_of_drho(fp drho, linear_map<fp>::noninteger_action - nia = linear_map<fp>::error) + int irho_of_drho(fp drho, jtutil::linear_map<fp>::noninteger_action + nia = jtutil::linear_map<fp>::error) const { return irho_of_rho(jtutil::radians_of_degrees(drho), nia); } - int isigma_of_dsigma(fp dsigma, linear_map<fp>::noninteger_action - nia = linear_map<fp>::error) + int isigma_of_dsigma(fp dsigma, + jtutil::linear_map<fp>::noninteger_action + nia = jtutil::linear_map<fp>::error) const { return isigma_of_sigma(jtutil::radians_of_degrees(dsigma), nia); @@ -622,9 +623,9 @@ public: // public: // human-readable names for the sides (for debugging) - static const char *ang_name(bool want_rho) + static const char* ang_name(bool want_rho) { return want_rho ? "rho" : "sigma"; } - static const char *dang_name(bool want_rho) + static const char* dang_name(bool want_rho) { return want_rho ? "drho" : "dsigma"; } @@ -657,7 +658,7 @@ private: private: // range of these is the full grid (including ghost zones) - const linear_map<fp> rho_map_, sigma_map_; + const jtutil::linear_map<fp> rho_map_, sigma_map_; // angular boundaries of nominal grid const fp min_rho_, max_rho_; diff --git a/src/patch/patch.cc b/src/patch/patch.cc index 62b76b3..02d7338 100644 --- a/src/patch/patch.cc +++ b/src/patch/patch.cc @@ -28,18 +28,19 @@ #include <assert.h> #include <math.h> +#include "cctk.h" + #include "jt/stdc.h" #include "jt/util.hh" #include "jt/array.hh" #include "jt/cpm_map.hh" #include "jt/linear_map.hh" -#include "jt/interpolate.hh" - using jtutil::error_exit; #include "fp.hh" #include "coords.hh" #include "grid.hh" +#include "fd_grid.hh" #include "patch.hh" #include "patch_edge.hh" #include "ghost_zone.hh" @@ -53,7 +54,7 @@ using jtutil::error_exit; // This function constructs a patch object. // patch::patch(patch_system &my_patch_system_in, int patch_number_in, - const char *name_in, bool is_plus_in, char ctype_in, + const char* name_in, bool is_plus_in, char ctype_in, local_coords::coords_set coords_set_rho_in, local_coords::coords_set coords_set_sigma_in, local_coords::coords_set coords_set_tau_in, @@ -62,8 +63,10 @@ patch::patch(patch_system &my_patch_system_in, int patch_number_in, : fd_grid(grid_array_pars_in, grid_pars_in), - my_patch_system_(my_patch_system_in), patch_number_(patch_number_in), - name_(name_in), is_plus_(is_plus_in), ctype_(ctype_in), + my_patch_system_(my_patch_system_in), + patch_number_(patch_number_in), + name_(name_in), + is_plus_(is_plus_in), ctype_(ctype_in), coords_set_rho_ (coords_set_rho_in ), coords_set_sigma_(coords_set_sigma_in), @@ -71,10 +74,10 @@ patch::patch(patch_system &my_patch_system_in, int patch_number_in, min_rho_patch_edge_(*new patch_edge(*this, side_is_min, side_is_rho)), max_rho_patch_edge_(*new patch_edge(*this, side_is_max, side_is_rho)), - min_sigma_patch_edge_(*new patch_edge(*this, - side_is_min, side_is_sigma)), - max_sigma_patch_edge_(*new patch_edge(*this, - side_is_max, side_is_sigma)), + min_sigma_patch_edge_ + (*new patch_edge(*this, side_is_min, side_is_sigma)), + max_sigma_patch_edge_ + (*new patch_edge(*this, side_is_max, side_is_sigma)), min_rho_ghost_zone_(NULL), max_rho_ghost_zone_(NULL), @@ -119,7 +122,7 @@ delete & min_rho_patch_edge_; // This function constructs a z_patch object. // z_patch::z_patch(patch_system &my_patch_system_in, int patch_number_in, - const char *name_in, bool is_plus_in, + const char* name_in, bool is_plus_in, const grid_arrays::grid_array_pars& grid_array_pars_in, const grid::grid_pars& grid_pars_in) : patch(my_patch_system_in, patch_number_in, @@ -135,7 +138,7 @@ z_patch::z_patch(patch_system &my_patch_system_in, int patch_number_in, // This function constructs an x_patch object. // x_patch::x_patch(patch_system &my_patch_system_in, int patch_number_in, - const char *name_in, bool is_plus_in, + const char* name_in, bool is_plus_in, const grid_arrays::grid_array_pars& grid_array_pars_in, const grid::grid_pars& grid_pars_in) : patch(my_patch_system_in, patch_number_in, @@ -151,7 +154,7 @@ x_patch::x_patch(patch_system &my_patch_system_in, int patch_number_in, // This function constructs a y_patch object. // y_patch::y_patch(patch_system &my_patch_system_in, int patch_number_in, - const char *name_in, bool is_plus_in, + const char* name_in, bool is_plus_in, const grid_arrays::grid_array_pars& grid_array_pars_in, const grid::grid_pars& grid_pars_in) : patch(my_patch_system_in, patch_number_in, @@ -285,13 +288,13 @@ return *temp; // void patch::set_ghost_zone(const patch_edge& edge, ghost_zone* gzp) { -ghost_zone*& gzp +ghost_zone*& ghost_zone_ptr_to_set = edge.is_min() ? (edge.is_rho() ? min_rho_ghost_zone_ : min_sigma_ghost_zone_) : (edge.is_rho() ? max_rho_ghost_zone_ : max_sigma_ghost_zone_); -assert(gzp == NULL); -gzp = gzp; +assert(ghost_zone_ptr_to_set == NULL); +ghost_zone_ptr_to_set = gzp; } //****************************************************************************** @@ -302,16 +305,18 @@ gzp = gzp; // This function assert()s that one of the patch frontier pointers // (which one is selected by edge ) is NULL, then stores a value in it. // -void patch::set_patch_frontier(const patch_edge& edge, patch_frontier* pfp) +void patch::set_patch_frontier(const patch_edge& edge, + const patch_frontier* pfp) + const { -patch_frontier*& pfp = edge.is_min() - ? (edge.is_rho() ? min_rho_patch_frontier_ - : min_sigma_patch_frontier_) - : (edge.is_rho() ? max_rho_patch_frontier_ - : max_sigma_patch_frontier_); - -assert(pfp == NULL); -pfp = pfp; +const patch_frontier*& patch_frontier_ptr_to_set + = edge.is_min() ? (edge.is_rho() ? min_rho_patch_frontier_ + : min_sigma_patch_frontier_) + : (edge.is_rho() ? max_rho_patch_frontier_ + : max_sigma_patch_frontier_); + +assert(patch_frontier_ptr_to_set == NULL); +patch_frontier_ptr_to_set = pfp; } //****************************************************************************** @@ -371,8 +376,9 @@ if ((common_is_q_rho ^ common_is_q_sigma) != 0x1) /*NOTREACHED*/ // how much do the patches overlap? -if ((N_overlap_points != 0) && fuzzy<fp>::NE(p.delta_dang(common_is_p_rho), - q.delta_dang(common_is_q_rho))) +if ( (N_overlap_points != 0) + && jtutil::fuzzy<fp>::NE(p.delta_dang(common_is_p_rho), + q.delta_dang(common_is_q_rho)) ) then error_exit(ERROR_EXIT, "***** patch::edge_adjacent_to_patch():\n" " N_overlap_points != 0 must have same perp grid spacing in both patches!\n" @@ -510,25 +516,25 @@ fprintf(output_fp, "# dpx\tdpy\tgridfn\tirho\tisigma\n"); // 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 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; +static + struct grid_arrays::grid_array_pars grid_array_pars_buffer; grid_array_pars_buffer.min_irho = jtutil::round<fp>::to_integer(min_drho /delta_drho_dsigma); grid_array_pars_buffer.min_isigma = jtutil::round<fp>::to_integer(min_dsigma/delta_drho_dsigma); grid_array_pars_buffer.max_irho - = array_pars.min_irho + = grid_array_pars_buffer.min_irho + jtutil::round<fp>::to_integer( (max_drho -min_drho ) / delta_drho_dsigma ); grid_array_pars_buffer.max_isigma - = array_pars.min_isigma + = grid_array_pars_buffer.min_isigma + jtutil::round<fp>::to_integer( (max_dsigma-min_dsigma) / delta_drho_dsigma ); @@ -544,7 +550,6 @@ grid_array_pars_buffer.max_sigma_N_ghost_points = N_ghost_points; return grid_array_pars_buffer; } - } //****************************************************************************** // @@ -575,7 +580,8 @@ 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; +static + struct grid::grid_pars grid_pars_buffer; const fp extend_drho_dsigma = fp(N_extend_points) * delta_drho_dsigma; @@ -588,4 +594,3 @@ grid_pars_buffer. max_dsigma = max_dsigma + extend_drho_dsigma; return grid_pars_buffer; } - } diff --git a/src/patch/patch.hh b/src/patch/patch.hh index bef630d..90c31d3 100644 --- a/src/patch/patch.hh +++ b/src/patch/patch.hh @@ -21,6 +21,7 @@ // "fp.hh" // "coords.hh" // "grid.hh" +// "fd_grid.hh" // //***************************************************************************** @@ -149,7 +150,7 @@ public: int patch_number() const { return patch_number_; } // each patch has a unique human-readable patch name for debugging etc - const char *name() const { return name_; } // typically "+z" etc + const char* name() const { return name_; } // typically "+z" etc // are we a +[xyz] or -[xyz] patch? bool is_plus() const { return is_plus_; } @@ -181,8 +182,8 @@ public: // (rho,sigma) coordinates as human-readable character strings // (for labelling output files etc) - virtual const char *name_of_rho() const = 0; - virtual const char *name_of_sigma() const = 0; + virtual const char* name_of_rho() const = 0; + virtual const char* name_of_sigma() const = 0; // @@ -225,8 +226,8 @@ public: // ... character string describing how (dpx,dpy) are // defined in terms of (mu,nu,phi), eg "90 - drho = 90 - dphi" // (used for labelling output files) - virtual const char *name_of_dpx() const = 0; - virtual const char *name_of_dpy() const = 0; + virtual const char* name_of_dpx() const = 0; + virtual const char* name_of_dpy() const = 0; // ... (irho,isimga) --> (px,py) virtual fp dpx_of_rho_sigma(fp rho, fp sigma) const = 0; virtual fp dpy_of_rho_sigma(fp rho, fp sigma) const = 0; @@ -301,7 +302,6 @@ public: const; - // // ***** set up ghost zone and frontier subobjects // @@ -333,6 +333,7 @@ public: // are fully setup void assert_all_ghost_zones_fully_setup() const; + // // ***** access to ghost zone/frontier pointers ***** // @@ -344,12 +345,30 @@ private: // then assign new value to it void set_ghost_zone(const patch_edge& edge, ghost_zone* gzp); - // helper function for (friend) + // this function is used only by // interpatch_ghost_zone::setup_other_patch_frontier(): - // assert() that patch frontier pointer on specified edge is NULL - // (i.e. that we haven't already setup this patch frontier), - // then assign new value to it - void set_patch_frontier(const patch_edge& edge, patch_frontier *pfp); + // it assert() that the patch frontier pointer on the specified edge + // is NULL (i.e. that we haven't already setup this patch frontier), + // then assigns a new value to it + // + // ... this function is const since it doesn't alter this + // patch's gridfn values + // + // KLUDGE: + // ... this function should really be private, and + // interpatch_ghost_zone::setup_other_patch_frontier(): + // be declared a friend of this class, but .cc files need + // to #include this header file ("patch.hh") before + // "ghost_zone.hh" to get inline functions properly inlined, + // so there's no clean way to make + // interpatch_ghost_zone::setup_other_patch_frontier(): + // a friend here ==> we just make it public for now :( :( + // +public: + void set_patch_frontier(const patch_edge& edge, + const patch_frontier* pfp) + const; + // // ***** constructor, destructor, et al ***** @@ -360,7 +379,7 @@ protected: // depends on knowing our neighbouring patches, which may // not exist yet patch(patch_system &my_patch_system_in, int patch_number_in, - const char *name_in, bool is_plus_in, char ctype_in, + const char* name_in, bool is_plus_in, char ctype_in, local_coords::coords_set coords_set_rho_in, local_coords::coords_set coords_set_sigma_in, local_coords::coords_set coords_set_tau_in, @@ -371,13 +390,6 @@ public: // of derived classes via ptr/ref to this class virtual ~patch(); - - // - // ***** friends ***** - // - friend interpatch_ghost_zone::setup_other_patch_frontier - (int interp_handle_in, int interp_par_table_handle_in); - private: // we forbid copying and passing by value // by declaring the copy constructor and assignment operator @@ -394,7 +406,7 @@ private: // type/coordinate metadata patch_system &my_patch_system_; const int patch_number_; - const char *name_; + const char* name_; const bool is_plus_; const char ctype_; const local_coords::coords_set coords_set_rho_, @@ -414,8 +426,8 @@ private: // setup_periodic_symmetry_ghost_zone() // setup_interpatch_ghost_zone() ghost_zone* min_rho_ghost_zone_; - ghost_zone* max_rho_ghost_zone_, - ghost_zone* min_sigma_ghost_zone_, + ghost_zone* max_rho_ghost_zone_; + ghost_zone* min_sigma_ghost_zone_; ghost_zone* max_sigma_ghost_zone_; // frontiers (NULL pointers if no frontier for this ghost zone) @@ -423,11 +435,13 @@ private: // reset for those cases where there *is* a frontier by // set_patch_frontier(), which is called by the *other* patch's // interpatch_ghost_zone::setup_other_patch_frontier() + // ... contrary to appearance, "mutable" here refers to the pointers, + // not to the patch_frontier objects to which they point! // - const patch_frontier* min_rho_patch_frontier_, - const patch_frontier* max_rho_patch_frontier_, - const patch_frontier* min_sigma_patch_frontier_, - const patch_frontier* max_sigma_patch_frontier_; + mutable const patch_frontier* min_rho_patch_frontier_; + mutable const patch_frontier* max_rho_patch_frontier_; + mutable const patch_frontier* min_sigma_patch_frontier_; + mutable const patch_frontier* max_sigma_patch_frontier_; }; //***************************************************************************** @@ -463,7 +477,7 @@ private: // struct patch_info { - const char *name; + const char* name; bool is_plus; char ctype; fp min_drho, max_drho; @@ -472,10 +486,9 @@ struct patch_info // compute and return reference to struct grid_arrays::grid_array_pars // ... result refers to internal static buffer; // the usual caveats about lifetimes/overwriting apply - const grid_arrays::grid_array_pars& grid_array_pars - (int N_ghost_points, - int N_extend_points, - fp delta_drho_dsigma) + const grid_arrays::grid_array_pars& + grid_array_pars(int N_ghost_points, int N_extend_points, + fp delta_drho_dsigma) const; // compute and return reference to struct grid::grid_pars @@ -502,8 +515,8 @@ class z_patch { public: // human-readable names of (rho,sigma) - const char *name_of_rho() const { return "mu"; } - const char *name_of_sigma() const { return "nu"; } + const char* name_of_rho() const { return "mu"; } + const char* name_of_sigma() const { return "nu"; } // convert (rho,sigma) --> tau fp tau_of_rho_sigma(fp rho, fp sigma) const @@ -540,9 +553,9 @@ public: // ... character string describing how (dpx,dpy) are // defined in terms of (mu,nu,phi), eg "90 - drho = 90 - dphi" // (used for labelling output files) - const char *name_of_dpx() const + const char* name_of_dpx() const { return "dsigma = dnu"; } - const char *name_of_dpy() const + const char* name_of_dpy() const { return is_plus() ? "drho = dmu" : "180 - drho = 180 - dmu"; } // ... (irho,isimga) --> (px,py) fp dpx_of_rho_sigma(fp rho, fp sigma) const @@ -555,7 +568,7 @@ public: // constructor, destructor z_patch(patch_system &my_patch_system_in, int patch_number_in, - const char *name_in, bool is_plus_in, + const char* name_in, bool is_plus_in, const grid_arrays::grid_array_pars& grid_array_pars_in, const grid::grid_pars& grid_pars_in); ~z_patch() { } @@ -582,8 +595,8 @@ class x_patch { public: // human-readable names of (rho,sigma) - const char *name_of_rho() const { return "nu"; } - const char *name_of_sigma() const { return "phi"; } + const char* name_of_rho() const { return "nu"; } + const char* name_of_sigma() const { return "phi"; } // convert (rho,sigma) --> tau fp tau_of_rho_sigma(fp rho, fp sigma) const @@ -620,8 +633,8 @@ public: // ... character string describing how (dpx,dpy) are // defined in terms of (mu,nu,phi), eg "90 - drho = 90 - dphi" // (used for labelling output files) - const char *name_of_dpx() const { return "drho = dnu"; } - const char *name_of_dpy() const + const char* name_of_dpx() const { return "drho = dnu"; } + const char* name_of_dpy() const { return is_plus() ? "dsigma = dphi" : "180 - dsigma = 180 - dphi"; @@ -637,7 +650,7 @@ public: // constructor, destructor x_patch(patch_system &my_patch_system_in, int patch_number_in, - const char *name_in, bool is_plus_in, + const char* name_in, bool is_plus_in, const grid_arrays::grid_array_pars& grid_array_pars_in, const grid::grid_pars& grid_pars_in); ~x_patch() { } @@ -664,8 +677,8 @@ class y_patch { public: // human-readable names of (rho,sigma) - const char *name_of_rho() const { return "mu"; } - const char *name_of_sigma() const { return "phi"; } + const char* name_of_rho() const { return "mu"; } + const char* name_of_sigma() const { return "phi"; } // convert (rho,sigma) --> tau fp tau_of_rho_sigma(fp rho, fp sigma) const @@ -702,12 +715,12 @@ public: // ... character string describing how (dpx,dpy) are // defined in terms of (mu,nu,phi), eg "90 - drho = 90 - dphi" // (used for labelling output files) - const char *name_of_dpx() const + const char* name_of_dpx() const { return is_plus() ? "90 - dsigma = 90 - dphi" : "90 + dsigma = 90 + dphi"; } - const char *name_of_dpy() const { return "drho = dmu"; } + const char* name_of_dpy() const { return "drho = dmu"; } // ... (rho,simga) --> (px,py) fp dpx_of_rho_sigma(fp rho, fp sigma) const { @@ -720,7 +733,7 @@ public: // constructor, destructor y_patch(patch_system &my_patch_system_in, int patch_number_in, - const char *name_in, bool is_plus_in, + const char* name_in, bool is_plus_in, const grid_arrays::grid_array_pars& grid_array_pars_in, const grid::grid_pars& grid_pars_in); ~y_patch() { } diff --git a/src/patch/patch_edge.hh b/src/patch/patch_edge.hh index d8ed620..08e0127 100644 --- a/src/patch/patch_edge.hh +++ b/src/patch/patch_edge.hh @@ -53,7 +53,7 @@ public: bool par_is_rho() const { return ! is_rho(); } // human-readable {min,max}_{rho,sigma} name (for debugging etc) - const char *name() const + const char* name() const { return is_min() ? (is_rho() ? "min_rho" : "min_sigma") @@ -92,9 +92,9 @@ public: // coordinate maps perpendicular/parallel to the edge // ... range is that of the grid *including* ghost zones - const linear_map<fp>& perp_map() const + const jtutil::linear_map<fp>& perp_map() const { return my_patch().ang_map(perp_is_rho()); } - const linear_map<fp>& par_map() const + const jtutil::linear_map<fp>& par_map() const { return my_patch().ang_map(par_is_rho()); } // meta-info about perp/par coordinates @@ -125,11 +125,11 @@ public: { return my_patch().fp_iang_of_ang(perp_is_rho(), perp); } fp fp_ipar_of_par(fp par) const { return my_patch().fp_iang_of_ang(par_is_rho(), par); } - int iperp_of_perp(fp perp, linear_map<fp>::noninteger_action - nia = linear_map<fp>::error) + int iperp_of_perp(fp perp, jtutil::linear_map<fp>::noninteger_action + nia = jtutil::linear_map<fp>::error) { return my_patch().iang_of_ang(perp_is_rho(), perp, nia); } - int ipar_of_par(fp par, linear_map<fp>::noninteger_action - nia = linear_map<fp>::error) + int ipar_of_par(fp par, jtutil::linear_map<fp>::noninteger_action + nia = jtutil::linear_map<fp>::error) { return my_patch().iang_of_ang(par_is_rho(), par, nia); } // ... (perp,par) --> (rho,sigma) diff --git a/src/patch/patch_interp.cc b/src/patch/patch_interp.cc index e239d9f..4fd884a 100644 --- a/src/patch/patch_interp.cc +++ b/src/patch/patch_interp.cc @@ -12,17 +12,14 @@ #include <assert.h> #include <math.h> -// Cactus stuff #include "util_Table.h" #include "cctk.h" -// jtutil:: stuff #include "jt/stdc.h" #include "jt/util.hh" #include "jt/array.hh" #include "jt/cpm_map.hh" #include "jt/linear_map.hh" -#include "jt/interpolate.hh" using jtutil::error_exit; #include "fp.hh" @@ -41,14 +38,15 @@ using jtutil::error_exit; // // Note this requires that the adjacent-side ghost_zone objects already // exist, since they're used in determining the ipar range over which the -// interpolation will be done. However, the patch's gridfns need not exist -// yet. +// interpolation will be done. +// +// It also requires that the patch's gridfns exist, since we size various +// arrays based on the patch's min/max ghosted gfn. // patch_frontier::patch_frontier(const patch_edge& my_edge_in, int min_iperp_in, int max_iperp_in, - int min_parindex_in, int max_parindex_in, - const jtutil::array1d<fp>& min_parindex_used_in, - const jtutil::array1d<fp>& max_parindex_used_in, + const jtutil::array1d<int>& min_parindex_used_in, + const jtutil::array1d<int>& max_parindex_used_in, const jtutil::array2d<fp>& interp_par_in, int interp_handle_in, int interp_par_table_handle_in) @@ -64,12 +62,12 @@ patch_frontier::patch_frontier(const patch_edge& my_edge_in, interp_par_table_handle_(Util_TableClone(interp_par_table_handle_in)), gridfn_coord_origin_(my_edge().par_of_ipar(min_ipar())), gridfn_coord_delta_ (my_edge().par_map().delta_fp()), - gridfn_type_codes_ - (my_patch().ghosted_min_gfn(), my_patch().ghosted_max_gfn()) - gridfn_data_ptrs_ - (my_patch().ghosted_min_gfn(), my_patch().ghosted_max_gfn()) - result_buffer_ptrs_ - (my_patch().ghosted_min_gfn(), my_patch().ghosted_max_gfn()) + gridfn_type_codes_ (my_patch().ghosted_min_gfn(), + my_patch().ghosted_max_gfn()), + gridfn_data_ptrs_ (my_patch().ghosted_min_gfn(), + my_patch().ghosted_max_gfn()), + result_buffer_ptrs_(my_patch().ghosted_min_gfn(), + my_patch().ghosted_max_gfn()) { int status; @@ -84,7 +82,7 @@ if (status < 0) interp_par_table_handle_in, status); /*NOTREACHED*/ -// set up parameter table for interpolator +// set up gridfn storage addressing in interpolator parameter table const int N_dims = 1; const CCTK_INT stride = my_patch().ghosted_iang_stride(my_edge().is_rho()); status = Util_TableSetIntArray(interp_par_table_handle_, @@ -100,7 +98,9 @@ if (status < 0) status); /*NOTREACHED*/ // set up gridfn type codes - for (int gfn = ghosted_min_gfn() ; gfn <= ghosted_max_gfn() ; ++gfn) + for (int gfn = my_patch().ghosted_min_gfn() ; + gfn <= my_patch().ghosted_max_gfn() ; + ++gfn) { gridfn_type_codes_(gfn) = CCTK_VARIABLE_REAL; // fp == CCTK_REAL } @@ -131,8 +131,8 @@ const ghost_zone& min_par_adjacent_ghost_zone = my_patch() .ghost_zone_on_edge(my_edge().min_par_adjacent_edge()); return min_par_adjacent_ghost_zone.is_symmetry() - ? my_edge_in.min_ipar_with_corners() - : my_edge_in.min_ipar_without_corners(); + ? my_edge().min_ipar_with_corners() + : my_edge().min_ipar_without_corners(); } int patch_frontier::max_ipar_for_gridfn_data() const @@ -141,8 +141,8 @@ const ghost_zone& max_par_adjacent_ghost_zone = my_patch() .ghost_zone_on_edge(my_edge().max_par_adjacent_edge()); return max_par_adjacent_ghost_zone.is_symmetry() - ? my_edge_in.max_ipar_with_corners() - : my_edge_in.max_ipar_without_corners(); + ? my_edge().max_ipar_with_corners() + : my_edge().max_ipar_without_corners(); } //***************************************************************************** @@ -156,7 +156,8 @@ return max_par_adjacent_ghost_zone.is_symmetry() // void patch_frontier::interpolate(int ghosted_min_gfn_to_interp, int ghosted_max_gfn_to_interp, - jtutil::array3d<fp>& result_buffer) const + jtutil::array3d<fp>& result_buffer_array) + const { // // We do a separate interpolation for each iperp. @@ -176,8 +177,8 @@ void patch_frontier::interpolate(int ghosted_min_gfn_to_interp, const int N_dims = 1; const int N_gridfns = jtutil::how_many_in_range(ghosted_min_gfn_to_interp, ghosted_max_gfn_to_interp); -const CCTK_INT N_gridfn_data_points = jtutil::how_many_in_range(min_ipar(), - max_ipar()); +const CCTK_INT N_gridfn_data_points + = jtutil::how_many_in_range(min_ipar(), max_ipar()); const int interp_coords_type_code = CCTK_VARIABLE_REAL; // fp == CCTK_REAL const CCTK_INT *gridfn_type_codes_ptr = & gridfn_type_codes_(ghosted_min_gfn_to_interp); @@ -193,7 +194,7 @@ const CCTK_INT *gridfn_type_codes_ptr // interpolation-point coordinates const CCTK_INT N_interp_points = jtutil::how_many_in_range(min_parindex, max_parindex); - const fp *interp_coords_ptr = & interp_par_(iperp, min_parindex); + const fp* const interp_coords_ptr = & interp_par_(iperp, min_parindex); const void* const interp_coords[N_dims] = { static_cast<const void *>(interp_coords_ptr) }; @@ -207,27 +208,27 @@ const CCTK_INT *gridfn_type_codes_ptr const int start_isigma = my_edge().isigma_of_iperp_ipar(iperp, min_ipar()); gridfn_data_ptrs_(gfn) - = & my_patch() - .ghosted_gridfn(gfn, start_irho,start_isigma); + = static_cast<const void *>( + & my_patch() + .ghosted_gridfn(gfn, start_irho,start_isigma) + ); result_buffer_ptrs_(gfn) - = & result_buffer(gfn, iperp,min_parindex); + = static_cast<void *>( + & result_buffer_array(gfn, iperp,min_parindex) + ); } - const void* const* gridfn_data - = static_cast<const void* const*>( - & gridfn_data_ptrs_(ghosted_min_gfn_to_interp) - ); - void* const result_buffer - = static_cast<void* const*>( - & result_buffer_ptrs_(ghosted_min_gfn_to_interp) - ); + const void* const* const gridfn_data + = & gridfn_data_ptrs_(ghosted_min_gfn_to_interp); + void* const* const result_buffer + = & result_buffer_ptrs_(ghosted_min_gfn_to_interp); // do the actual interpolation const int status = CCTK_InterpLocalUniform(N_dims, interp_handle_, interp_par_table_handle_, - gridfn_coord_origin_, - gridfn_coord_delta_, + &gridfn_coord_origin_, + &gridfn_coord_delta_, N_interp_points, interp_coords_type_code, interp_coords, diff --git a/src/patch/patch_interp.hh b/src/patch/patch_interp.hh index c0c6dcb..29c0836 100644 --- a/src/patch/patch_interp.hh +++ b/src/patch/patch_interp.hh @@ -34,6 +34,12 @@ // // +// Since all patch_frontier member functions are const, a patch_frontier +// object is effectively always const whether declared that way or not, +// so there's no harm in always declaring patch_frontier objects as const. +// + +// // The way our coordinates are constructed, any two adjacent patches // share a common (perpendicular) coordinate. Thus we only have to do // 1-dimensional interpolation here (in the parallel direction). @@ -78,7 +84,8 @@ public: // ... result buffer indices are (gfn, iperp,parindex) void interpolate(int ghosted_min_gfn_to_interp, int ghosted_max_gfn_to_interp, - jtutil::array3d<fp>& result_buffer); + jtutil::array3d<fp>& result_buffer_array) + const; // @@ -137,9 +144,8 @@ public: // patch_frontier(const patch_edge& my_edge_in, int min_iperp_in, int max_iperp_in, - int min_parindex_in, int max_parindex_in, - const jtutil::array1d<fp>& min_parindex_used_in, - const jtutil::array1d<fp>& max_parindex_used_in, + const jtutil::array1d<int>& min_parindex_used_in, + const jtutil::array1d<int>& max_parindex_used_in, const jtutil::array2d<fp>& interp_par_in, int interp_handle_in, int interp_par_table_handle_in); ~patch_frontier(); @@ -157,8 +163,8 @@ private: // range of (iperp,ipar) in this patch from which // we will use gridfn data in interpolation - int min_iperp_, max_iperp_; - int min_ipar_, max_ipar_; + const int min_iperp_, max_iperp_; + const int min_ipar_, max_ipar_; // [min,max] parindex at each iperp // ... these are references to arrays passed in to our constructor @@ -185,14 +191,14 @@ private: // then gets extra stuff added to it specific to this // frontier; it's shared across all iperp // ... we own this table - int interp_par_table_handle_; + const int interp_par_table_handle_; // (par) origin and delta values of the gridfn data - fp gridfn_coord_origin_, gridfn_coord_delta_; + const fp gridfn_coord_origin_, gridfn_coord_delta_; // gridfn type codes for interpolator // ... must be CCTK_INT so we can pass by reference to interpolator - // ... must be mutable so we can set values in ctor + // ... values set in ctor body, const thereafter // ... index is (gfn) mutable jtutil::array1d<CCTK_INT> gridfn_type_codes_; @@ -200,11 +206,11 @@ private: // (reset for each iperp) // ... we do *not* own the pointed-to data! // ... index is (gfn) - mutable jtutil::array1d<fp *> gridfn_data_ptrs_; + mutable jtutil::array1d<const void*> gridfn_data_ptrs_; // --> start of result buffer for interpolation // (reset for each iperp) // ... we do *not* own the pointed-to data! // ... index is (gfn) - mutable jtutil::array1d<fp *> result_buffer_ptrs_; - } + mutable jtutil::array1d<void*> result_buffer_ptrs_; + }; diff --git a/src/patch/patch_system.cc b/src/patch/patch_system.cc index ebd6045..2412d75 100644 --- a/src/patch/patch_system.cc +++ b/src/patch/patch_system.cc @@ -27,12 +27,13 @@ #include <math.h> #include <string.h> +#include "cctk.h" + #include "jt/stdc.h" #include "jt/util.hh" #include "jt/array.hh" #include "jt/cpm_map.hh" #include "jt/linear_map.hh" -#include "jt/interpolate.hh" using jtutil::error_exit; #include "fp.hh" @@ -708,9 +709,9 @@ py.setup_interpatch_ghost_zone(ey, ex, N_overlap_points); const patch_edge& ex = px.edge_adjacent_to_patch(py, N_overlap_points); const patch_edge& ey = py.edge_adjacent_to_patch(px, N_overlap_points); px.interpatch_ghost_zone_on_edge(ex) - .setup_other_frontier(interp_handle, interp_par_table_handle); + .setup_other_patch_frontier(interp_handle, interp_par_table_handle); py.interpatch_ghost_zone_on_edge(ey) - .setup_other_frontier(interp_handle, interp_par_table_handle); + .setup_other_patch_frontier(interp_handle, interp_par_table_handle); } //****************************************************************************** @@ -822,7 +823,7 @@ else error_exit(PANIC_EXIT, // the patch number, or does an error_exit() if no patch is found with // the specified name. // -int patch_system::patch_number_of_name(const char *name) const +int patch_system::patch_number_of_name(const char* name) const { for (int pn = 0 ; pn < N_patches() ; ++pn) { diff --git a/src/patch/patch_system.hh b/src/patch/patch_system.hh index ffecf15..1db72db 100644 --- a/src/patch/patch_system.hh +++ b/src/patch/patch_system.hh @@ -97,7 +97,7 @@ public: { return * (*all_patches_)(pn); } // find a patch by name, return patch number; error_exit() if not found - int patch_number_of_name(const char *name) const; + int patch_number_of_name(const char* name) const; // total number of grid points int N_grid_points() const { return N_grid_points_; } @@ -239,6 +239,6 @@ private: // pointers to storage blocks for all gridfns // ... patches point into these, but we own the storage blocks - fp *gridfn_storage_; - fp *ghosted_gridfn_storage_; + fp* gridfn_storage_; + fp* ghosted_gridfn_storage_; }; diff --git a/src/patch/test_coords.cc b/src/patch/test_coords.cc index 8e913ee..109a29e 100644 --- a/src/patch/test_coords.cc +++ b/src/patch/test_coords.cc @@ -23,9 +23,9 @@ using namespace local_coords; // This program is a test driver for the local_coords:: coordinate-conversion // functions. See the help message below for details. // -int main(int argc, const char *argv[]) +int main(int argc, const char* argv[]) { -const char *help_msg = +const char* help_msg = "Usage:\n" "n.b. all angles are input/output in degrees!\n" " test_coords [ r=number ] [ theta=number ]\n" diff --git a/src/patch/test_coords2.cc b/src/patch/test_coords2.cc index 3a9f4df..770e497 100644 --- a/src/patch/test_coords2.cc +++ b/src/patch/test_coords2.cc @@ -31,7 +31,7 @@ void test_r_theta_phi(fp x, fp y, fp z); // functions. It tries a large number of coordinate conversions, and checks // them all for mutual consistency. // -int main(int argc, const char *argv[]) +int main(int argc, const char* argv[]) { bool verbose_flag = (argc == 2) && STRING_EQUAL(argv[1], "--verbose"); const fp xyz_minmax = 1.0; diff --git a/src/patch/test_patch_system.cc b/src/patch/test_patch_system.cc index d9e82a9..752fa3e 100644 --- a/src/patch/test_patch_system.cc +++ b/src/patch/test_patch_system.cc @@ -35,7 +35,7 @@ #include "jt/array.hh" #include "jt/cpm_map.hh" #include "jt/linear_map.hh" -#include "jt/interpolate.hh" +using jtutil::error_exit; #include "fp.hh" #include "coords.hh" @@ -47,8 +47,6 @@ #include "patch_frontier.hh" #include "patch_system.hh" -using jtutil::error_exit; - //****************************************************************************** // |