diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-08-12 15:18:23 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-08-12 15:18:23 +0000 |
commit | 211d94c18235f7e95ad2f0dc70047777c6b2d48a (patch) | |
tree | 33ed987367dafef1a45da71185dc1b7d708a6fb1 /src/patch/ghost_zone.cc | |
parent | 3a5c09c54f643bb394491839597aec55000a71c5 (diff) |
merge in changes from laptop:
- fix nasty bug in interpatch_ghost_zone::min_ipar()
and interpatch_ghost_zone::max_ipar()
where we used the corners when we shouldn't
- fix similar bug in interpatch_ghost_zone::finish_setup()
where we used *our* adjacent ghost zone types to decide what to tell
the other patch's patch_interp object about whether or not to use
its min/max par corners -- this should be the *other* patch's adjacent
ghost zones
- rename that to min/max par ghost zones
- rename some other functions
- finish implementing patch_system::synchronize_Jacobian()
to properly take into account the 3-phase algorithm of
patch_system::synchronize()
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@693 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/patch/ghost_zone.cc')
-rw-r--r-- | src/patch/ghost_zone.cc | 137 |
1 files changed, 90 insertions, 47 deletions
diff --git a/src/patch/ghost_zone.cc b/src/patch/ghost_zone.cc index 1b4ba11..3ace6e3 100644 --- a/src/patch/ghost_zone.cc +++ b/src/patch/ghost_zone.cc @@ -2,6 +2,9 @@ // $Id$ // +// ghost_zone::cast_to_symmetry_ghost_zone +// ghost_zone::cast_to_interpatch_ghost_zone +// // symmetry_ghost_zone::symmetry_ghost_zone (mirror symmetry) // symmetry_ghost_zone::symmetry_ghost_zone (periodic BC) // symmetry_ghost_zone::~symmetry_ghost_zone @@ -47,12 +50,49 @@ using jtutil::error_exit; //****************************************************************************** // +// These functions verify (assert()) that a ghost zone is indeed of +// the specified type, then static_cast to the appropriate derived class. +// + +const symmetry_ghost_zone& ghost_zone::cast_to_symmetry_ghost_zone() + const +{ +assert( is_symmetry() ); +return static_cast<const symmetry_ghost_zone &>(*this); +} + +symmetry_ghost_zone& ghost_zone::cast_to_symmetry_ghost_zone() +{ +assert( is_symmetry() ); +return static_cast<symmetry_ghost_zone &>(*this); +} + +//************************************** + +const interpatch_ghost_zone& ghost_zone::cast_to_interpatch_ghost_zone() + const +{ +assert( is_interpatch() ); +return static_cast<const interpatch_ghost_zone &>(*this); +} + +interpatch_ghost_zone& ghost_zone::cast_to_interpatch_ghost_zone() +{ +assert( is_interpatch() ); +return static_cast<interpatch_ghost_zone &>(*this); +} + +//****************************************************************************** +//****************************************************************************** +//****************************************************************************** + +// // This function constructs a mirror-symmetry ghost zone object // symmetry_ghost_zone::symmetry_ghost_zone(const patch_edge& my_edge_in) - : ghost_zone(my_edge_in, ghost_zone_is_symmetry), - symmetry_patch_(my_edge_in.my_patch()), - symmetry_edge_(my_edge_in) + : ghost_zone(my_edge_in, + my_edge_in, // other edge == my edge + ghost_zone_is_symmetry) { // iperp_map: i --> (i of ghost zone) - i iperp_map_ = new jtutil::cpm_map<fp>(min_iperp(), max_iperp(), @@ -68,36 +108,35 @@ ipar_map_ = new jtutil::cpm_map<fp>(extreme_min_ipar(), extreme_max_ipar()); // This function constructs a periodic-symmetry ghost zone object. // symmetry_ghost_zone::symmetry_ghost_zone - (const patch_edge& my_edge_in, const patch_edge& symmetry_edge_in, - int my_edge_sample_ipar, int symmetry_edge_sample_ipar, + (const patch_edge& my_edge_in, const patch_edge& other_edge_in, + int my_edge_sample_ipar, int other_edge_sample_ipar, bool ipar_map_is_plus) - : ghost_zone(my_edge_in, ghost_zone_is_symmetry), - symmetry_patch_(symmetry_edge_in.my_patch()), - symmetry_edge_(symmetry_edge_in) + : ghost_zone(my_edge_in, + other_edge_in, + ghost_zone_is_symmetry) { // // perpendicular map // -const fp fp_my_period_plane_iperp = my_edge().fp_grid_outer_iperp(); -const fp fp_symmetry_period_plane_iperp = symmetry_edge().fp_grid_outer_iperp(); +const fp fp_my_period_plane_iperp = my_edge() .fp_grid_outer_iperp(); +const fp fp_other_period_plane_iperp = other_edge().fp_grid_outer_iperp(); // iperp mapping must be outside --> inside // i.e. if both edges have iperp as the same min/max "direction", // then the mapping is iperp increasing --> iperp decreasing // (i.e. the map's sign is -1) const bool is_iperp_map_plus - = ! (my_edge().is_min() == symmetry_edge().is_min()); + = ! (my_edge().is_min() == other_edge().is_min()); iperp_map_ = new jtutil::cpm_map<fp>(min_iperp(), max_iperp(), fp_my_period_plane_iperp, - fp_symmetry_period_plane_iperp, + fp_other_period_plane_iperp, is_iperp_map_plus); // // parallel map // ipar_map_ = new jtutil::cpm_map<fp>(extreme_min_ipar(), extreme_max_ipar(), - my_edge_sample_ipar, - symmetry_edge_sample_ipar, + my_edge_sample_ipar, other_edge_sample_ipar, ipar_map_is_plus); } @@ -122,7 +161,7 @@ delete iperp_map_; // void symmetry_ghost_zone::synchronize(int ghosted_min_gfn, int ghosted_max_gfn, bool want_corners = true, - bool want_non_corner = true) + bool want_noncorner = true) { for (int gfn = ghosted_min_gfn ; gfn <= ghosted_max_gfn ; ++gfn) { @@ -131,17 +170,17 @@ void symmetry_ghost_zone::synchronize(int ghosted_min_gfn, int ghosted_max_gfn, for (int ipar = min_ipar(iperp) ; ipar <= max_ipar(iperp) ; ++ipar) { // do we want to do this point? - if (! my_edge().ipar_is_in_selected_part(want_corners, want_non_corner, + if (! my_edge().ipar_is_in_selected_part(want_corners, want_noncorner, ipar) ) then continue; // *** LOOP CONTROL *** const int sym_iperp = iperp_map_of_iperp(iperp); const int sym_ipar = ipar_map_of_ipar (ipar ); - const int sym_irho = symmetry_edge() + const int sym_irho = other_edge() .irho_of_iperp_ipar (sym_iperp,sym_ipar); - const int sym_isigma = symmetry_edge() + const int sym_isigma = other_edge() .isigma_of_iperp_ipar(sym_iperp,sym_ipar); - const fp sym_gridfn = symmetry_patch() + const fp sym_gridfn = other_patch() .ghosted_gridfn(gfn, sym_irho,sym_isigma); const int irho = my_edge(). irho_of_iperp_ipar(iperp,ipar); @@ -162,9 +201,9 @@ void symmetry_ghost_zone::synchronize(int ghosted_min_gfn, int ghosted_max_gfn, interpatch_ghost_zone::interpatch_ghost_zone(const patch_edge& my_edge_in, const patch_edge& other_edge_in, int N_overlap_points) - : ghost_zone(my_edge_in, ghost_zone_is_interpatch), - other_patch_(other_edge_in.my_patch()), - other_edge_(other_edge_in), + : ghost_zone(my_edge_in, + other_edge_in, + ghost_zone_is_interpatch), // remaining pointers are all set up properly by finish_setup() other_patch_interp_(NULL), other_iperp_(NULL), @@ -342,7 +381,7 @@ delete other_patch_interp_; // a given iperp, taking into account how we treat the corners // (cf. the example in the header comments in "ghost_zone.hh"): // -// If an adjacent ghost zone is mirror-symmetry, +// If an adjacent ghost zone is symmetry, // we do not include that corner; // If an adjacent ghost zone is interpatch, // we include up to the diagonal line, and if we are a rho ghost zone, @@ -358,7 +397,7 @@ delete other_patch_interp_; int interpatch_ghost_zone::min_ipar(int iperp) const { return min_par_adjacent_ghost_zone().is_symmetry() - ? my_edge().min_ipar_with_corners() + ? my_edge().min_ipar_without_corners() : my_edge().min_ipar_without_corners() - iabs(iperp - my_edge().nominal_grid_outer_iperp()) + (is_rho() ? 0 : 1); @@ -367,7 +406,7 @@ return min_par_adjacent_ghost_zone().is_symmetry() int interpatch_ghost_zone::max_ipar(int iperp) const { return max_par_adjacent_ghost_zone().is_symmetry() - ? my_edge().max_ipar_with_corners() + ? my_edge().max_ipar_without_corners() : my_edge().max_ipar_without_corners() + iabs(iperp - my_edge().nominal_grid_outer_iperp()) - (is_rho() ? 0 : 1); @@ -393,9 +432,8 @@ max_other_iperp_ = std::max(other_iperp(min_iperp()), other_iperp(max_iperp())); // // set up arrays giving actual [min,max] ipar that we'll use -// at each other_iperp -// ... we will pass these arrays by reference to the other patch's -// patch_interp object, with ipar being parindex there +// at each other_iperp (later on we will pass these arrays to the +// other patch's patch_interp object, with ipar being parindex there // min_ipar_used_ = new jtutil::array1d<int>(min_other_iperp_, max_other_iperp_); max_ipar_used_ = new jtutil::array1d<int>(min_other_iperp_, max_other_iperp_); @@ -447,24 +485,29 @@ interp_result_buffer_ // // construct the patch_interp object to interpolate from the *other* patch -// ... tell it to use corners if and only if the adjacent ghost zones -// are symmetry; cf min_ipar() and max_ipar() functions above, -// and header comments in this file -// -const bool ok_to_use_min_par_corner - = min_par_adjacent_ghost_zone().is_symmetry() +// ... the patch_interp should use gridfn data from it's (the other patch's) +// min/max par ghost zones if those (adjacent) adjacent ghost zones +// are symmetry, but not if they're interpatch, +// cf the header comments in "ghost_zone.hh" +// +const ghost_zone& other_ghost_zone = other_patch() + .ghost_zone_on_edge(other_edge()); +const bool ok_to_use_min_par_ghost_zone + = other_ghost_zone.min_par_adjacent_ghost_zone() + .is_symmetry() ? true : false; -const bool ok_to_use_max_par_corner - = max_par_adjacent_ghost_zone().is_symmetry() +const bool ok_to_use_max_par_ghost_zone + = other_ghost_zone.max_par_adjacent_ghost_zone() + .is_symmetry() ? true : false; other_patch_interp_ = new patch_interp(other_edge(), min_other_iperp_, max_other_iperp_, *min_ipar_used_, *max_ipar_used_, *other_par_, - ok_to_use_min_par_corner, - ok_to_use_max_par_corner, + ok_to_use_min_par_ghost_zone, + ok_to_use_max_par_ghost_zone, interp_handle, interp_par_table_handle); } @@ -487,7 +530,7 @@ assert( other_patch() .ghost_zone_on_edge(other_edge()) .is_interpatch() ); assert( my_patch() == other_patch() - .interpatch_ghost_zone_on_edge(other_edge()) + .ghost_zone_on_edge(other_edge()) .other_patch() ); } @@ -505,17 +548,17 @@ assert( my_patch() == other_patch() void interpatch_ghost_zone::synchronize (int ghosted_min_gfn, int ghosted_max_gfn, bool want_corners = true, - bool want_non_corner = true) + bool want_noncorner = true) { // make sure the caller wants the entire ghost zone -if (! (want_corners && want_non_corner)) +if (! (want_corners && want_noncorner)) then error_exit(ERROR_EXIT, "***** interpatch_ghost_zone::synchronize():\n" " we only support operating on the *entire* ghost zone,\n" " but we were passed flags specifying a proper subset!\n" -" want_corners=(int)%d want_non_corner=(int)%d\n" +" want_corners=(int)%d want_noncorner=(int)%d\n" , - want_corners, want_non_corner); /*NOTREACHED*/ + want_corners, want_noncorner); /*NOTREACHED*/ // do the interpolation into our result buffer other_patch_interp_->interpolate(ghosted_min_gfn, ghosted_max_gfn, @@ -555,18 +598,18 @@ other_patch_interp_->interpolate(ghosted_min_gfn, ghosted_max_gfn, void interpatch_ghost_zone::compute_Jacobian (int ghosted_min_gfn, int ghosted_max_gfn, bool want_corners = true, - bool want_non_corner = true) + bool want_noncorner = true) const { // make sure the caller wants the entire ghost zone -if (! (want_corners && want_non_corner)) +if (! (want_corners && want_noncorner)) then error_exit(ERROR_EXIT, "***** interpatch_ghost_zone::compute_Jacobian():\n" " we only support operating on the *entire* ghost zone,\n" " but we were passed flags specifying a proper subset!\n" -" want_corners=(int)%d want_non_corner=(int)%d\n" +" want_corners=(int)%d want_noncorner=(int)%d\n" , - want_corners, want_non_corner); /*NOTREACHED*/ + want_corners, want_noncorner); /*NOTREACHED*/ assert(other_patch_interp_ != NULL); other_patch_interp_->verify_Jacobian_sparsity_pattern_ok(); |