diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-03-24 19:43:07 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-03-24 19:43:07 +0000 |
commit | 75ea9f948bf58357c273fa86c01c46c30f56fbde (patch) | |
tree | 08ef13e5b1d6c3a840b93d0d6ff15c9e19fe0560 /src/patch/grid.hh | |
parent | 2a367c9385159493665d531c216eca00765828b6 (diff) |
delete actual storage of grid function data
(this will now be up in class patch_system:: in order to allow
arrays to be contiguous across patches)
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@366 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/patch/grid.hh')
-rw-r--r-- | src/patch/grid.hh | 136 |
1 files changed, 76 insertions, 60 deletions
diff --git a/src/patch/grid.hh b/src/patch/grid.hh index 7bcb3d3..8d97023 100644 --- a/src/patch/grid.hh +++ b/src/patch/grid.hh @@ -1,8 +1,8 @@ // grid.hh -- classes for a 2D uniform tensor-product grid // $Id$ // -// grid_arrays - data arrays for a 2D tensor-product grid -// grid - uniform 2D tensor-product grid +// grid_arrays - integer-array-subscripts metadata for a 2D tensor-product grid +// grid - metadata for a uniform 2D tensor-product grid // // @@ -22,33 +22,29 @@ //***************************************************************************** // -// grid_arrays - data arrays for a 2D tensor-product grid +// grid_arrays - integer-array-subscripts metadata for a 2D tensor-product grid // // This is a helper class for class grid (below). This class stores -// most of the actual grid function (gridfn) data arrays for a uniform -// tensor-product 2D grid. +// the integer-array-subscripts metadata for a uniform tensor-product +// 2D grid. It also does the grid function subscripting computations. +// It does *not* store any actual grid function data (that's stored in +// class patch_system:: ). // // The integer grid coordinates are (irho,isigma). This class deals // with the grid solely at the level of arrays with integer subscripts; -// the derived class grid deals with the floating-point coordinates +// the derived class grid:: deals with the floating-point coordinates // related to those subscripts. // // The grid has a nominal extent, surrounded by "ghost zones" on each -// side for finite differencing purposes. For simplicity, all grid -// functions (gridfns) are stored on the full "ghosted" grid (nominal -// + ghost zones), even though we actually only need this for finite -// differencing targets. -// -// We identify a gridfn by a small-integer "grid function number", -// a.k.a. "gfn". Each gridfn is stored contiguously. +// side for finite differencing purposes. // class grid_arrays { -public: // // ***** {min,max}_{rho,sigma} "sides" of grid ***** // +public: // // A grid has 4 (angular) "sides", which we identify as @@ -94,27 +90,9 @@ public: // - // ***** gfn-checking and gridfn access functions ***** - // - - int min_gfn() const { return min_gfn_; } - int max_gfn() const { return max_gfn_; } - int N_gridfns() const - { return jtutil::how_many_in_range(min_gfn(), max_gfn()); } - - // access to gridfn data - // ... rvalue (may be slightly faster since it's a const function - // and it returns by value rather than reference - fp gridfn(int gfn, int irho, int isigma) const - { return gridfn_data_(gfn, irho, isigma); } - // ... lvalue (must return a reference) - fp& gridfn(int gfn, int irho, int isigma) - { return gridfn_data_(gfn, irho, isigma); } - - - // - // ***** array info ***** + // ***** min/max/sizes ***** // +public: // nominal-grid min/max/sizes int min_irho() const { return min_irho_; } @@ -136,7 +114,7 @@ public: int N_grid_points() const { return N_irho() * N_isigma(); } - // full-grid min/max (don't need sizes) + // ghosted-grid min/max/sizes int ghosted_min_irho() const { return ghosted_min_irho_; } int ghosted_max_irho() const { return ghosted_max_irho_; } int ghosted_min_isigma() const @@ -158,6 +136,18 @@ public: return want_min ? ghosted_min_iang(want_rho) : ghosted_max_iang(want_rho); } + int ghosted_N_irho() const + { + return jtutil::how_many_in_range(ghosted_min_irho(), + ghosted_max_irho()); + } + int ghosted_N_isigma() const + { + return jtutil::how_many_in_range(ghosted_min_isigma(), + ghosted_max_isigma()); + } + int ghosted_N_grid_points() const + { return ghosted_N_irho() * ghosted_N_isigma(); } // "effective" grid min/max // (= dynamic select between nominal and full grids) @@ -182,6 +172,7 @@ public: // // ***** ghost zones ***** // +public: // ghost zone min/max perpendicular coordinates int min_rho_ghost_zone__min_iperp() const @@ -259,8 +250,9 @@ public: // - // ***** membership predicates ***** + // ***** grid-point membership predicates ***** // +public: bool is_in_nominal_grid(int irho, int isigma) const { return (irho >= min_irho()) && (irho <= max_irho()) @@ -281,25 +273,50 @@ public: // - // ***** argument structure for constructor ***** + // ***** grid function subscripting ***** // +protected: + // 1-D 0-origin array subscript + // ... std::assert used for (irho,isigma) range checking + // ... present implementation has isigma as contiguous axis + int subscript(int irho, int isigma) const + { + std::assert( is_in_nominal_grid(irho, isigma) ); + return N_isigma() * (irho - min_irho() ) + + (isigma - min_isigma()); + } + int ghosted_subscript(int irho, int isigma) const + { + std::assert( is_in_ghosted_grid(irho, isigma) ); + return ghosted_N_isigma() * (irho - ghosted_min_irho() ) + + (isigma - ghosted_min_isigma()); + } - // this structure bundles related arguments together so we don't - // have 20+ (!) separate arguments to our top-level constructors + // + // ***** argument structure for constructor ***** + // +public: + // this (POD) structure bundles related arguments together so we + // don't have 20+ (!) separate arguments to our top-level constructors struct grid_array_pars { - int min_irho, max_irho; + int min_irho , max_irho ; int min_isigma, max_isigma; - int min_rho_N_ghost_points, max_rho_N_ghost_points; + int min_rho_N_ghost_points , max_rho_N_ghost_points ; int min_sigma_N_ghost_points, max_sigma_N_ghost_points; +#ifdef OBSELETE + // total number of grid points + int N_grid_points() const; + int ghosted_N_grid_points() const; +#endif }; // // ***** constructor, destructor ***** // - grid_arrays(const grid_array_pars& grid_array_pars_in, - int min_gfn_in, int max_gfn_in); +public: + grid_arrays(const grid_array_pars& grid_array_pars_in); // compiler-generated default destructor is ok private: @@ -310,16 +327,6 @@ private: grid_arrays& operator=(const grid_arrays& rhs); private: - // - // ***** the actual gridfn storage arrays ***** - // - // n.b. this array is *first* data member in this class - // ==> possibly slightly faster access (0 offset from pointer) - array3d<fp> gridfn_data_; // indices are (gfn, irho, isigma) - - // gfn bounds - const int min_gfn_, max_gfn_; - // nominal grid min/max bounds const int min_irho_, max_irho_; const int min_isigma_, max_isigma_; @@ -332,7 +339,13 @@ private: //****************************************************************************** // -// grid - uniform 2D tensor-product grid +// grid - metadata for a uniform 2D tensor-product grid +// +// This class stores the metadata for a uniform tensor-product 2D grid. +// The base class grid_arrays:: stores the integer-array-subscripts +// information; this class stores the floating-point-coordinates information. +// Neither class stores any actual grid function data (that's stored in +// class patch_system:: ). // // The grid is uniform in the floating point grid coordinates (rho,sigma). // There is also some (limited) support for expressing these coordinates @@ -349,10 +362,10 @@ private: class grid : public grid_arrays { -public: // // ***** low-level access to coordinate maps ***** // +protected: // direct (read-only) access to the underlying linear_map objects // ... useful for (eg) passing to interpolators @@ -365,6 +378,7 @@ public: // // ***** single-axis coordinate conversions ***** // +public: // ... angles in radians fp rho_of_irho(int irho) const { return rho_map().fp_of_int(irho); } @@ -424,6 +438,7 @@ public: // // ***** grid info ***** // +public: // grid spacings fp delta_rho() const { return rho_map().delta_fp(); } @@ -495,6 +510,7 @@ public: // // ***** misc stuff ***** // +public: // human-readable names for the sides (for debugging) static const char *ang_name(bool want_rho) @@ -508,12 +524,13 @@ public: // // ***** argument structure for constructor ***** // +public: - // this structure bundles related arguments together so we don't - // have 20+ (!) separate arguments to our top-level constructors + // this (POD) structure bundles related arguments together so we + // don't have 20+ (!) separate arguments to our top-level constructors struct grid_pars // *** note angles in degrees *** { - fp min_drho, delta_drho, max_drho; + fp min_drho , delta_drho , max_drho ; fp min_dsigma, delta_dsigma, max_dsigma; }; @@ -522,8 +539,7 @@ public: // ***** constructor, destructor ***** // grid(const grid_array_pars& grid_array_pars_in, - const grid_pars& grid_pars_in, - int min_gfn_in, int max_gfn_in); + const grid_pars& grid_pars_in); // compiler-generated default destructor is ok private: |