diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-03-29 15:20:27 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-03-29 15:20:27 +0000 |
commit | 19a124f8ed3fe19540866536ec30113fcd9b8f35 (patch) | |
tree | ff36fbbae23ce202dae1e7377c18cd1865f4281b | |
parent | d12fce1c94b752c601000f0e0d233b23971a0c53 (diff) |
redo patch_info:: as a separate POD struct
(no longer a member of some other class)
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@392 f88db872-0e4f-0410-b76b-b9085cfa78c5
-rw-r--r-- | src/patch/patch.cc | 149 | ||||
-rw-r--r-- | src/patch/patch.hh | 68 |
2 files changed, 216 insertions, 1 deletions
diff --git a/src/patch/patch.cc b/src/patch/patch.cc index 3aa0a40..a142f55 100644 --- a/src/patch/patch.cc +++ b/src/patch/patch.cc @@ -18,6 +18,9 @@ // patch::setup_patch_frontier // patch::assert_all_ghost_zones_fully_setup // +// patch_info::grid_array_pars +// patch_info::grid_pars +// #include <stdio.h> #include <assert.h> @@ -157,7 +160,43 @@ y_patch::y_patch(patch_system &my_patch_system_in, int patch_number_in, { } //****************************************************************************** -//****************************************************************************** + +// +// This function prints a gridfn in ASCII format to an already-open +// stdio stream. The output format is suitable for a gnuplot 'splot' +// command. Individual patches may be selected with the select.patch +// program (perl script). +// +void patch::print_gridfn(int gfn, bool want_ghost_zones, + FILE *output_fp = stdout) + const +{ +fprintf(output_fp, "### %s patch\n", name()); +fprintf(output_fp, "# gfn=%d\n", gfn); +fprintf(output_fp, "# dpx = %s\n", name_of_dpx()); +fprintf(output_fp, "# dpy = %s\n", name_of_dpy()); +fprintf(output_fp, "#\n"); +fprintf(output_fp, "# dpx\tdpy\tgridfn\tirho\tisigma\n"); + for (int irho = effective_min_irho(want_ghost_zones) ; + irho <= effective_max_irho(want_ghost_zones) ; + ++irho) + { + for (int isigma = effective_min_isigma(want_ghost_zones) ; + isigma <= effective_max_isigma(want_ghost_zones) ; + ++isigma) + { + const fp rho = rho_of_irho(irho); + const fp sigma = sigma_of_isigma(isigma); + const fp dpx = dpx_of_rho_sigma(rho, sigma); + const fp dpy = dpy_of_rho_sigma(rho, sigma); + fprintf(output_fp, + "%g\t%g\t%.15g\t%d\t%d\n", + dpx, dpy, gridfn(gfn,irho,isigma), irho, isigma); + } + printf("\n"); + } +} + //****************************************************************************** // @@ -432,3 +471,111 @@ max_rho_ghost_zone().assert_fully_setup(); min_sigma_ghost_zone().assert_fully_setup(); max_sigma_ghost_zone().assert_fully_setup(); } + +//****************************************************************************** +//****************************************************************************** +//****************************************************************************** + +// +// 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 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<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 + + jtutil::round<fp>::to_integer( + (max_drho -min_drho ) / delta_drho_dsigma + ); +grid_array_pars_buffer.max_isigma + = array_pars.min_isigma + + jtutil::round<fp>::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; +} + } diff --git a/src/patch/patch.hh b/src/patch/patch.hh index d772637..c18b047 100644 --- a/src/patch/patch.hh +++ b/src/patch/patch.hh @@ -3,6 +3,7 @@ // // ***** how patch boundaries are handled ***** // patch - abstract base class to describe a coordinate/grid patch +// patch_info - POD struct with summary info for patch construction // // z_patch - derived class for a +/- z patch // x_patch - derived class for a +/- x patch @@ -189,6 +190,14 @@ public: // + // ***** I/O ***** + // + void print_gridfn(int gfn, bool want_ghost_zones, + FILE *output_fp = stdout) + const; + + + // // ***** (rho,sigma,tau) coordinate conversions ***** // public: @@ -335,6 +344,10 @@ public: // are fully setup void assert_all_ghost_zones_fully_setup() const; + + // + // ***** constructor, destructor, et al ***** + // protected: // ... used only from derived classes // ... doesn't set up ghost zone or frontier info, since this @@ -405,6 +418,61 @@ private: //***************************************************************************** // +// This (POD, and hence static-initializable) struct gives a minimal +// set of information which varies from one patch to another. +// +// The member functions allow a patch to be constructed from this struct +// together with the additional information provided by their arguments. +// This doesn't allow the most general possible type of patch (eg it +// constrains all ghost zones to have the same width), but does cover +// the common casees. +// +// Arguments for member functions: +// 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 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. +// +struct patch_info + { + const char *name; + bool is_plus; + char ctype; + fp min_drho, max_drho; + fp min_dsigma, max_dsigma; + + // 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; + + // compute and return reference to struct grid::grid_pars + // ... result refers to internal static buffer; + // the usual caveats about lifetimes/overwriting apply + const grid::grid_pars& grid_pars(int N_extend_points, + fp delta_drho_dsigma) + const; + }; + +//***************************************************************************** +//***************************************************************************** +//***************************************************************************** + +// // This class describes a +/- z patch. It doesn't define any new // functions not already present in class patch ; it "just" defines // non-virtual versions of all the pure virtual functions defined there. |