diff options
author | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-09-11 12:08:49 +0000 |
---|---|---|
committer | jthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5> | 2002-09-11 12:08:49 +0000 |
commit | 9675e06f2660f68622da3e5c13dbcf549a6f2b4c (patch) | |
tree | 8c2e641b682cf277f88ed8dc2dfa7eafce3487fa /src | |
parent | 5b9a8d35dace6e1c5f2d28eb33fff801fbcb311c (diff) |
- change semantics of Boolean fns from false=ok to true=ok
- adjust verbosity controls for CCTK_VInfo printing
git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@714 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src')
-rw-r--r-- | src/driver/Newton.cc | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/src/driver/Newton.cc b/src/driver/Newton.cc index 63f6243..e7ce466 100644 --- a/src/driver/Newton.cc +++ b/src/driver/Newton.cc @@ -35,7 +35,7 @@ using jtutil::error_exit; #include "../gr/gfns.hh" #include "../gr/gr.hh" -#include "AHFinderDirect.hh" +#include "driver.hh" //****************************************************************************** @@ -57,54 +57,56 @@ bool Newton_solve(patch_system& ps, const struct Jacobian_info& Jacobian_info, const struct solver_info& solver_info, struct IO_info& IO_info, - int hn, enum verbose_level verbose_level) + int hn, const struct verbose_info& verbose_info) { -const bool print_more_msg_flag - = (verbose_level >= verbose_level__algorithm_details); - for (int iteration = 1 ; iteration <= solver_info.max_Newton_iterations ; ++iteration) { - if (print_more_msg_flag) + if (verbose_info.print_algorithm_details) then CCTK_VInfo(CCTK_THORNSTRING, "Newton iteration %d", iteration); if (solver_info.output_h_and_H_at_each_Newton_iteration) then output_gridfn(ps, gfns::gfn__h, IO_info, IO_info.h_base_file_name, - hn, print_more_msg_flag, iteration); + hn, verbose_info.print_algorithm_details, + iteration); jtutil::norm<fp> H_norms; - if (horizon_function(ps, - cgi, gi, - true, // yes, we want the Jacobian coeffs - print_more_msg_flag, - &H_norms)) + if (! horizon_function(ps, + cgi, gi, + true, // yes, we want the Jacobian coeffs + verbose_info.print_algorithm_details, + &H_norms)) then return false; // *** ERROR RETURN *** - if (print_more_msg_flag) + if (verbose_info.print_algorithm_highlights) then CCTK_VInfo(CCTK_THORNSTRING, - " H rms-norm=%.2e, infinity-norm=%.2e", + " iteration %d: H ||rms||=%.2e, ||infinity||=%.2e", + iteration, H_norms.rms_norm(), H_norms.infinity_norm()); if (solver_info.output_h_and_H_at_each_Newton_iteration) then output_gridfn(ps, gfns::gfn__H, IO_info, IO_info.H_base_file_name, - hn, print_more_msg_flag, iteration); + hn, verbose_info.print_algorithm_details, + iteration); if (H_norms.infinity_norm() <= solver_info.H_norm_for_convergence) then { - CCTK_VInfo(CCTK_THORNSTRING, - "==> finished (||H|| < %g)", - double(solver_info.H_norm_for_convergence)); + if (verbose_info.print_algorithm_details) + then CCTK_VInfo(CCTK_THORNSTRING, + "==> finished (||H|| < %g)", + double(solver_info.H_norm_for_convergence)); return true; // *** NORMAL RETURN *** } // compute the Newton step - horizon_Jacobian(ps, Jac, - cgi, gi, Jacobian_info, - print_more_msg_flag); - if (print_more_msg_flag) + if (! horizon_Jacobian(ps, Jac, + cgi, gi, Jacobian_info, + verbose_info.print_algorithm_details)) + then return false; // *** ERROR RETURN *** + if (verbose_info.print_algorithm_details) then CCTK_VInfo(CCTK_THORNSTRING, "solving linear system for Delta_h (%d unknowns)", Jac.NN()); @@ -116,7 +118,7 @@ const bool print_more_msg_flag "Newton_solve: Jacobian matrix is numerically singular!"); return false; // *** ERROR RETURN *** } - if (print_more_msg_flag) + if (verbose_info.print_algorithm_details) then { if (rcond > 0.0) then CCTK_VInfo(CCTK_THORNSTRING, @@ -156,7 +158,7 @@ const bool print_more_msg_flag } } } - if (print_more_msg_flag) + if (verbose_info.print_algorithm_details) then { if (scale == 1.0) then CCTK_VInfo(CCTK_THORNSTRING, @@ -172,15 +174,21 @@ const bool print_more_msg_flag if ( scale * Delta_h_norms.infinity_norm() <= solver_info.Delta_h_norm_for_convergence ) then { - CCTK_VInfo(CCTK_THORNSTRING, + if (verbose_info.print_algorithm_details) + then CCTK_VInfo(CCTK_THORNSTRING, "==> finished (||Delta_h|| < %g)", - double(solver_info.Delta_h_norm_for_convergence)); + double(solver_info + .Delta_h_norm_for_convergence)); if (solver_info.final_H_update_if_exit_x_H_small) then { - if (print_more_msg_flag) + if (verbose_info.print_algorithm_details) then CCTK_VInfo(CCTK_THORNSTRING, " doing final H(h) evaluation"); - if (horizon_function(ps, cgi, gi, false, true)) + if (! horizon_function(ps, + cgi, gi, + false, // no Jacobian coeffs + verbose_info + .print_algorithm_details)) then return false; // *** ERROR RETURN *** } return true; // *** NORMAL RETURN *** @@ -193,10 +201,13 @@ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, solver_info.max_Newton_iterations); if (solver_info.final_H_update_if_exit_x_H_small) then { - if (print_more_msg_flag) + if (verbose_info.print_algorithm_details) then CCTK_VInfo(CCTK_THORNSTRING, " doing final H(h) evaluation"); - if (horizon_function(ps, cgi, gi, false, true)) + if (! horizon_function(ps, + cgi, gi, + false, // no Jacobian coeffs + verbose_info.print_algorithm_details)) then return false; // *** ERROR RETURN *** } return false; // *** ERROR RETURN *** |