aboutsummaryrefslogtreecommitdiff
path: root/src/patch/patch.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/patch/patch.cc')
-rw-r--r--src/patch/patch.cc57
1 files changed, 43 insertions, 14 deletions
diff --git a/src/patch/patch.cc b/src/patch/patch.cc
index dfa4369..1002a60 100644
--- a/src/patch/patch.cc
+++ b/src/patch/patch.cc
@@ -8,8 +8,8 @@
// x_patch::x_patch
// y_patch::y_patch
//
-// patch::minmax_ang_ghost_zone
// patch::ghost_zone_on_edge
+// patch::corner_ghost_zone_containing_point
// patch::interpatch_ghost_zone_on_edge
// patch::create_mirror_symmetry_ghost_zone
// patch::create_periodic_symmetry_ghost_zone
@@ -156,29 +156,58 @@ y_patch::y_patch(patch_system &my_patch_system_in, int patch_number_in,
//******************************************************************************
//
-// This function returns a reference to the specified ghost zone
-// of this patch.
+// This function returns a reference to the ghost zone on a specified
+// edge, after first assert()ing that the edge belongs to this patch.
//
-ghost_zone& patch::minmax_ang_ghost_zone(bool want_min, bool want_rho)
+// N.b. This function can't be inline in "patch.hh" because it needs
+// member functions of class patch_edge, which comes after class patch
+// in our #include order.
+//
+ghost_zone& patch::ghost_zone_on_edge(const patch_edge& e)
const
{
-return want_min ? (want_rho ? min_rho_ghost_zone()
- : min_sigma_ghost_zone())
- : (want_rho ? max_rho_ghost_zone()
- : max_sigma_ghost_zone());
+assert(& e.my_patch() == this);
+return minmax_ang_ghost_zone(e.is_min(), e.is_rho());
}
//******************************************************************************
//
-// This function returns a reference to the specified ghost zone
-// of this patch.
+// This function determines which of the two adjacent ghost zones meeting
+// at a specified corner, contains a specified point. If the point isn't
+// in either ghost zone, an abort(0) is done.
//
-ghost_zone& patch::ghost_zone_on_edge(const patch_edge &edge)
-const
+// Arguments:
+// {rho,sigma}_is_min = Specify the corner (and implicitly the ghost zones).
+// irho,isigma = Specify the point.
+//
+// Results:
+// This function returns (a reference to) the desired ghost zone.
+ghost_zone& patch::corner_ghost_zone_containing_point
+ (bool rho_is_min, bool sigma_is_min,
+ int irho, int isigma)
+ const
{
-assert(& edge.my_patch() == this);
-return minmax_ang_ghost_zone(edge.is_min(), edge.is_rho());
+ghost_zone& rho_gz = minmax_rho_ghost_zone( rho_is_min);
+ghost_zone& sigma_gz = minmax_sigma_ghost_zone(sigma_is_min);
+
+const patch_edge& rho_edge = rho_gz.my_edge();
+const patch_edge& sigma_edge = sigma_gz.my_edge();
+
+const int rho_iperp = rho_edge.iperp_of_irho_isigma(irho, isigma);
+const int rho_ipar = rho_edge. ipar_of_irho_isigma(irho, isigma);
+const int sigma_iperp = sigma_edge.iperp_of_irho_isigma(irho, isigma);
+const int sigma_ipar = sigma_edge. ipar_of_irho_isigma(irho, isigma);
+
+const bool is_in_rho_ghost_zone
+ = rho_gz.is_in_ghost_zone( rho_iperp, rho_ipar);
+const bool is_in_sigma_ghost_zone
+ = sigma_gz.is_in_ghost_zone(sigma_iperp, sigma_ipar);
+
+// check that point is in exactly one ghost zone
+assert(is_in_rho_ghost_zone ^ is_in_sigma_ghost_zone);
+
+return is_in_rho_ghost_zone ? rho_gz : sigma_gz;
}
//******************************************************************************