diff options
Diffstat (limited to 'src/patch')
-rw-r--r-- | src/patch/ghost_zone.cc | 164 | ||||
-rw-r--r-- | src/patch/ghost_zone.hh | 41 | ||||
-rw-r--r-- | src/patch/patch.cc | 28 | ||||
-rw-r--r-- | src/patch/patch.hh | 28 | ||||
-rw-r--r-- | src/patch/patch_system.cc | 442 | ||||
-rw-r--r-- | src/patch/patch_system.hh | 19 | ||||
-rw-r--r-- | src/patch/test_patch_system.cc | 7 |
7 files changed, 367 insertions, 362 deletions
diff --git a/src/patch/ghost_zone.cc b/src/patch/ghost_zone.cc index ec58f18..3c54f18 100644 --- a/src/patch/ghost_zone.cc +++ b/src/patch/ghost_zone.cc @@ -10,7 +10,7 @@ // interpatch_ghost_zone::interpatch_ghost_zone // interpatch_ghost_zone::~interpatch_ghost_zone // interpatch_ghost_zone::[min,max]_ipar -// interpatch_ghost_zone::setup_other_patch_frontier +// interpatch_ghost_zone::finish_setup // interpatch_ghost_zone::assert_fully_setup // interpatch_ghost_zone::synchronize // @@ -20,6 +20,7 @@ #include <stdlib.h> #include <limits.h> #include <math.h> +#include <algorithm> #include "cctk.h" @@ -165,10 +166,9 @@ interpatch_ghost_zone::interpatch_ghost_zone(const patch_edge& my_edge_in, : ghost_zone(my_edge_in, ghost_zone_is_interpatch), other_patch_(other_edge_in.my_patch()), other_edge_(other_edge_in), - other_frontier_(NULL), // set by setup_other_patch_frontier() - // remaining subobjects are all set properly in ctor body + // remaining pointers are all set up properly by finish_setup() + other_frontier_(NULL), other_iperp_(NULL), - other_min_iperp_(0), other_max_iperp_(0), min_ipar_used_(NULL), max_ipar_used_(NULL), other_par_(NULL), interp_result_buffer_(NULL) @@ -316,72 +316,6 @@ const bool is_iperp_map_plus = (iperp_map_sign_pm1 > 0.0); other_iperp_ = new jtutil::cpm_map<fp>(min_iperp(), max_iperp(), sample_iperp, other_sample_iperp, is_iperp_map_plus); -other_min_iperp_ = jtutil::min(other_iperp(min_iperp()), - other_iperp(max_iperp())); -other_max_iperp_ = jtutil::max(other_iperp(min_iperp()), - other_iperp(max_iperp())); - - -// -// set up arrays giving [min,max] ipar that we'll use at each other_iperp -// ... we will pass these arrays by reference to the other patch's -// patch_frontier object, with ipar being parindex there -// -min_ipar_used_ = new jtutil::array1d<int>(other_min_iperp_, other_max_iperp_); -max_ipar_used_ = new jtutil::array1d<int>(other_min_iperp_, other_max_iperp_); - for (int iperp = min_iperp() ; iperp <= max_iperp() ; ++iperp) - { - (*min_ipar_used_)(other_iperp(iperp)) = min_ipar(iperp); - (*max_ipar_used_)(other_iperp(iperp)) = max_ipar(iperp); - } - - -// -// set up array giving other patch's par coordinate for interpolation -// - -// ... note that we can't yet count on any other ghost zone existing, -// so we don't yet know whether or not we'll want our corners -// (since that depends on the type of our patch's adjacent ghost zones) -// ==> we include the corners on the chance we may want them later, -// and use the appropriate parts of them in synchronize() below -other_par_ = new jtutil::array2d<fp> - (other_min_iperp_, other_max_iperp_, - ghost_zone_min_ipar(), ghost_zone_max_ipar()); - - for (int iperp = min_iperp() ; iperp <= max_iperp() ; ++iperp) - { - for (int ipar = ghost_zone_min_ipar() ; - ipar <= ghost_zone_max_ipar() ; - ++ipar) - { - // compute the other_par corresponding to (iperp,ipar) - // ... here we use the fact (which we verified above) that - // other edge's parallel coordinate == our tau coordinate - // (at least modulo 2*pi radians = 360 degrees) - const fp perp = my_edge().perp_of_iperp(iperp); - const fp par = my_edge().par_of_ipar(ipar); - - const fp rho = my_edge(). rho_of_perp_par(perp, par); - const fp sigma = my_edge().sigma_of_perp_par(perp, par); - - const fp tau = my_patch().tau_of_rho_sigma(rho, sigma); - const fp other_par = other_patch() - .modulo_reduce_ang(other_edge().par_is_rho(), tau); - - (*other_par_)(other_iperp(iperp),ipar) = other_par; - } - } - - -// -// set up interpolation result buffer -// -interp_result_buffer_ - = new jtutil::array3d<fp> - (my_patch().ghosted_min_gfn(), my_patch().ghosted_max_gfn(), - other_min_iperp_, other_max_iperp_, - ghost_zone_min_ipar(), ghost_zone_max_ipar()); } //****************************************************************************** @@ -439,21 +373,91 @@ return max_par_adjacent_ghost_zone().is_symmetry() //****************************************************************************** // -// This function constructs the *other* patch's patch_frontier:: object, -// and interlinks it with this ghost zone and the other patch. +// This function finishes the construction/setup of an interpatch_ghost_zone +// object. It +// - sets up the par coordinate mapping information +// - sets up the interpolator data pointer and result arrays +// - constructs the *other* patch's patch_frontier:: object +// and sets our patch frontier pointer to point to it // // We use our ipar as the patch_frontier's parindex. // -void interpatch_ghost_zone::setup_other_patch_frontier - (int interp_handle, int interp_par_table_handle) +void interpatch_ghost_zone::finish_setup(int interp_handle, + int interp_par_table_handle) { -other_frontier_ - = new patch_frontier(other_edge(), - other_min_iperp_, other_max_iperp_, - *min_ipar_used_, *max_ipar_used_, - *other_par_, - interp_handle, interp_par_table_handle); +const int other_min_iperp = std::min(other_iperp(min_iperp()), + other_iperp(max_iperp())); +const int other_max_iperp = std::max(other_iperp(min_iperp()), + other_iperp(max_iperp())); +// +// set up arrays giving [min,max] ipar that we'll use at each other_iperp +// ... we will pass these arrays by reference to the other patch's +// patch_frontier object, with ipar being parindex there +// +min_ipar_used_ = new jtutil::array1d<int>(other_min_iperp, other_max_iperp); +max_ipar_used_ = new jtutil::array1d<int>(other_min_iperp, other_max_iperp); + for (int iperp = min_iperp() ; iperp <= max_iperp() ; ++iperp) + { + (*min_ipar_used_)(other_iperp(iperp)) = min_ipar(iperp); + (*max_ipar_used_)(other_iperp(iperp)) = max_ipar(iperp); + } + + +// +// set up array giving other patch's par coordinate for interpolation +// + +// ... note that we can't yet count on any other ghost zone existing, +// so we don't yet know whether or not we'll want our corners +// (since that depends on the type of our patch's adjacent ghost zones) +// ==> we include the corners on the chance we may want them later, +// and use the appropriate parts of them in synchronize() below +other_par_ = new jtutil::array2d<fp> + (other_min_iperp, other_max_iperp, + ghost_zone_min_ipar(), ghost_zone_max_ipar()); + + for (int iperp = min_iperp() ; iperp <= max_iperp() ; ++iperp) + { + for (int ipar = ghost_zone_min_ipar() ; + ipar <= ghost_zone_max_ipar() ; + ++ipar) + { + // compute the other_par corresponding to (iperp,ipar) + // ... here we use the fact (which we verified above) that + // other edge's parallel coordinate == our tau coordinate + // (at least modulo 2*pi radians = 360 degrees) + const fp perp = my_edge().perp_of_iperp(iperp); + const fp par = my_edge().par_of_ipar(ipar); + const fp rho = my_edge(). rho_of_perp_par(perp, par); + const fp sigma = my_edge().sigma_of_perp_par(perp, par); + + const fp tau = my_patch().tau_of_rho_sigma(rho, sigma); + const fp other_par = other_patch() + .modulo_reduce_ang(other_edge().par_is_rho(), tau); + + (*other_par_)(other_iperp(iperp),ipar) = other_par; + } + } + + +// +// set up interpolation result buffer +// +interp_result_buffer_ + = new jtutil::array3d<fp> + (my_patch().ghosted_min_gfn(), my_patch().ghosted_max_gfn(), + other_min_iperp, other_max_iperp, + ghost_zone_min_ipar(), ghost_zone_max_ipar()); + +// +// construct and link to the *other* patch's frontier +// +other_frontier_ = new patch_frontier(other_edge(), + other_min_iperp, other_max_iperp, + *min_ipar_used_, *max_ipar_used_, + *other_par_, + interp_handle, interp_par_table_handle); other_patch().set_patch_frontier(other_edge(), other_frontier_); } diff --git a/src/patch/ghost_zone.hh b/src/patch/ghost_zone.hh index 6020166..141c75d 100644 --- a/src/patch/ghost_zone.hh +++ b/src/patch/ghost_zone.hh @@ -449,7 +449,7 @@ private: //***************************************************************************** // -// derived class for interpatch ghost zone of a patch +// interpatch_ghost_zone - derived class for interpatch ghost zone of a patch // // A ghost_zone object maps (my_iperp,my_ipar) coordinates to the other // patch's (other_iperp,other_par) coordinates, then calls the other patch's @@ -466,9 +466,9 @@ private: // the 2nd and 3rd phase of the overall 3-phase construction process // described at the comments at the start of this file. // - first set up the object itslf and its links to/from the patches -// and their edges -// - then set up and link to the other patch's patch_frontier object -// from which this object will interpolate +// and their edges [this is done by our constructor] +// - then set up the interpatch mapping information, data pointers, +// and interpolation result buffer [this is done by finish_setup() ] // class patch_frontier; @@ -508,20 +508,21 @@ public: return other_iperp_->map(iperp); } - // construct *other* patch's frontier, - // interlink it with this ghost zone and the other patch - void setup_other_patch_frontier(int interp_handle, - int interp_par_table_handle); - // assert() that frontier pointer is non-NULL, // that other patch has interpatch ghost zone on this edge, // and that it points back to us void assert_fully_setup() const; - // constructor, destructor + // constructor et al, destructor interpatch_ghost_zone(const patch_edge& my_edge_in, const patch_edge& other_edge_in, int N_overlap_points); + // finish setup (requires adjacent-side ghost_zone objects + // to exist, though not to have finish_setup() called): + // - setup par coordinate mapping information + // - setup interpolator data pointers & result buffer + // - create *other* patch's frontier and setup pointer to it + void finish_setup(int interp_handle, int interp_par_table_handle); ~interpatch_ghost_zone(); private: @@ -535,26 +536,20 @@ private: patch& other_patch_; const patch_edge& other_edge_; - // initialized to NULL in constructor, - // set to proper value by setup_other_patch_frontier() - // ... we do *not* own this object (the other patch does)! - // ... see comment in "patch_frontier.hh" for why this is "const" - const patch_frontier* other_frontier_; - // - // our remaining subobjects are all pointed-to because - // we won't know the range of other_iperp (which we need - // to initialize the subobjects) until partway into the - // body of our constructor + // all the remaining subobjects are initialized to NULL + // pointers in our constructor, then properly set up by + // finish_setup() // + // see comment in "patch_frontier.hh" for why this is "const" + // n.b. we do *not* own this object (the other patch does)! + const patch_frontier* other_frontier_; + // other patch's iperp coordinates of our ghost zone points // ... maps my_iperp --> other_iperp jtutil::cpm_map<fp>* other_iperp_; - // other patch's [min,max]_iperp of our ghost zone points - int other_min_iperp_, other_max_iperp_; - // [min,max]_ipar used at each other_iperp // ... we will pass these arrays by reference // to the other patch's patch_frontier object diff --git a/src/patch/patch.cc b/src/patch/patch.cc index bee350d..393a385 100644 --- a/src/patch/patch.cc +++ b/src/patch/patch.cc @@ -11,9 +11,9 @@ // patch::minmax_ang_ghost_zone // patch::ghost_zone_on_edge // patch::interpatch_ghost_zone_on_edge -// patch::setup_mirror_symmetry_ghost_zone -// patch::setup_periodic_symmetry_ghost_zone -// patch::setup_interpatch_ghost_zone +// patch::create_mirror_symmetry_ghost_zone +// patch::create_periodic_symmetry_ghost_zone +// patch::create_interpatch_ghost_zone // patch::set_ghost_zone // patch::edge_adjacent_to_patch // patch::assert_all_ghost_zones_fully_setup @@ -214,11 +214,10 @@ return static_cast<interpatch_ghost_zone &>(g); // // This function assert()s that a specified ghost zone of this patch -// hasn't already been set up, then sets it up as a mirror-symmetry -// ghost zone. It returns a reference to the newly-set-up symmetry -// ghost zone object. +// hasn't already been set up, then constructs it as a mirror-symmetry +// ghost zone and properly links this to/from the patch. // -symmetry_ghost_zone& patch::setup_mirror_symmetry_ghost_zone +symmetry_ghost_zone& patch::create_mirror_symmetry_ghost_zone (const patch_edge& my_edge) { // make sure we belong to the right patch @@ -233,11 +232,10 @@ return *temp; // // This function assert()s that a specified ghost zone of this patch -// hasn't already been set up, then sets it up as a periodic-symmetry -// ghost zone. It returns a reference to the newly-set-up symmetry -// ghost zone object. +// hasn't already been set up, then creates it as a periodic-symmetry +// ghost zone and properly links this to/from the patch. // -symmetry_ghost_zone& patch::setup_periodic_symmetry_ghost_zone +symmetry_ghost_zone& patch::create_periodic_symmetry_ghost_zone (const patch_edge& my_edge, const patch_edge& symmetry_edge, bool is_ipar_map_plus) { @@ -261,11 +259,11 @@ return *temp; // // This function assert()s that a specified ghost zone of this patch -// hasn't already been set up, then sets it up as an interpatch ghost -// zone. It returns a reference to the newly-set-up interpatch ghost -// zone object. +// hasn't already been set up, then creates it as an interpatch ghost +// zone (with lots of NULL pointers for info we can't compute yet) +// and properly links this to/from the patch. // -interpatch_ghost_zone& patch::setup_interpatch_ghost_zone +interpatch_ghost_zone& patch::create_interpatch_ghost_zone (const patch_edge& my_edge, const patch_edge& other_edge, int N_overlap_points) { diff --git a/src/patch/patch.hh b/src/patch/patch.hh index 4f3e907..202f94a 100644 --- a/src/patch/patch.hh +++ b/src/patch/patch.hh @@ -93,15 +93,17 @@ // * The patch constructors themselves construct the patch_edge objects // and links them to/from the patches. // * The patch_system constructor calls the appropriate functions -// patch::setup_mirror_symmetry_ghost_zone() -// patch::setup_periodic_symmetry_ghost_zone() -// patch::setup_interpatch_ghost_zone() +// patch::create_mirror_symmetry_ghost_zone() +// patch::create_periodic_symmetry_ghost_zone() +// patch::create_interpatch_ghost_zone() // to construct the ghost_zone objects and link them to/from the // patches. -// * The patch_system constructor calls the function -// patch::setup_other_patch_frontier() -// to construct the patch_frontier objects and link them to/from the -// patches and ghost zones. +// * The patch_system constructor calls the functions +// interpatch_ghost_zone::finish_setup() +// to finish setting up the interpatch_ghost_zone objects, construct +// the patch_frontier objects and interlink them from their patches, +// and finish linking the interpatch_ghost_zone objects to the +// patch_frontier objects. // //***************************************************************************** @@ -312,13 +314,13 @@ public: // assert() that this ghost zone hasn't been set up yet, // then set it up as mirror-symmetry // ... return reference to newly-set-up ghost zone object - symmetry_ghost_zone& setup_mirror_symmetry_ghost_zone + symmetry_ghost_zone& create_mirror_symmetry_ghost_zone (const patch_edge& edge); // assert() that this ghost zone hasn't been set up yet, // then set it up as periodic-symmetry // ... return reference to newly-set-up ghost zone object - symmetry_ghost_zone& setup_periodic_symmetry_ghost_zone + symmetry_ghost_zone& create_periodic_symmetry_ghost_zone (const patch_edge& my_edge, const patch_edge& symmetry_edge, bool ipar_map_is_plus); @@ -327,7 +329,7 @@ public: // ... but don't link it to the other patch's frontier // (which doesn't exist yet) // ... return reference to newly-set-up ghost zone object - interpatch_ghost_zone& setup_interpatch_ghost_zone + interpatch_ghost_zone& create_interpatch_ghost_zone (const patch_edge& my_edge, const patch_edge& other_edge, int N_overlap_points); @@ -424,9 +426,9 @@ private: // ghost zones // ... pointers are set to NULL by ctor, // reset to non-NULL by set_ghost_zone(), which is called by - // setup_mirror_symmetry_ghost_zone() - // setup_periodic_symmetry_ghost_zone() - // setup_interpatch_ghost_zone() + // create_mirror_symmetry_ghost_zone() + // create_periodic_symmetry_ghost_zone() + // create_interpatch_ghost_zone() ghost_zone* min_rho_ghost_zone_; ghost_zone* max_rho_ghost_zone_; ghost_zone* min_sigma_ghost_zone_; diff --git a/src/patch/patch_system.cc b/src/patch/patch_system.cc index c904c64..43172c4 100644 --- a/src/patch/patch_system.cc +++ b/src/patch/patch_system.cc @@ -3,15 +3,15 @@ // // patch_system::patch_system // patch_system::~patch_system -// patch_system::construct_patches +// patch_system::create_patches // patch_system::setup_gridfn_storage // patch_system::setup_full_sphere_patch_system // patch_system::setup_plus_z_hemisphere_patch_system // patch_system::setup_plus_xy_quadrant_patch_system // patch_system::setup_plus_xz_quadrant_patch_system // patch_system::setup_octant_patch_system -// patch_system::setup_adjacent_ghost_zones -// patch_system::setup_adjacent_patch_frontiers +// patch_system::create_interpatch_ghost_zones +// patch_system::finish_interpatch_setup // patch_system::assert_all_ghost_zones_fully_setup // // patch_system::N_patches_of_type @@ -102,9 +102,9 @@ const int N_extend_points = N_overlap_points >> 1; switch (type_in) { case full_sphere_patch_system: - construct_patches(patch_system_info::full_sphere::patch_info_array, - N_ghost_points, N_extend_points, - delta_drho_dsigma); + create_patches(patch_system_info::full_sphere::patch_info_array, + N_ghost_points, N_extend_points, + delta_drho_dsigma); setup_gridfn_storage(min_gfn_in, max_gfn_in, ghosted_min_gfn_in, ghosted_max_gfn_in); interlink_full_sphere_patch_system(N_overlap_points, @@ -112,10 +112,9 @@ case full_sphere_patch_system: interp_par_table_handle); break; case plus_z_hemisphere_patch_system: - construct_patches(patch_system_info::plus_z_hemisphere - ::patch_info_array, - N_ghost_points, N_extend_points, - delta_drho_dsigma); + create_patches(patch_system_info::plus_z_hemisphere::patch_info_array, + N_ghost_points, N_extend_points, + delta_drho_dsigma); setup_gridfn_storage(min_gfn_in, max_gfn_in, ghosted_min_gfn_in, ghosted_max_gfn_in); interlink_plus_z_hemisphere_patch_system(N_overlap_points, @@ -123,9 +122,9 @@ case plus_z_hemisphere_patch_system: interp_par_table_handle); break; case plus_xy_quadrant_patch_system: - construct_patches(patch_system_info::plus_xy_quadrant::patch_info_array, - N_ghost_points, N_extend_points, - delta_drho_dsigma); + create_patches(patch_system_info::plus_xy_quadrant::patch_info_array, + N_ghost_points, N_extend_points, + delta_drho_dsigma); setup_gridfn_storage(min_gfn_in, max_gfn_in, ghosted_min_gfn_in, ghosted_max_gfn_in); interlink_plus_xy_quadrant_patch_system(N_overlap_points, @@ -133,9 +132,9 @@ case plus_xy_quadrant_patch_system: interp_par_table_handle); break; case plus_xz_quadrant_patch_system: - construct_patches(patch_system_info::plus_xz_quadrant::patch_info_array, - N_ghost_points, N_extend_points, - delta_drho_dsigma); + create_patches(patch_system_info::plus_xz_quadrant::patch_info_array, + N_ghost_points, N_extend_points, + delta_drho_dsigma); setup_gridfn_storage(min_gfn_in, max_gfn_in, ghosted_min_gfn_in, ghosted_max_gfn_in); interlink_plus_xz_quadrant_patch_system(N_overlap_points, @@ -143,9 +142,9 @@ case plus_xz_quadrant_patch_system: interp_par_table_handle); break; case plus_xyz_octant_patch_system: - construct_patches(patch_system_info::plus_xyz_octant::patch_info_array, - N_ghost_points, N_extend_points, - delta_drho_dsigma); + create_patches(patch_system_info::plus_xyz_octant::patch_info_array, + N_ghost_points, N_extend_points, + delta_drho_dsigma); setup_gridfn_storage(min_gfn_in, max_gfn_in, ghosted_min_gfn_in, ghosted_max_gfn_in); interlink_plus_xyz_octant_patch_system(N_overlap_points, @@ -188,9 +187,9 @@ delete gridfn_storage_; // This function does *NOT* create any of the ghost zones or frontiers, // and does *NOT* set up any gridfns. // -void patch_system::construct_patches(const struct patch_info patch_info_in[], - int N_ghost_points, int N_extend_points, - fp delta_drho_dsigma) +void patch_system::create_patches(const struct patch_info patch_info_in[], + int N_ghost_points, int N_extend_points, + fp delta_drho_dsigma) { CCTK_VInfo(CCTK_THORNSTRING, "constructing %s patch system", @@ -237,7 +236,7 @@ ghosted_N_grid_points_ = 0; break; default: error_exit(ERROR_EXIT, -"***** patch_system::construct_patches():\n" +"***** patch_system::create_patches():\n" " unknown patch_info_in[pn=%d].ctype=0x%02d='%c'!\n" , pn, pi.ctype, pi.ctype); /*NOTREACHED*/ @@ -436,58 +435,59 @@ patch& my = ith_patch(patch_number_of_name("-y")); patch& mz = ith_patch(patch_number_of_name("-z")); // create the ghost zones -CCTK_VInfo(CCTK_THORNSTRING, " setting up ghost zones"); -setup_adjacent_ghost_zones(pz, px, N_overlap_points); -setup_adjacent_ghost_zones(pz, py, N_overlap_points); -setup_adjacent_ghost_zones(pz, mx, N_overlap_points); -setup_adjacent_ghost_zones(pz, my, N_overlap_points); -setup_adjacent_ghost_zones(px, py, N_overlap_points); -setup_adjacent_ghost_zones(py, mx, N_overlap_points); -setup_adjacent_ghost_zones(mx, my, N_overlap_points); -setup_adjacent_ghost_zones(my, px, N_overlap_points); -setup_adjacent_ghost_zones(mz, px, N_overlap_points); -setup_adjacent_ghost_zones(mz, py, N_overlap_points); -setup_adjacent_ghost_zones(mz, mx, N_overlap_points); -setup_adjacent_ghost_zones(mz, my, N_overlap_points); - -// create the patch frontiers -CCTK_VInfo(CCTK_THORNSTRING, " setting up patch frontiers"); -setup_adjacent_patch_frontiers(pz, px, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(pz, py, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(pz, mx, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(pz, my, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(px, py, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(py, mx, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(mx, my, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(my, px, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(mz, px, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(mz, py, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(mz, mx, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(mz, my, - N_overlap_points, - interp_handle, interp_par_table_handle); +CCTK_VInfo(CCTK_THORNSTRING, " creating ghost zones"); +create_interpatch_ghost_zones(pz, px, N_overlap_points); +create_interpatch_ghost_zones(pz, py, N_overlap_points); +create_interpatch_ghost_zones(pz, mx, N_overlap_points); +create_interpatch_ghost_zones(pz, my, N_overlap_points); +create_interpatch_ghost_zones(px, py, N_overlap_points); +create_interpatch_ghost_zones(py, mx, N_overlap_points); +create_interpatch_ghost_zones(mx, my, N_overlap_points); +create_interpatch_ghost_zones(my, px, N_overlap_points); +create_interpatch_ghost_zones(mz, px, N_overlap_points); +create_interpatch_ghost_zones(mz, py, N_overlap_points); +create_interpatch_ghost_zones(mz, mx, N_overlap_points); +create_interpatch_ghost_zones(mz, my, N_overlap_points); + +// finish setting up the interpatch ghost zones and patch frontiers +CCTK_VInfo(CCTK_THORNSTRING, + " finishing setting up interpatch ghost zones + patch frontiers"); +finish_interpatch_setup(pz, px, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(pz, py, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(pz, mx, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(pz, my, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(px, py, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(py, mx, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(mx, my, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(my, px, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(mz, px, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(mz, py, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(mz, mx, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(mz, my, + N_overlap_points, + interp_handle, interp_par_table_handle); assert_all_ghost_zones_fully_setup(); } @@ -511,46 +511,47 @@ patch& mx = ith_patch(patch_number_of_name("-x")); patch& my = ith_patch(patch_number_of_name("-y")); // create the ghost zones -CCTK_VInfo(CCTK_THORNSTRING, " setting up ghost zones"); -setup_adjacent_ghost_zones(pz, px, N_overlap_points); -setup_adjacent_ghost_zones(pz, py, N_overlap_points); -setup_adjacent_ghost_zones(pz, mx, N_overlap_points); -setup_adjacent_ghost_zones(pz, my, N_overlap_points); -setup_adjacent_ghost_zones(px, py, N_overlap_points); -setup_adjacent_ghost_zones(py, mx, N_overlap_points); -setup_adjacent_ghost_zones(mx, my, N_overlap_points); -setup_adjacent_ghost_zones(my, px, N_overlap_points); -px.setup_mirror_symmetry_ghost_zone(px.max_rho_patch_edge()); -py.setup_mirror_symmetry_ghost_zone(py.max_rho_patch_edge()); -mx.setup_mirror_symmetry_ghost_zone(mx.min_rho_patch_edge()); -my.setup_mirror_symmetry_ghost_zone(my.min_rho_patch_edge()); - -// create the patch frontiers -CCTK_VInfo(CCTK_THORNSTRING, " setting up patch frontiers"); -setup_adjacent_patch_frontiers(pz, px, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(pz, py, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(pz, mx, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(pz, my, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(px, py, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(py, mx, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(mx, my, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(my, px, - N_overlap_points, - interp_handle, interp_par_table_handle); +CCTK_VInfo(CCTK_THORNSTRING, " creating ghost zones"); +create_interpatch_ghost_zones(pz, px, N_overlap_points); +create_interpatch_ghost_zones(pz, py, N_overlap_points); +create_interpatch_ghost_zones(pz, mx, N_overlap_points); +create_interpatch_ghost_zones(pz, my, N_overlap_points); +create_interpatch_ghost_zones(px, py, N_overlap_points); +create_interpatch_ghost_zones(py, mx, N_overlap_points); +create_interpatch_ghost_zones(mx, my, N_overlap_points); +create_interpatch_ghost_zones(my, px, N_overlap_points); +px.create_mirror_symmetry_ghost_zone(px.max_rho_patch_edge()); +py.create_mirror_symmetry_ghost_zone(py.max_rho_patch_edge()); +mx.create_mirror_symmetry_ghost_zone(mx.min_rho_patch_edge()); +my.create_mirror_symmetry_ghost_zone(my.min_rho_patch_edge()); + +// finish setting up the interpatch ghost zones and patch frontiers +CCTK_VInfo(CCTK_THORNSTRING, + " finishing setting up interpatch ghost zones + patch frontiers"); +finish_interpatch_setup(pz, px, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(pz, py, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(pz, mx, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(pz, my, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(px, py, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(py, mx, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(mx, my, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(my, px, + N_overlap_points, + interp_handle, interp_par_table_handle); assert_all_ghost_zones_fully_setup(); } @@ -573,39 +574,40 @@ patch& py = ith_patch(patch_number_of_name("+y")); patch& mz = ith_patch(patch_number_of_name("-z")); // create the ghost zones -CCTK_VInfo(CCTK_THORNSTRING, " setting up ghost zones"); -setup_adjacent_ghost_zones(pz, px, N_overlap_points); -setup_adjacent_ghost_zones(pz, py, N_overlap_points); -setup_adjacent_ghost_zones(px, py, N_overlap_points); -setup_adjacent_ghost_zones(mz, px, N_overlap_points); -setup_adjacent_ghost_zones(mz, py, N_overlap_points); -setup_periodic_symmetry_ghost_zones(pz.min_rho_patch_edge(), - pz.min_sigma_patch_edge(), - true); -setup_periodic_symmetry_ghost_zones(px.min_sigma_patch_edge(), - py.max_sigma_patch_edge(), - true); -setup_periodic_symmetry_ghost_zones(mz.max_rho_patch_edge(), - mz.max_sigma_patch_edge(), - true); - -// create the patch frontiers -CCTK_VInfo(CCTK_THORNSTRING, " setting up patch frontiers"); -setup_adjacent_patch_frontiers(pz, px, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(pz, py, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(px, py, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(mz, px, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(mz, py, - N_overlap_points, - interp_handle, interp_par_table_handle); +CCTK_VInfo(CCTK_THORNSTRING, " creating ghost zones"); +create_interpatch_ghost_zones(pz, px, N_overlap_points); +create_interpatch_ghost_zones(pz, py, N_overlap_points); +create_interpatch_ghost_zones(px, py, N_overlap_points); +create_interpatch_ghost_zones(mz, px, N_overlap_points); +create_interpatch_ghost_zones(mz, py, N_overlap_points); +create_periodic_symmetry_ghost_zones(pz.min_rho_patch_edge(), + pz.min_sigma_patch_edge(), + true); +create_periodic_symmetry_ghost_zones(px.min_sigma_patch_edge(), + py.max_sigma_patch_edge(), + true); +create_periodic_symmetry_ghost_zones(mz.max_rho_patch_edge(), + mz.max_sigma_patch_edge(), + true); + +// finish setting up the interpatch ghost zones and patch frontiers +CCTK_VInfo(CCTK_THORNSTRING, + " finishing setting up interpatch ghost zones + patch frontiers"); +finish_interpatch_setup(pz, px, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(pz, py, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(px, py, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(mz, px, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(mz, py, + N_overlap_points, + interp_handle, interp_par_table_handle); assert_all_ghost_zones_fully_setup(); } @@ -628,39 +630,40 @@ patch& py = ith_patch(patch_number_of_name("+y")); patch& my = ith_patch(patch_number_of_name("-y")); // create the ghost zones -CCTK_VInfo(CCTK_THORNSTRING, " setting up ghost zones"); -setup_adjacent_ghost_zones(pz, px, N_overlap_points); -setup_adjacent_ghost_zones(pz, py, N_overlap_points); -setup_adjacent_ghost_zones(pz, my, N_overlap_points); -setup_adjacent_ghost_zones(px, py, N_overlap_points); -setup_adjacent_ghost_zones(px, my, N_overlap_points); -px.setup_mirror_symmetry_ghost_zone(px.max_rho_patch_edge()); -py.setup_mirror_symmetry_ghost_zone(py.max_rho_patch_edge()); -my.setup_mirror_symmetry_ghost_zone(my.min_rho_patch_edge()); -setup_periodic_symmetry_ghost_zones(pz.min_sigma_patch_edge(), - pz.min_sigma_patch_edge(), - false); -setup_periodic_symmetry_ghost_zones(py.max_sigma_patch_edge(), - my.min_sigma_patch_edge(), - false); - -// create the patch frontiers -CCTK_VInfo(CCTK_THORNSTRING, " setting up patch frontiers"); -setup_adjacent_patch_frontiers(pz, px, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(pz, py, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(pz, my, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(px, py, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(px, my, - N_overlap_points, - interp_handle, interp_par_table_handle); +CCTK_VInfo(CCTK_THORNSTRING, " creating ghost zones"); +create_interpatch_ghost_zones(pz, px, N_overlap_points); +create_interpatch_ghost_zones(pz, py, N_overlap_points); +create_interpatch_ghost_zones(pz, my, N_overlap_points); +create_interpatch_ghost_zones(px, py, N_overlap_points); +create_interpatch_ghost_zones(px, my, N_overlap_points); +px.create_mirror_symmetry_ghost_zone(px.max_rho_patch_edge()); +py.create_mirror_symmetry_ghost_zone(py.max_rho_patch_edge()); +my.create_mirror_symmetry_ghost_zone(my.min_rho_patch_edge()); +create_periodic_symmetry_ghost_zones(pz.min_sigma_patch_edge(), + pz.min_sigma_patch_edge(), + false); +create_periodic_symmetry_ghost_zones(py.max_sigma_patch_edge(), + my.min_sigma_patch_edge(), + false); + +// finish setting up the interpatch ghost zones and patch frontiers +CCTK_VInfo(CCTK_THORNSTRING, + " finishing setting up interpatch ghost zones + patch frontiers"); +finish_interpatch_setup(pz, px, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(pz, py, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(pz, my, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(px, py, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(px, my, + N_overlap_points, + interp_handle, interp_par_table_handle); assert_all_ghost_zones_fully_setup(); } @@ -682,30 +685,31 @@ patch& px = ith_patch(patch_number_of_name("+x")); patch& py = ith_patch(patch_number_of_name("+y")); // create the ghost zones -CCTK_VInfo(CCTK_THORNSTRING, " setting up ghost zones"); -setup_adjacent_ghost_zones(pz, px, N_overlap_points); -setup_adjacent_ghost_zones(pz, py, N_overlap_points); -setup_adjacent_ghost_zones(px, py, N_overlap_points); -px.setup_mirror_symmetry_ghost_zone(px.max_rho_patch_edge()); -py.setup_mirror_symmetry_ghost_zone(py.max_rho_patch_edge()); -setup_periodic_symmetry_ghost_zones(pz.min_rho_patch_edge(), - pz.min_sigma_patch_edge(), - true); -setup_periodic_symmetry_ghost_zones(px.min_sigma_patch_edge(), - py.max_sigma_patch_edge(), - true); - -// create the patch frontiers -CCTK_VInfo(CCTK_THORNSTRING, " setting up patch frontiers"); -setup_adjacent_patch_frontiers(pz, px, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(pz, py, - N_overlap_points, - interp_handle, interp_par_table_handle); -setup_adjacent_patch_frontiers(px, py, - N_overlap_points, - interp_handle, interp_par_table_handle); +CCTK_VInfo(CCTK_THORNSTRING, " creating ghost zones"); +create_interpatch_ghost_zones(pz, px, N_overlap_points); +create_interpatch_ghost_zones(pz, py, N_overlap_points); +create_interpatch_ghost_zones(px, py, N_overlap_points); +px.create_mirror_symmetry_ghost_zone(px.max_rho_patch_edge()); +py.create_mirror_symmetry_ghost_zone(py.max_rho_patch_edge()); +create_periodic_symmetry_ghost_zones(pz.min_rho_patch_edge(), + pz.min_sigma_patch_edge(), + true); +create_periodic_symmetry_ghost_zones(px.min_sigma_patch_edge(), + py.max_sigma_patch_edge(), + true); + +// finish setting up the interpatch ghost zones and patch frontiers +CCTK_VInfo(CCTK_THORNSTRING, + " finishing setting up interpatch ghost zones + patch frontiers"); +finish_interpatch_setup(pz, px, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(pz, py, + N_overlap_points, + interp_handle, interp_par_table_handle); +finish_interpatch_setup(px, py, + N_overlap_points, + interp_handle, interp_par_table_handle); assert_all_ghost_zones_fully_setup(); } @@ -718,11 +722,11 @@ assert_all_ghost_zones_fully_setup(); // This function creates a pair of periodic-symmetry ghost zones. // //static - void patch_system::setup_periodic_symmetry_ghost_zones + void patch_system::create_periodic_symmetry_ghost_zones (const patch_edge& ex, const patch_edge& ey, bool ipar_map_is_plus) { -ex.my_patch().setup_periodic_symmetry_ghost_zone(ex, ey, ipar_map_is_plus); +ex.my_patch().create_periodic_symmetry_ghost_zone(ex, ey, ipar_map_is_plus); if (ex == ey) then { @@ -730,7 +734,7 @@ if (ex == ey) // back to itself), so we only want to set up the edge once // ==> no-op here } - else ey.my_patch().setup_periodic_symmetry_ghost_zone(ey, ex, + else ey.my_patch().create_periodic_symmetry_ghost_zone(ey, ex, ipar_map_is_plus); } @@ -738,29 +742,29 @@ if (ex == ey) // // This function automagically figures out which edges of two adjacent -// patches are adjacent, then sets up both patches' ghost zones on those -// edges. +// patches are adjacent, then creates both patches' ghost zones on those +// edges and interlinks them with their respective patches. // //static - void patch_system::setup_adjacent_ghost_zones(patch &px, patch &py, - int N_overlap_points) + void patch_system::create_interpatch_ghost_zones(patch &px, patch &py, + int N_overlap_points) { const patch_edge& ex = px.edge_adjacent_to_patch(py, N_overlap_points); const patch_edge& ey = py.edge_adjacent_to_patch(px, N_overlap_points); -px.setup_interpatch_ghost_zone(ex, ey, N_overlap_points); -py.setup_interpatch_ghost_zone(ey, ex, N_overlap_points); +px.create_interpatch_ghost_zone(ex, ey, N_overlap_points); +py.create_interpatch_ghost_zone(ey, ex, N_overlap_points); } //****************************************************************************** // // This function automagically figures out which edges of two adjacent -// patches are adjacent, then sets up the appropriate pair of patch -// frontiers and interlinks them with their ghost zones and patches. +// patches are adjacent, then finishes setting up both ghost zones and +// sets up the corresponding patch frontiers. // //static - void patch_system::setup_adjacent_patch_frontiers + void patch_system::finish_interpatch_setup (patch &px, patch &py, int N_overlap_points, int interp_handle, int interp_par_table_handle) @@ -768,9 +772,9 @@ py.setup_interpatch_ghost_zone(ey, ex, N_overlap_points); const patch_edge& ex = px.edge_adjacent_to_patch(py, N_overlap_points); const patch_edge& ey = py.edge_adjacent_to_patch(px, N_overlap_points); px.interpatch_ghost_zone_on_edge(ex) - .setup_other_patch_frontier(interp_handle, interp_par_table_handle); + .finish_setup(interp_handle, interp_par_table_handle); py.interpatch_ghost_zone_on_edge(ey) - .setup_other_patch_frontier(interp_handle, interp_par_table_handle); + .finish_setup(interp_handle, interp_par_table_handle); } //****************************************************************************** diff --git a/src/patch/patch_system.hh b/src/patch/patch_system.hh index 140675e..c445195 100644 --- a/src/patch/patch_system.hh +++ b/src/patch/patch_system.hh @@ -164,9 +164,9 @@ private: // and link them into the patch system // does *NOT* create ghost zones or frontiers // does *NOT* set up gridfns - void construct_patches(const struct patch_info patch_info_in[], - int N_ghost_points, int N_extend_points, - fp delta_drho_dsigma); + void create_patches(const struct patch_info patch_info_in[], + int N_ghost_points, int N_extend_points, + fp delta_drho_dsigma); // setup all gridfns with contiguous-across-patches storage void setup_gridfn_storage @@ -192,20 +192,21 @@ private: // create/interlink a pair of periodic-symmetry ghost zones static - void setup_periodic_symmetry_ghost_zones + void create_periodic_symmetry_ghost_zones (const patch_edge& ex, const patch_edge& ey, bool ipar_map_is_plus); - // create/interlink a pair of interpatch ghost zones + // construct a pair of interpatch ghost zones // ... automagically figures out which edges are adjacent static - void setup_adjacent_ghost_zones(patch &px, patch &py, - int N_overlap_points); + void create_interpatch_ghost_zones(patch &px, patch &py, + int N_overlap_points); - // create/interlink a pair of patch frontiers + // finish setup of a pair of interpatch ghost zones, + // setup the corresponding patch frontiers // ... automagically figures out which edges are adjacent static - void setup_adjacent_patch_frontiers + void finish_interpatch_setup (patch &px, patch &py, int N_overlap_points, int interp_handle, int interp_par_table_handle); diff --git a/src/patch/test_patch_system.cc b/src/patch/test_patch_system.cc index e59c38f..aefe552 100644 --- a/src/patch/test_patch_system.cc +++ b/src/patch/test_patch_system.cc @@ -13,7 +13,7 @@ #include "util_Table.h" #include "cctk.h" -//#include "cctk_Arguments.h" +#include "cctk_Arguments.h" #include "cctk_Parameters.h" #include "jt/stdc.h" @@ -39,7 +39,7 @@ using jtutil::error_exit; // ***** prototypes ***** // extern "C" - void test_patch_system(); + void test_patch_system(CCTK_ARGUMENTS); //****************************************************************************** @@ -47,8 +47,9 @@ extern "C" // This function is the Cactus interface for the test driver. // extern "C" - void test_patch_system() + void test_patch_system(CCTK_ARGUMENTS) { +DECLARE_CCTK_ARGUMENTS DECLARE_CCTK_PARAMETERS // |