aboutsummaryrefslogtreecommitdiff
path: root/src/patch/patch_info.cc
diff options
context:
space:
mode:
authorjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-07-04 14:35:15 +0000
committerjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-07-04 14:35:15 +0000
commit254e5f4b6ef1c7c32ed29021ecab0d93d7a9cb14 (patch)
tree29ebdbf04b1714b40b42c670a87b1e51c6d72851 /src/patch/patch_info.cc
parent04cab2b135932cb205829b5c16e4d11c2d7288f0 (diff)
new files split out from patch.{cc,hh}
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@606 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/patch/patch_info.cc')
-rw-r--r--src/patch/patch_info.cc134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/patch/patch_info.cc b/src/patch/patch_info.cc
new file mode 100644
index 0000000..7d6488e
--- /dev/null
+++ b/src/patch/patch_info.cc
@@ -0,0 +1,134 @@
+// patch_info.cc -- POD struct of minimal info varying from one patch to another
+// $Id$
+
+//
+// patch_info::grid_array_pars
+// patch_info::grid_pars
+//
+
+#include <cstdio>
+#include <cmath>
+#include <assert.h>
+using std::fprintf;
+using std::printf;
+
+#include "cctk.h"
+
+#include "stdc.h"
+#include "config.hh"
+#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<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
+ = grid_array_pars_buffer.min_irho
+ + jtutil::round<fp>::to_integer(
+ (max_drho -min_drho ) / delta_drho_dsigma
+ );
+grid_array_pars_buffer.max_isigma
+ = grid_array_pars_buffer.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;
+}