Newton’s Method¶
- Contents
rhea_newton.h [source]¶
Typedefs
-
typedef void (*rhea_newton_data_initialize_fn_t)(ymir_vec_t *solution, void *data)¶
RHEA_NEWTON
Nonlinear solver using Newton’s method. Initializes user data of the nonlinear problem to be able to run the Newton solver.
- Param solution:
[in] Solution vector (may be NULL)
- Param data:
[in] User data
-
typedef void (*rhea_newton_data_finalize_fn_t)(ymir_vec_t *solution, void *data)¶
Clears user data of the nonlinear problem after the Newton solve.
- Param data:
[in] User data
-
typedef double (*rhea_newton_evaluate_objective_fn_t)(ymir_vec_t *solution, void *data, double *obj_comp)¶
Evaluates the objective functional.
- Param solution:
[in] Current solution vector (may be NULL)
- Param data:
[in] User data
- Return:
Value of objective functional
-
typedef void (*rhea_newton_compute_negative_gradient_fn_t)(ymir_vec_t *neg_gradient, ymir_vec_t *solution, void *data)¶
Computes the negative gradient of the objective functional.
- Param neg_gradient:
[out] Negative gradient vector
- Param solution:
[in] Current solution vector (may be NULL)
- Param data:
[in] User data
-
typedef double (*rhea_newton_compute_norm_of_gradient_fn_t)(ymir_vec_t *neg_gradient, void *data, double *grad_norm_comp)¶
Computes the norm of the gradient.
- Param neg_gradient:
[in] Negative gradient vector
- Param data:
[in] User data
- Param norm_comp:
[out] Components of the gradient norm
- Return:
Norm of the gradient vector
-
typedef void (*rhea_newton_apply_hessian_fn_t)(ymir_vec_t *out, ymir_vec_t *in, void *data)¶
Applies the Hessian operator to a vector.
- Param out:
[out] Result of Hessian application
- Param in:
[in] Input vector
- Param data:
[in] User data
-
typedef int (*rhea_newton_solve_hessian_system_fn_t)(ymir_vec_t *step, ymir_vec_t *neg_gradient, const int lin_iter_max, const double lin_res_norm_rtol, const int nonzero_initial_guess, void *data, int *lin_iter_count)¶
Applies inexact inverse of the Hessian operator.
- Param step:
[out] Newton step
- Param neg_gradient:
[in] Negative gradient vector (serves as RHS)
- Param lin_iter_max:
[in] Max #iterations for iterative solver
- Param lin_res_norm_rtol:
[in] Relative tolerance for iterative solver
- Param nonzero_initial_guess:
[in] Flag if initial guess is nonzero
- Param data:
[in] User data
- Param lin_iter_count:
[out] Number of iterations taken
- Return:
Stopping reason
-
typedef double (*rhea_newton_modify_step_fn_t)(ymir_vec_t *step, ymir_vec_t *solution, const int iter, void *data)¶
Modfies the Newton step after it has been.computed.
- Param [in/out]:
step Newton step (previously computed)
- Param solution:
[in] Current solution vector
- Param iter:
[in] Iteration number of Newton’s method
- Param data:
[in] User data
- Return:
Step length modification factor
-
typedef void (*rhea_newton_update_operator_fn_t)(ymir_vec_t *solution, void *data)¶
Updates the nonlinear operator at the current solution vector.
- Param solution:
[in] Current solution vector (may be NULL)
- Param data:
[in] User data
-
typedef void (*rhea_newton_update_hessian_fn_t)(ymir_vec_t *solution, ymir_vec_t *step_vec, const double step_length, void *data)¶
Updates the Hessian operator at the current solution vector.
- Param solution:
[in] Current solution vector (may be NULL)
- Param step_vec:
[in] Recent step vector, which (together with step length) resulted in current solution (may be NULL)
- Param step_length:
[in] Step length corresponding to step vector
- Param data:
[in] User data
-
typedef void (*rhea_newton_modify_hessian_system_fn_t)(ymir_vec_t *neg_gradient, ymir_vec_t *solution, void *data)¶
Modifies the Hessian system before launching the solver for this system.
- Param [in/out]:
neg_gradient Negative gradient vector (serves as RHS)
- Param solution:
[in] Current solution vector (may be NULL)
- Param data:
[in] User data
-
typedef int (*rhea_newton_setup_poststep_fn_t)(ymir_vec_t **solution, const int iter, void *data)¶
Performs additional setup for next Newton step, e.g., AMR.
- Param solution:
[in] Pointer to solution vector
- Param iter:
[in] Iteration number of Newton’s method
- Param data:
[in] User data
- Return:
Flag whether to recompute Newton status
-
typedef void (*rhea_newton_output_prestep_fn_t)(ymir_vec_t *solution, ymir_vec_t *neg_gradient, const int iter, void *data)¶
Writes or prints output at the beginning of a Newton step.
- Param solution:
[in] Solution vector
- Param iter:
[in] Iteration number of Newton’s method
- Param data:
[in] User data
-
typedef double (*rhea_newton_check_gradient_innerprod_fn_t)(ymir_vec_t *gradient, ymir_vec_t *perturbation, void *data)¶
Computes the inner product of the gradient and a (random) perturbation.
- Param gradient:
[in] Vector on left-hand side of inner product
- Param perturbation:
[in] Vector on right-hand side of inner product
- Param data:
[in] User data
- Return:
Value of inner product
-
typedef struct rhea_newton_options rhea_newton_options_t¶
-
typedef struct rhea_newton_problem rhea_newton_problem_t¶
Enums
-
enum rhea_newton_perfmon_idx_t¶
Values:
-
enumerator RHEA_NEWTON_PERFMON_DATA_INITIALIZE¶
-
enumerator RHEA_NEWTON_PERFMON_DATA_FINALIZE¶
-
enumerator RHEA_NEWTON_PERFMON_OBJ¶
-
enumerator RHEA_NEWTON_PERFMON_GRAD¶
-
enumerator RHEA_NEWTON_PERFMON_GRAD_NORM¶
-
enumerator RHEA_NEWTON_PERFMON_UPDATE_HESSIAN¶
-
enumerator RHEA_NEWTON_PERFMON_MODIFY_HESSIAN¶
-
enumerator RHEA_NEWTON_PERFMON_COMPUTE_STEP¶
-
enumerator RHEA_NEWTON_PERFMON_HESSIAN_SOLVE¶
-
enumerator RHEA_NEWTON_PERFMON_HESSIAN_APPLY¶
-
enumerator RHEA_NEWTON_PERFMON_SEARCH_STEP_LENGTH¶
-
enumerator RHEA_NEWTON_PERFMON_UPDATE_OPERATOR¶
-
enumerator RHEA_NEWTON_PERFMON_PRESTEP¶
-
enumerator RHEA_NEWTON_PERFMON_POSTSTEP¶
-
enumerator RHEA_NEWTON_PERFMON_N¶
-
enumerator RHEA_NEWTON_PERFMON_DATA_INITIALIZE¶
Functions
-
void rhea_newton_add_options(rhea_newton_options_t *newton_options, ymir_options_t *opt_sup)¶
Defines options and adds them as sub-options.
-
void rhea_newton_get_global_options(rhea_newton_options_t *opt)¶
Gets global options values.
-
void rhea_newton_options_set_defaults(rhea_newton_options_t *opt)¶
Sets options to default values.
-
rhea_newton_problem_t *rhea_newton_problem_new(rhea_newton_compute_negative_gradient_fn_t compute_neg_gradient, rhea_newton_compute_norm_of_gradient_fn_t compute_gradient_norm, const int grad_norm_multi_components, rhea_newton_solve_hessian_system_fn_t solve_hessian_sys)¶
Creates a new nonlinear problem.
-
void rhea_newton_problem_destroy(rhea_newton_problem_t *nl_problem)¶
Destroys a nonlinear problem.
-
void rhea_newton_problem_set_vectors(ymir_vec_t *neg_gradient_vec, ymir_vec_t *step_vec, rhea_newton_problem_t *nl_problem)¶
Sets vectors required by the Newton solver.
-
void rhea_newton_problem_set_data_fn(void *data, rhea_newton_data_initialize_fn_t data_initialize, rhea_newton_data_finalize_fn_t data_finalize, rhea_newton_problem_t *nl_problem)¶
Sets callback function for initializing the Newton solver.
-
void rhea_newton_problem_set_evaluate_objective_fn(rhea_newton_evaluate_objective_fn_t evaluate_objective, const int obj_multi_components, rhea_error_stats_fn_t error_stats_fn, rhea_newton_problem_t *nl_problem)¶
Sets callback function for evaluating the objective functional.
-
void rhea_newton_problem_set_apply_hessian_fn(rhea_newton_apply_hessian_fn_t apply_hessian, rhea_newton_problem_t *nl_problem)¶
Sets callback function for applying the Hessian.
-
void rhea_newton_problem_set_modify_step_fn(rhea_newton_modify_step_fn_t modify_step_vec, rhea_newton_problem_t *nl_problem)¶
Sets callback function for modfiying the Newton step after it has been.computed.
-
void rhea_newton_problem_set_update_fn(rhea_newton_update_operator_fn_t update_operator, rhea_newton_update_hessian_fn_t update_hessian, rhea_newton_modify_hessian_system_fn_t modify_hessian_system, rhea_newton_problem_t *nl_problem)¶
Sets callback functions for updating the nonlinear and Hessian operators.
-
void rhea_newton_problem_set_setup_poststep_fn(rhea_newton_setup_poststep_fn_t setup_poststep, rhea_newton_problem_t *nl_problem)¶
Sets callback functions for performing additional setup for next Newton step.
-
void rhea_newton_problem_set_output_fn(rhea_newton_output_prestep_fn_t output_prestep, rhea_newton_problem_t *nl_problem)¶
Sets callback function for output.
-
void rhea_newton_problem_set_checks(const int check_gradient, const int check_hessian, rhea_newton_problem_t *nl_problem)¶
Activates/deactivates gradient and Hessian checks.
-
int rhea_newton_problem_get_check_gradient(rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_set_check_gradient(const int check_gradient, rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_problem_get_check_hessian(rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_set_check_hessian(const int check_hessian, rhea_newton_problem_t *nl_problem)¶
-
ymir_vec_t **rhea_newton_problem_check_gradient_get_perturbations(int *n_vecs, rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_check_gradient_set_perturbations(ymir_vec_t **perturb_vec, const int n_vecs, rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_check_gradient_get_innerprod(rhea_newton_check_gradient_innerprod_fn_t *fn, void **data, rhea_newton_problem_t *nl_problem)¶
Gets/sets inner product for gradient check.
-
void rhea_newton_problem_check_gradient_set_innerprod(rhea_newton_check_gradient_innerprod_fn_t fn, void *data, rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_set_perfmon(void *perfmon, rhea_newton_problem_t *nl_problem)¶
Get/set performance monitor.
-
sc_MPI_Comm rhea_newton_problem_get_mpicomm(rhea_newton_problem_t *nl_problem)¶
Get/set MPI communicator.
-
void rhea_newton_problem_set_mpicomm(sc_MPI_Comm mpicomm, rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_solve(ymir_vec_t **solution, rhea_newton_problem_t *nl_problem, rhea_newton_options_t *opt)¶
Solves a nonlinear problem with inexact Newton—Krylov.
-
int rhea_newton_solve_has_converged(const int stop_reason)¶
-
int rhea_newton_solve_get_num_iterations(rhea_newton_problem_t *nl_problem)¶
-
double rhea_newton_solve_get_residual_reduction(rhea_newton_problem_t *nl_problem)¶
-
ymir_vec_t *rhea_newton_problem_get_neg_gradient_vec(rhea_newton_problem_t *nl_problem)¶
Accesses data and callback functions of a nonlinear problem.
-
ymir_vec_t *rhea_newton_problem_get_step_vec(rhea_newton_problem_t *nl_problem)¶
-
void *rhea_newton_problem_get_data(rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_problem_evaluate_objective_exists(rhea_newton_problem_t *nl_problem)¶
-
double rhea_newton_problem_evaluate_objective(ymir_vec_t *solution, rhea_newton_problem_t *nl_problem, double *obj_comp)¶
-
int rhea_newton_problem_evaluate_objective_err(double *error_mean, double *error_stddev, rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_problem_compute_gradient_norm_exists(rhea_newton_problem_t *nl_problem)¶
-
double rhea_newton_problem_compute_gradient_norm(ymir_vec_t *neg_gradient, rhea_newton_problem_t *nl_problem, double *grad_norm_comp)¶
-
int rhea_newton_problem_compute_neg_gradient_exists(rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_compute_neg_gradient(ymir_vec_t *neg_gradient, ymir_vec_t *solution, rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_problem_apply_hessian_exists(rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_apply_hessian(ymir_vec_t *out, ymir_vec_t *in, rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_problem_update_operator_exists(rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_update_operator(ymir_vec_t *solution, rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_problem_update_hessian_exists(rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_update_hessian(ymir_vec_t *solution, ymir_vec_t *step_vec, const double step_length, rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_problem_modify_hessian_system_exists(rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_modify_hessian_system(ymir_vec_t *neg_gradient, ymir_vec_t *solution, rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_problem_setup_poststep_exists(rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_problem_setup_poststep(ymir_vec_t **solution, const int iter, rhea_newton_problem_t *nl_problem)¶
-
int rhea_newton_problem_output_prestep_exists(rhea_newton_problem_t *nl_problem)¶
-
void rhea_newton_problem_output_prestep(ymir_vec_t *solution, ymir_vec_t *neg_gradient, const int iter, rhea_newton_problem_t *nl_problem)¶
-
double rhea_newton_problem_get_reduction_curr(rhea_newton_problem_t *nl_problem)¶
Accesses to status of a nonlinear problem.
Variables
-
const char *rhea_newton_perfmon_name[RHEA_NEWTON_PERFMON_N]¶
-
struct rhea_newton_options¶
Public Members
-
int nonzero_initial_guess¶
-
int abort_failed_step_search¶
-
int iter_start¶
-
int iter_min¶
-
int iter_max¶
-
double rtol¶
-
int lin_iter_max¶
-
int lin_rtol_init_n_iter¶
-
double lin_rtol_init¶
-
double lin_rtol_adaptive_exponent¶
-
double lin_rtol_adaptive_max¶
-
int lin_rtol_adaptive_min_active¶
-
double lin_rtol_adaptive_min_threshold¶
-
int lin_rtol_adaptive_progressive_n_iter¶
-
int lin_monitor_reduction¶
-
int init_step_search_iter_max¶
-
int step_search_iter_max¶
-
double step_length_min¶
-
double step_length_max¶
-
double step_reduction¶
-
double step_descend_condition_relaxation¶
-
int resume¶
-
double resume_obj_init¶
-
double resume_obj_prev¶
-
double resume_obj_reduction_prev¶
-
double resume_grad_norm_init¶
-
double resume_grad_norm_prev¶
-
double resume_grad_norm_reduction_prev¶
-
int status_verbosity¶
-
int print_summary¶
-
char *print_summary_name¶
-
int monitor_performance¶
-
int nonzero_initial_guess¶
rhea_newton_check.h [source]¶
Functions
-
void rhea_newton_check_gradient(ymir_vec_t *solution, ymir_vec_t *neg_gradient, int n_trials, ymir_vec_t **perturb_vec, int n_perturb_vecs, const int iter, rhea_newton_problem_t *nl_problem)¶
Checks gradient of an objective functional by comparing to the finite difference gradient of the functional.
-
void rhea_newton_check_hessian(ymir_vec_t *solution, ymir_vec_t *neg_gradient, int n_trials, const int iter, rhea_newton_problem_t *nl_problem)¶
Checks Hessian of an objective functional by comparing to the finite difference derivative of the functianal’s gradient.