diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2003-02-16 22:21:49 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2003-02-16 22:21:49 +0000 |
commit | cc221a875a640142697df54a2bcff6638f7b1a88 (patch) | |
tree | a1477d8a3dd8b96d0dea7a2af4546556166389aa /src/gr | |
parent | 04ed769ddfacb1d6f5faedb66d3ff8d512ede7d4 (diff) |
* general tidying of multiprocessor code
* add current iteration number to what's sent to processor #0 for
printing at each iteration
* add a new verbosity level "algorithm debug" for what used to be
#ifdef DEBUG debugging code
* add new parameters & logic to set CCTK_Warn() levels for various
warnings (eg AH is outside the gid, metric isn't +ve definite, etc)
* restore the ability to output the horizon shape to a data file,
which I mistakenly deleted a few days ago :(
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@947 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/gr')
-rw-r--r-- | src/gr/expansion.cc | 109 | ||||
-rw-r--r-- | src/gr/expansion_Jacobian.cc | 79 | ||||
-rw-r--r-- | src/gr/gr.hh | 49 | ||||
-rw-r--r-- | src/gr/misc.cc | 6 |
4 files changed, 155 insertions, 88 deletions
diff --git a/src/gr/expansion.cc b/src/gr/expansion.cc index 490ff99..1946cfa 100644 --- a/src/gr/expansion.cc +++ b/src/gr/expansion.cc @@ -59,20 +59,25 @@ void setup_xyz_posns(patch_system& ps, bool print_msg_flag); bool interpolate_geometry(patch_system* ps_ptr, const struct cactus_grid_info& cgi, const struct geometry_info& gi, + const struct error_info& error_info, bool initial_flag, bool print_msg_flag); -void convert_conformal_to_physical(patch_system& ps, bool print_msg_flag); +void convert_conformal_to_physical(patch_system& ps, + bool print_msg_flag); void Schwarzschild_EF_geometry(patch_system& ps, const struct cactus_grid_info& cgi, const struct geometry_info& gi, bool print_msg_flag); -bool h_is_finite(patch_system& ps, bool print_msg_flag); +bool h_is_finite(patch_system& ps, + const struct error_info& error_info, bool initial_flag, + bool print_msg_flag); bool geometry_is_finite(patch_system& ps, - bool print_msg_flag); + const struct error_info& error_info, bool initial_flag, + bool print_msg_flag); -bool compute_Theta(patch_system& ps, - bool Jacobian_flag, +bool compute_Theta(patch_system& ps, bool Jacobian_flag, jtutil::norm<fp>* Theta_norms_ptr, + const struct error_info& error_info, bool initial_flag, bool print_msg_flag); } @@ -122,6 +127,11 @@ bool compute_Theta(patch_system& ps, // interpolator call are done, the latter with the number of // interpolation points is set to 0 and all the output array // pointers set to NULL. +// initial_flag = true if this is the first evaluation of expansion() +// for this horizon, +// false otherwise; +// this is used (only) to select which elements of error_info +// are relevant // Jacobian_flag = true to compute the Jacobian coefficients, // false to skip this. // print_msg_flag = true to print status messages, @@ -145,6 +155,7 @@ bool compute_Theta(patch_system& ps, bool expansion(patch_system* ps_ptr, const struct cactus_grid_info& cgi, const struct geometry_info& gi, + const struct error_info& error_info, bool initial_flag, bool Jacobian_flag /* = false */, bool print_msg_flag /* = false */, jtutil::norm<fp>* Theta_norms_ptr /* = NULL */) @@ -164,8 +175,9 @@ if (active_flag) // fill in values of all ghosted gridfns in ghost zones ps_ptr->synchronize(); - if (gi.check_that_h_is_finite - && !h_is_finite(*ps_ptr, print_msg_flag)) + if (gi.check_that_h_is_finite && !h_is_finite(*ps_ptr, + error_info, initial_flag, + print_msg_flag)) then return false; // *** ERROR RETURN *** // set up xyz positions of grid points @@ -181,15 +193,19 @@ case geometry__local_interp_from_Cactus_grid: // ps_ptr (non-NULL vs NULL) to choose a normal vs dummy computation if (!interpolate_geometry(ps_ptr, cgi, gi, + error_info, initial_flag, print_msg_flag)) then return false; // *** ERROR RETURN *** if (active_flag && cgi.Cactus_conformal_metric) - then convert_conformal_to_physical(*ps_ptr, print_msg_flag); + then convert_conformal_to_physical(*ps_ptr, + print_msg_flag); break; case geometry__Schwarzschild_EF: if (active_flag) - then Schwarzschild_EF_geometry(*ps_ptr, gi, print_msg_flag); + then Schwarzschild_EF_geometry(*ps_ptr, + gi, + print_msg_flag); break; default: @@ -203,7 +219,9 @@ default: if (active_flag) then { if (gi.check_that_geometry_is_finite - && !geometry_is_finite(*ps_ptr, print_msg_flag)) + && !geometry_is_finite(*ps_ptr, + error_info, initial_flag, + print_msg_flag)) then return false; // *** ERROR RETURN *** // compute remaining gridfns --> $\Theta$ @@ -211,6 +229,7 @@ if (active_flag) // by algebraic ops and angular finite differencing if (!compute_Theta(*ps_ptr, Jacobian_flag, Theta_norms_ptr, + error_info, initial_flag, print_msg_flag)) then return false; // *** ERROR RETURN *** } @@ -322,6 +341,7 @@ namespace { bool interpolate_geometry(patch_system* ps_ptr, const struct cactus_grid_info& cgi, const struct geometry_info& gi, + const struct error_info& error_info, bool initial_flag, bool print_msg_flag) { const bool active_flag = (ps_ptr != NULL); @@ -651,19 +671,26 @@ if (status == CCTK_ERROR_INTERP_POINT_OUTSIDE) const char axis = "xyz"[error_axis]; assert((error_direction == -1) || (error_direction == +1)); - const char end = (error_direction == -1) ? '-' : '+'; + const char direction = (error_direction == -1) ? '-' : '+'; if (print_msg_flag) then { - CCTK_VWarn(expansion_warning_levels::failure, - __LINE__, __FILE__, CCTK_THORNSTRING, + const int warn_level + = initial_flag + ? error_info.warn_level__point_outside__initial + : error_info.warn_level__point_outside__subsequent; + CCTK_VWarn(warn_level, __LINE__, __FILE__, CCTK_THORNSTRING, "\n" -" the trial-horizon-surface point" -" global_(x,y,z)=(%g,%g,%g)" -" is outside the grid (or too close to the boundary) in the %c%c direction!" +"interpolate_geometry():\n" +" the trial-horizon-surface point\n" +" global_(x,y,z)=(%g,%g,%g)\n" +" is outside the grid (or too close to the boundary)" + " in the %c%c direction!\n" +" (this may mean that driver::ghost_size is too small,\n" +" especially if any horizon crosses a symmetry boundary)" , global_x, global_y, global_z, - end, axis); + direction, axis); } return false; // *** ERROR RETURN *** } @@ -811,7 +838,7 @@ if (print_msg_flag) // or more NaNs or infinities. // // Results: -#ifdef Theta_AVE_FINITE +#ifdef HAVE_FINITE // This function returns true if all the h values are finite, false // otherwise (i.e. if it contains any NaNs or infinities). #else @@ -820,12 +847,14 @@ if (print_msg_flag) #endif // namespace { -bool h_is_finite(patch_system& ps, bool print_msg_flag) +bool h_is_finite(patch_system& ps, + const struct error_info& error_info, bool initial_flag, + bool print_msg_flag) { if (print_msg_flag) then CCTK_VInfo(CCTK_THORNSTRING, " checking that h is finite"); -#ifdef Theta_AVE_FINITE +#ifdef HAVE_FINITE for (int pn = 0 ; pn < ps.N_patches() ; ++pn) { patch& p = ps.ith_patch(pn); @@ -843,7 +872,7 @@ if (print_msg_flag) const fp sigma = p.sigma_of_isigma(isigma); const fp drho = jtutil::degrees_of_radians(rho); const fp dsigma = jtutil::degrees_of_radians(sigma); - CCTK_VWarn(expansion_warning_levels::nonfinite, + CCTK_VWarn(error_info.warn_level__nonfinite_geometry, __LINE__, __FILE__, CCTK_THORNSTRING, "\n" " h=%g isn't finite!\n" @@ -859,7 +888,7 @@ if (print_msg_flag) } return true; // *** all values finite *** #else -CCTK_VWarn(expansion_warning_levels::skip_nonfinite, +CCTK_VWarn(error_info.warn_level__skipping_finite_check, __LINE__, __FILE__, CCTK_THORNSTRING, " no finite() fn ==> skipping is-h-finite check"); return true; // *** no check possible *** @@ -878,7 +907,7 @@ return true; // *** no check possible *** // or more NaNs or infinities. // // Results: -#ifdef Theta_AVE_FINITE +#ifdef HAVE_FINITE // This function returns true if all the geometry variables are finite, // false otherwise (i.e. if they contain any NaNs or infinities). #else @@ -887,12 +916,14 @@ return true; // *** no check possible *** #endif // namespace { -bool geometry_is_finite(patch_system& ps, bool print_msg_flag) +bool geometry_is_finite(patch_system& ps, + const struct error_info& error_info, bool initial_flag, + bool print_msg_flag) { if (print_msg_flag) then CCTK_VInfo(CCTK_THORNSTRING, " checking that geometry is finite"); -#ifdef Theta_AVE_FINITE +#ifdef HAVE_FINITE for (int pn = 0 ; pn < ps.N_patches() ; ++pn) { patch& p = ps.ith_patch(pn); @@ -989,7 +1020,7 @@ if (print_msg_flag) const fp global_x = ps.global_x_of_local_x(local_x); const fp global_y = ps.global_y_of_local_y(local_y); const fp global_z = ps.global_z_of_local_z(local_z); - CCTK_VWarn(expansion_warning_levels::nonfinite, + CCTK_VWarn(error_info.warn_level__nonfinite_geometry, __LINE__, __FILE__, CCTK_THORNSTRING, "\n" " geometry isn't finite at %s patch\n" @@ -1041,7 +1072,7 @@ if (print_msg_flag) } return true; // *** no NaNs found *** #else -CCTK_VWarn(expansion_warning_levels::skip_nonfinite, +CCTK_VWarn(error_info.warn_level__skipping_finite_check, __LINE__, __FILE__, CCTK_THORNSTRING, " no finite() ==> skipping is-geometry-finite check"); return true; // *** no check possible *** @@ -1073,9 +1104,9 @@ return true; // *** no check possible *** // g_ij isn't positive definite). // namespace { -bool compute_Theta(patch_system& ps, - bool Jacobian_flag, +bool compute_Theta(patch_system& ps, bool Jacobian_flag, jtutil::norm<fp>* Theta_norms_ptr, + const struct error_info& error_info, bool initial_flag, bool print_msg_flag) { if (print_msg_flag) @@ -1159,16 +1190,16 @@ if (print_msg_flag) if (Theta_D <= 0) then { - CCTK_VWarn(expansion_warning_levels::failure, - __LINE__, __FILE__, CCTK_THORNSTRING, - "Theta_D <= 0 at %s patch rho=%g sigma=%g!", - p.name(), double(rho), double(sigma)); - CCTK_VWarn(expansion_warning_levels::failure, - __LINE__, __FILE__, CCTK_THORNSTRING, - "(this probably means the interpolated g_ij"); - CCTK_VWarn(expansion_warning_levels::failure, - __LINE__, __FILE__, CCTK_THORNSTRING, - " isn't positive definite)"); +const int warn_level + = initial_flag ? error_info.warn_level__gij_not_positive_definite__initial + : error_info.warn_level__gij_not_positive_definite__subsequent; +CCTK_VWarn(warn_level, __LINE__, __FILE__, CCTK_THORNSTRING, +"\n" +" compute_Theta(): Theta_D = $g^{ij} s_i s_j$ = %g <= 0\n" +" at %s patch rho=%g sigma=%g!\n" +" (i.e. the interpolated g_ij isn't positive definite)", + double(Theta_D), + p.name(), double(rho), double(sigma)); return false; // *** ERROR RETURN *** } diff --git a/src/gr/expansion_Jacobian.cc b/src/gr/expansion_Jacobian.cc index 805ed97..ef2f7e8 100644 --- a/src/gr/expansion_Jacobian.cc +++ b/src/gr/expansion_Jacobian.cc @@ -48,12 +48,13 @@ using jtutil::error_exit; // namespace { -bool expansion_Jacobian_NP(patch_system& ps, - Jacobian& Jac, - const struct cactus_grid_info& cgi, - const struct geometry_info& ii, - const struct Jacobian_info& Jacobian_info, - bool print_msg_flag); +bool expansion_Jacobian_NP + (patch_system& ps, Jacobian& Jac, + const struct cactus_grid_info& cgi, + const struct geometry_info& gi, + const struct Jacobian_info& Jacobian_info, + const struct error_info& error_info, bool initial_flag, + bool print_msg_flag); void expansion_Jacobian_partial_SD(patch_system& ps, Jacobian& Jac, @@ -67,12 +68,13 @@ void add_ghost_zone_Jacobian(const patch_system& ps, const patch& xp, const ghost_zone& xmgz, int x_II, int xm_irho, int xm_isigma); -bool expansion_Jacobian_dr_FD(patch_system* ps_ptr, - Jacobian* Jac_ptr, - const struct cactus_grid_info& cgi, - const struct geometry_info& gi, - const struct Jacobian_info& Jacobian_info, - bool print_msg_flag); +bool expansion_Jacobian_dr_FD + (patch_system* ps_ptr, Jacobian* Jac_ptr, + const struct cactus_grid_info& cgi, + const struct geometry_info& gi, + const struct Jacobian_info& Jacobian_info, + const struct error_info& error_info, bool initial_flag, + bool print_msg_flag); } //****************************************************************************** @@ -108,6 +110,7 @@ bool expansion_Jacobian(patch_system* ps_ptr, const struct cactus_grid_info& cgi, const struct geometry_info& gi, const struct Jacobian_info& Jacobian_info, + const struct error_info& error_info, bool initial_flag, bool print_msg_flag /* = false */) { const bool active_flag = (ps_ptr != NULL) && (Jac_ptr != NULL); @@ -119,24 +122,23 @@ case Jacobian__numerical_perturbation: then { if (! expansion_Jacobian_NP(*ps_ptr, *Jac_ptr, cgi, gi, Jacobian_info, + error_info, initial_flag, print_msg_flag)) then return false; // *** ERROR RETURN *** break; } - else CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, -"\n" -" expansion_Jacobian():\n" + else error_exit(ERROR_EXIT, +"***** expansion_Jacobian():\n" " dummy computation isn't supported for\n" -" Jacobian_compute_method = \"numerical perturbation\"!");/*NOTREACHED*/ +" Jacobian_compute_method = \"numerical perturbation\"!\n"); + /*NOTREACHED*/ case Jacobian__symbolic_diff: - CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, -"\n" -" expansion_Jacobian():\n" + error_exit(ERROR_EXIT, +"***** expansion_Jacobian():\n" " Jacobian_compute_method == \"symbolic differentiation\"\n" " isn't implemented (yet); reverting to\n" -" \"symbolic differentiation with finite diff d/dr\""); - // fall through +" \"symbolic differentiation with finite diff d/dr\"\n");/*NOTREACHED*/ case Jacobian__symbolic_diff_with_FD_dr: if (active_flag) @@ -147,6 +149,7 @@ case Jacobian__symbolic_diff_with_FD_dr: // to choose a normal vs dummy computation if (! expansion_Jacobian_dr_FD(ps_ptr, Jac_ptr, cgi, gi, Jacobian_info, + error_info, initial_flag, print_msg_flag)) then return false; // *** ERROR RETURN *** break; @@ -202,12 +205,13 @@ return true; // *** NORMAL RETURN *** // for details of the various ways the computation may fail. // namespace { -bool expansion_Jacobian_NP(patch_system& ps, - Jacobian& Jac, - const struct cactus_grid_info& cgi, - const struct geometry_info& ii, - const struct Jacobian_info& Jacobian_info, - bool print_msg_flag) +bool expansion_Jacobian_NP + (patch_system& ps, Jacobian& Jac, + const struct cactus_grid_info& cgi, + const struct geometry_info& gi, + const struct Jacobian_info& Jacobian_info, + const struct error_info& error_info, bool initial_flag, + bool print_msg_flag) { if (print_msg_flag) then CCTK_VInfo(CCTK_THORNSTRING, @@ -234,7 +238,9 @@ ps.gridfn_copy(gfns::gfn__Theta, gfns::gfn__save_Theta); const fp save_h_y = yp.ghosted_gridfn(gfns::gfn__h, y_irho,y_isigma); yp.ghosted_gridfn(gfns::gfn__h, y_irho,y_isigma) += epsilon; - if (! expansion(&ps, cgi, ii)) + if (! expansion(&ps, + cgi, gi, + error_info, initial_flag)) then return false; // *** ERROR RETURN *** for (int xpn = 0 ; xpn < ps.N_patches() ; ++xpn) @@ -523,12 +529,13 @@ patch& yp = ye.my_patch(); // FIXME: excision isn't implemented yet :( // namespace { -bool expansion_Jacobian_dr_FD(patch_system* ps_ptr, - Jacobian* Jac_ptr, - const struct cactus_grid_info& cgi, - const struct geometry_info& gi, - const struct Jacobian_info& Jacobian_info, - bool print_msg_flag) +bool expansion_Jacobian_dr_FD + (patch_system* ps_ptr, Jacobian* Jac_ptr, + const struct cactus_grid_info& cgi, + const struct geometry_info& gi, + const struct Jacobian_info& Jacobian_info, + const struct error_info& error_info, bool initial_flag, + bool print_msg_flag) { const bool active_flag = (ps_ptr != NULL) && (Jac_ptr != NULL); if (print_msg_flag) @@ -544,7 +551,9 @@ if (active_flag) ps_ptr->gridfn_copy(gfns::gfn__Theta, gfns::gfn__save_Theta); ps_ptr->add_to_ghosted_gridfn(epsilon, gfns::gfn__h); } -if (! expansion(ps_ptr, cgi, gi)) +if (! expansion(ps_ptr, + cgi, gi, + error_info, initial_flag)) then return false; // *** ERROR RETURN *** if (active_flag) diff --git a/src/gr/gr.hh b/src/gr/gr.hh index 3014cd7..58275f5 100644 --- a/src/gr/gr.hh +++ b/src/gr/gr.hh @@ -42,9 +42,9 @@ struct cactus_grid_info cGH *GH; // --> Cactus grid hierarchy // this describes the semantics of the Cactus gij gridfns: - // true ==> the Cactus gij are conformal values as per + // true ==> the Cactus g_ij are conformal values as per // CactusEinstein/StaticConformal and the psi gridfn - // false ==> the Cactus gij are the physical metric + // false ==> the Cactus g_ij are the physical metric bool Cactus_conformal_metric; // @@ -136,6 +136,40 @@ struct Jacobian_info fp perturbation_amplitude; }; +// +// This struct holds information on what to do if various error/warning +// conditions occur. +// +struct error_info + { + // at present, we "handle" all these errors/warnings by CCTK_VWarn(); + // these parameters give the warning levels for various conditions: + + // point outside (or too close to boundary of) Cactus grid, + // i.e. geometry interpolator returns CCTK_ERROR_INTERP_POINT_OUTSIDE + // ... warning level if error occurs on first Newton iteration, + // i.e. when evaluating expansion/Jacobian for initial guess + int warn_level__point_outside__initial; + // ... warning level if error occurs on a subsequent Newton iteration + int warn_level__point_outside__subsequent; + + // the Cactus configure process didn't find a finite() function, + // so we're skipping the "check that the geometry is finite" tests + // even though the user set check_that_geometry_is_finite = "true" + int warn_level__skipping_finite_check; + + // infinity or NaN in interpolated {g_ij, partial_k g_ij, K_ij} + int warn_level__nonfinite_geometry; + + // interpolated g_ij isn't positive definite + // (usually this means we're too close to a singularity) + // ... warning level if error occurs on first Newton iteration, + // i.e. when evaluating expansion/Jacobian for initial guess + int warn_level__gij_not_positive_definite__initial; + // ... warning level if error occurs on a subsequent Newton iteration + int warn_level__gij_not_positive_definite__subsequent; + }; + //****************************************************************************** // @@ -148,18 +182,10 @@ struct Jacobian_info // ... returns false for failure (eg horizon outside grid); // if (print_msg_flag) then also reports CCTK_VWarn() at the // appropriate warning level -namespace expansion_warning_levels - { - enum { - failure = 2, // point outside grid etc - nonfinite = 2, // nonfinite gridfn detected - skip_nonfinite = 3 // no finite() function available - // ==> skipping nonfinite check - }; - } bool expansion(patch_system* ps_ptr, const struct cactus_grid_info& cgi, const struct geometry_info& gi, + const struct error_info& error_info, bool initial_flag, bool Jacobian_flag = false, bool print_msg_flag = false, jtutil::norm<fp>* H_norms_ptr = NULL); @@ -173,6 +199,7 @@ bool expansion_Jacobian(patch_system* ps_ptr, const struct cactus_grid_info& cgi, const struct geometry_info& gi, const struct Jacobian_info& Jacobian_info, + const struct error_info& error_info, bool initial_flag, bool print_msg_flag = false); // Schwarzschild_EF.cc diff --git a/src/gr/misc.cc b/src/gr/misc.cc index 8a0ced4..846ee5d 100644 --- a/src/gr/misc.cc +++ b/src/gr/misc.cc @@ -56,7 +56,7 @@ else if (STRING_EQUAL(geometry_method_string, else if (STRING_EQUAL(geometry_method_string, "Schwarzschild/EF")) then return geometry__Schwarzschild_EF; -else CCTK_VWarn(-1, __LINE__, __FILE__, CCTK_THORNSTRING, +else CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING, "decode_geometry_method(): unknown geometry_method_string=\"%s\"!", geometry_method_string); /*NOTREACHED*/ } @@ -78,7 +78,7 @@ case geometry__local_interp_from_Cactus_grid: case geometry__Schwarzschild_EF: return false; default: - CCTK_VWarn(-1, __LINE__, __FILE__, CCTK_THORNSTRING, + CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING, "geometry_method_is_interp(): unknown geometry_method=(int)%d!", geometry_method); /*NOTREACHED*/ } @@ -103,7 +103,7 @@ else if (STRING_EQUAL(Jacobian_compute_method_string, else if (STRING_EQUAL(Jacobian_compute_method_string, "symbolic differentiation")) then return Jacobian__symbolic_diff; -else CCTK_VWarn(-1, __LINE__, __FILE__, CCTK_THORNSTRING, +else CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING, "\n" " decode_Jacobian_compute_method():\n" " unknown Jacobian_compute_method_string=\"%s\"!", |