diff options
Diffstat (limited to 'src/gr/expansion_Jacobian.cc')
-rw-r--r-- | src/gr/expansion_Jacobian.cc | 104 |
1 files changed, 54 insertions, 50 deletions
diff --git a/src/gr/expansion_Jacobian.cc b/src/gr/expansion_Jacobian.cc index ef2f7e8..7d102f3 100644 --- a/src/gr/expansion_Jacobian.cc +++ b/src/gr/expansion_Jacobian.cc @@ -48,7 +48,8 @@ using jtutil::error_exit; // namespace { -bool expansion_Jacobian_NP +enum expansion_status + expansion_Jacobian_NP (patch_system& ps, Jacobian& Jac, const struct cactus_grid_info& cgi, const struct geometry_info& gi, @@ -68,7 +69,8 @@ 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 +enum expansion_status + expansion_Jacobian_dr_FD (patch_system* ps_ptr, Jacobian* Jac_ptr, const struct cactus_grid_info& cgi, const struct geometry_info& gi, @@ -99,32 +101,32 @@ bool expansion_Jacobian_dr_FD // Jac_ptr --> The Jacobian, or == NULL to do (only) a dummy computation. // // Results: -// This function returns -// * true for a successful computation -// * true for a dummy computation (ps_ptr == NULL) -// * false if the computation failed for any of the following reasons -// documented for expansion() (in "expansion.cc"). -// -bool expansion_Jacobian(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 /* = false */) +// This function returns a status code indicating whether the computation +// succeeded or failed, and if the latter, what caused the failure. +// +enum expansion_status + expansion_Jacobian(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 /* = false */) { const bool active_flag = (ps_ptr != NULL) && (Jac_ptr != NULL); +enum expansion_status status; switch (Jacobian_info.Jacobian_compute_method) { case Jacobian__numerical_perturbation: if (active_flag) 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 *** + status = expansion_Jacobian_NP(*ps_ptr, *Jac_ptr, + cgi, gi, Jacobian_info, + error_info, initial_flag, + print_msg_flag); + if (status != expansion_success) + then return status; // *** ERROR RETURN *** break; } else error_exit(ERROR_EXIT, @@ -137,8 +139,7 @@ case Jacobian__symbolic_diff: 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\"\n");/*NOTREACHED*/ +" isn't implemented (yet)!\n"); /*NOTREACHED*/ case Jacobian__symbolic_diff_with_FD_dr: if (active_flag) @@ -147,11 +148,14 @@ case Jacobian__symbolic_diff_with_FD_dr: print_msg_flag); // this function looks at ps_ptr and Jac_ptr (non-NULL vs NULL) // 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 *** + { + status = expansion_Jacobian_dr_FD(ps_ptr, Jac_ptr, + cgi, gi, Jacobian_info, + error_info, initial_flag, + print_msg_flag); + if (status != expansion_success) + then return status; // *** ERROR RETURN *** + } break; default: @@ -163,7 +167,7 @@ default: int(Jacobian_info.Jacobian_compute_method)); /*NOTREACHED*/ } -return true; // *** NORMAL RETURN *** +return expansion_success; // *** NORMAL RETURN *** } //****************************************************************************** @@ -200,12 +204,12 @@ return true; // *** NORMAL RETURN *** // As implied by the above algorithm, it's traversed by columns. // // Results: -// This function returns true for a successful computation, or false -// for failure. See expansion() (in "expansion.cc") -// for details of the various ways the computation may fail. +// This function returns a status code indicating whether the computation +// succeeded or failed, and if the latter, what caused the failure. // namespace { -bool expansion_Jacobian_NP +enum expansion_status + expansion_Jacobian_NP (patch_system& ps, Jacobian& Jac, const struct cactus_grid_info& cgi, const struct geometry_info& gi, @@ -238,10 +242,12 @@ 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, gi, - error_info, initial_flag)) - then return false; // *** ERROR RETURN *** + const + enum expansion_status status = expansion(&ps, + cgi, gi, + error_info, initial_flag); + if (status != expansion_success) + then return status; // *** ERROR RETURN *** for (int xpn = 0 ; xpn < ps.N_patches() ; ++xpn) { @@ -271,7 +277,7 @@ ps.gridfn_copy(gfns::gfn__Theta, gfns::gfn__save_Theta); } ps.gridfn_copy(gfns::gfn__save_Theta, gfns::gfn__Theta); -return true; // *** NORMAL RETURN *** +return expansion_success; // *** NORMAL RETURN *** } } @@ -520,16 +526,12 @@ patch& yp = ye.my_patch(); // Jac += d/dr terms // // Results: -// This function returns -// * true for a successful computation -// * true for a dummy computation (ps_ptr == NULL) -// * false if the computation failed for any of the following reasons: -// - the geometry interpolation would need data outside the Cactus grid, -// or from an excised region -// FIXME: excision isn't implemented yet :( +// This function returns a status code indicating whether the computation +// succeeded or failed, and if the latter, what caused the failure. // namespace { -bool expansion_Jacobian_dr_FD +enum expansion_status + expansion_Jacobian_dr_FD (patch_system* ps_ptr, Jacobian* Jac_ptr, const struct cactus_grid_info& cgi, const struct geometry_info& gi, @@ -551,10 +553,12 @@ 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, - error_info, initial_flag)) - then return false; // *** ERROR RETURN *** +const + enum expansion_status status = expansion(ps_ptr, + cgi, gi, + error_info, initial_flag); +if (status != expansion_success) + then return status; // *** ERROR RETURN *** if (active_flag) then { @@ -583,6 +587,6 @@ if (active_flag) ps_ptr->gridfn_copy(gfns::gfn__save_Theta, gfns::gfn__Theta); } -return true; // *** NORMAL RETURN *** +return expansion_success; // *** NORMAL RETURN *** } } |