Set of functions to manage high-level iterative algorithms such as Uzawa, Golub-Kahan Bi-orthogonalization, block preconditioner or Picard and Anderson algorithms which may incorporate inner iterative solvers. More...
#include "cs_defs.h"#include <float.h>#include <assert.h>#include <string.h>#include <bft_error.h>#include <bft_mem.h>#include <bft_printf.h>#include "cs_array.h"#include "cs_log.h"#include "cs_parall.h"#include "cs_sdm.h"#include "cs_iter_algo.h"Functions | |
| cs_iter_algo_t * | cs_iter_algo_create (cs_iter_algo_type_t type) |
| Create and initialize by default a new cs_iter_algo_t structure. | |
| cs_iter_algo_t * | cs_iter_algo_create_with_settings (cs_iter_algo_type_t type, int verbosity, cs_param_convergence_t cvg_param) |
| Create a new cs_iter_algo_t structure with the given settings. | |
| void | cs_iter_algo_free (cs_iter_algo_t **p_algo) |
| Free a cs_iter_algo_t structure. | |
| void | cs_iter_algo_reset (cs_iter_algo_t *algo) |
| Reset a cs_iter_algo_t structure. | |
| void | cs_iter_algo_release_anderson_arrays (cs_iter_algo_aac_t *c) |
| Free the members (arrays and matrix) associated to the context structure of an Anderson acceleration. | |
| void | cs_iter_algo_set_verbosity (cs_iter_algo_t *algo, int verbosity) |
| Define the verbosity of the given iterative algorithm. | |
| void | cs_iter_algo_set_cvg_param (cs_iter_algo_t *algo, cs_param_convergence_t cvg_param) |
| Define the criteria related to the convergence of the given iterative algorithm. | |
| void | cs_iter_algo_set_tolerance (cs_iter_algo_t *algo, double tol) |
| Set the final tolerance used to check the convergence of the algorithm This tolerance should take into account rtol and atol for instance. | |
| void | cs_iter_algo_set_initial_residual (cs_iter_algo_t *algo, double value) |
| Set the initial residual used to detect a divergence. | |
| void | cs_iter_algo_set_normalization (cs_iter_algo_t *algo, double value) |
| Set the normalization to apply when checking the convergence of the algorithm. | |
| void | cs_iter_algo_set_cvg_status (cs_iter_algo_t *algo, cs_sles_convergence_state_t cvg_status) |
| Set the convergence status of the given structure. | |
| void | cs_iter_algo_set_anderson_param (cs_iter_algo_t *algo, cs_iter_algo_param_aac_t aac_param, cs_lnum_t n_elts) |
| Create a new cs_iter_algo_aac_t structure for Anderson acceleration. | |
| int | cs_iter_algo_get_n_iter (const cs_iter_algo_t *algo) |
| Retrieve the current number of iterations done. | |
| int | cs_iter_algo_get_n_inner_iter (const cs_iter_algo_t *algo) |
| Retrieve the cumulated number of inner iterations done. | |
| double | cs_iter_algo_get_residual (const cs_iter_algo_t *algo) |
| Retrieve the last computed residual. | |
| cs_sles_convergence_state_t | cs_iter_algo_get_cvg_status (const cs_iter_algo_t *algo) |
| Retrieve the last convergence state. | |
| double | cs_iter_algo_get_normalization (const cs_iter_algo_t *algo) |
| Get the normalization to apply when computing the tolerance threshold. | |
| cs_iter_algo_param_aac_t | cs_iter_algo_get_anderson_param (cs_iter_algo_t *algo) |
| Retrieve the set of parameters for an Anderson algorithm. | |
| void | cs_iter_algo_update_anderson (cs_iter_algo_t *algo, cs_real_t *cur_iterate, const cs_real_t *pre_iterate, cs_cdo_blas_dotprod_t *dotprod, cs_cdo_blas_square_norm_t *sqnorm) |
| Apply one more iteration of the Anderson acceleration. | |
| void | cs_iter_algo_update_inner_iters (cs_iter_algo_t *algo, int n_last_inner_iter) |
| Update the counting of inner iterations in two-level algorithms. | |
| void | cs_iter_algo_update_residual (cs_iter_algo_t *algo, double res) |
| Update the value of the residual and its associated members. | |
| cs_sles_convergence_state_t | cs_iter_algo_update_cvg_tol_given (cs_iter_algo_t *algo, double tol) |
| Update the convergence status and the number of iterations. The tolerance threshold is given so that it has to be computed before calling this function. | |
| cs_sles_convergence_state_t | cs_iter_algo_update_cvg_tol_auto (cs_iter_algo_t *algo) |
| Update the convergence status and the number of iterations. The tolerance threshold is automatically computed by a default formula relying on the relative tolerance scaled by the normalization factor and the absolute tolerance. | |
| void | cs_iter_algo_log_cvg (cs_iter_algo_t *algo, const char *label) |
| Log the convergence of the iterative algorithm. | |
| void | cs_iter_algo_check_warning (const char *func_name, const char *eq_name, const char *algo_name, cs_iter_algo_t *algo) |
| Check if something wrong happens during the iterative process after one new iteration. | |
Set of functions to manage high-level iterative algorithms such as Uzawa, Golub-Kahan Bi-orthogonalization, block preconditioner or Picard and Anderson algorithms which may incorporate inner iterative solvers.
| void cs_iter_algo_check_warning | ( | const char * | func_name, |
| const char * | eq_name, | ||
| const char * | algo_name, | ||
| cs_iter_algo_t * | algo ) |
Check if something wrong happens during the iterative process after one new iteration.
| [in] | func_name | name of the calling function |
| [in] | eq_name | name of the equation being solved |
| [in] | algo_name | name of the iterative algo. used |
| [in] | algo | pointer to the iterative algorithm structure |
| cs_iter_algo_t * cs_iter_algo_create | ( | cs_iter_algo_type_t | type | ) |
Create and initialize by default a new cs_iter_algo_t structure.
| [in] | type | type of iterative algorithm |
| cs_iter_algo_t * cs_iter_algo_create_with_settings | ( | cs_iter_algo_type_t | type, |
| int | verbosity, | ||
| cs_param_convergence_t | cvg_param ) |
Create a new cs_iter_algo_t structure with the given settings.
| [in] | type | type of iterative algorithm |
| [in] | verbosity | level of information to print |
| [in] | cvg_param | set of parameters driving the convergence of the iterative algorithm |
| void cs_iter_algo_free | ( | cs_iter_algo_t ** | p_algo | ) |
Free a cs_iter_algo_t structure.
| [in,out] | p_algo | double pointer on the structure to free |
| cs_iter_algo_param_aac_t cs_iter_algo_get_anderson_param | ( | cs_iter_algo_t * | algo | ) |
Retrieve the set of parameters for an Anderson algorithm.
| [in,out] | algo | pointer to a cs_iter_algo_t structure |
| cs_sles_convergence_state_t cs_iter_algo_get_cvg_status | ( | const cs_iter_algo_t * | algo | ) |
Retrieve the last convergence state.
| [in,out] | algo | pointer to the structure to examine |
| int cs_iter_algo_get_n_inner_iter | ( | const cs_iter_algo_t * | algo | ) |
Retrieve the cumulated number of inner iterations done.
| [in,out] | algo | pointer to the structure to examine |
| int cs_iter_algo_get_n_iter | ( | const cs_iter_algo_t * | algo | ) |
Retrieve the current number of iterations done.
| [in,out] | algo | pointer to the structure to examine |
| double cs_iter_algo_get_normalization | ( | const cs_iter_algo_t * | algo | ) |
Get the normalization to apply when computing the tolerance threshold.
| [in] | algo | pointer to a cs_iter_algo_t structure |
| double cs_iter_algo_get_residual | ( | const cs_iter_algo_t * | algo | ) |
Retrieve the last computed residual.
| [in,out] | algo | pointer to the structure to examine |
| void cs_iter_algo_log_cvg | ( | cs_iter_algo_t * | algo, |
| const char * | label ) |
Log the convergence of the iterative algorithm.
| [in] | algo | pointer to the iterative algorithm structure |
| [in] | label | label to specify the log |
| void cs_iter_algo_release_anderson_arrays | ( | cs_iter_algo_aac_t * | c | ) |
Free the members (arrays and matrix) associated to the context structure of an Anderson acceleration.
| [in,out] | c | pointer to an Anderson context structure |
| void cs_iter_algo_reset | ( | cs_iter_algo_t * | algo | ) |
Reset a cs_iter_algo_t structure.
| [in,out] | algo | pointer to a cs_iter_algo_t |
| void cs_iter_algo_set_anderson_param | ( | cs_iter_algo_t * | algo, |
| cs_iter_algo_param_aac_t | aac_param, | ||
| cs_lnum_t | n_elts ) |
Create a new cs_iter_algo_aac_t structure for Anderson acceleration.
| [in,out] | algo | pointer to the structure to update |
| [in] | aac_param | set of parameters for the Anderson acceleration |
| [in] | n_elts | number of elements by direction |
| void cs_iter_algo_set_cvg_param | ( | cs_iter_algo_t * | algo, |
| cs_param_convergence_t | cvg_param ) |
Define the criteria related to the convergence of the given iterative algorithm.
| [in,out] | algo | pointer to the structure to update |
| [in] | cvg_param | set of parameters driving the convergence of the iterative algorithm |
| void cs_iter_algo_set_cvg_status | ( | cs_iter_algo_t * | algo, |
| cs_sles_convergence_state_t | cvg_status ) |
Set the convergence status of the given structure.
| [in,out] | algo | pointer to the structure to update |
| [in] | cvg_status | status to set |
| void cs_iter_algo_set_initial_residual | ( | cs_iter_algo_t * | algo, |
| double | value ) |
Set the initial residual used to detect a divergence.
| [in,out] | algo | pointer to the structure to update |
| [in] | value | value of the initial residual |
| void cs_iter_algo_set_normalization | ( | cs_iter_algo_t * | algo, |
| double | value ) |
Set the normalization to apply when checking the convergence of the algorithm.
| [in,out] | algo | pointer to the structure to update |
| [in] | value | normalization to apply |
| void cs_iter_algo_set_tolerance | ( | cs_iter_algo_t * | algo, |
| double | tol ) |
Set the final tolerance used to check the convergence of the algorithm This tolerance should take into account rtol and atol for instance.
| [in,out] | algo | pointer to the structure to update |
| [in] | tol | tolerance to apply |
| void cs_iter_algo_set_verbosity | ( | cs_iter_algo_t * | algo, |
| int | verbosity ) |
Define the verbosity of the given iterative algorithm.
| [in,out] | algo | pointer to the structure to update |
| [in] | verbosity | level of information to print |
| void cs_iter_algo_update_anderson | ( | cs_iter_algo_t * | algo, |
| cs_real_t * | cur_iterate, | ||
| const cs_real_t * | pre_iterate, | ||
| cs_cdo_blas_dotprod_t * | dotprod, | ||
| cs_cdo_blas_square_norm_t * | sqnorm ) |
Apply one more iteration of the Anderson acceleration.
| [in,out] | algo | pointer to a cs_iter_algo_t structure |
| [in,out] | cur_iterate | current iterate |
| [in] | pre_iterate | previous iterate |
| [in] | dotprod | function to compute a dot product |
| [in] | sqnorm | function to compute a square norm |
| cs_sles_convergence_state_t cs_iter_algo_update_cvg_tol_auto | ( | cs_iter_algo_t * | algo | ) |
Update the convergence status and the number of iterations. The tolerance threshold is automatically computed by a default formula relying on the relative tolerance scaled by the normalization factor and the absolute tolerance.
| [in,out] | algo | pointer to a cs_iter_algo_t structure |
| cs_sles_convergence_state_t cs_iter_algo_update_cvg_tol_given | ( | cs_iter_algo_t * | algo, |
| double | tol ) |
Update the convergence status and the number of iterations. The tolerance threshold is given so that it has to be computed before calling this function.
| [in,out] | algo | pointer to a cs_iter_algo_t structure |
| [in] | tol | tolerance threshold to apply |
| void cs_iter_algo_update_inner_iters | ( | cs_iter_algo_t * | algo, |
| int | n_last_inner_iter ) |
Update the counting of inner iterations in two-level algorithms.
| [in,out] | algo | pointer to the structure to update |
| [in] | n_last_inner_iter | last number of inner loop iterations |
| void cs_iter_algo_update_residual | ( | cs_iter_algo_t * | algo, |
| double | res ) |
Update the value of the residual and its associated members.
| [in,out] | algo | pointer to a cs_iter_algo_t structure |
| [in] | res | new value of the residual |