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 /src/patch/patch.cc | |
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
Diffstat (limited to 'src/patch/patch.cc')
-rw-r--r-- | src/patch/patch.cc | 149 |
1 files changed, 148 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; +} + } |