#include "cs_cdo_blas.h"
#include "cs_math.h"
#include "cs_param_sles.h"
#include "cs_param_types.h"
#include "cs_sles.h"
Go to the source code of this file.
Data Structures | |
struct | cs_iter_algo_default_t |
struct | cs_iter_algo_param_aac_t |
Structure storing all the parameters to drive the algorithm called Anderson acceleration. More... | |
struct | cs_iter_algo_aac_t |
Context structure for the algorithm called Anderson acceleration. More... | |
struct | cs_iter_algo_t |
Structure to handle the convergence of an iterative algorithm. More... | |
Typedefs | |
typedef cs_flag_t | cs_iter_algo_type_t |
Enumerations | |
enum | cs_iter_algo_type_bit_t { CS_ITER_ALGO_DEFAULT = 1 << 0 , CS_ITER_ALGO_ANDERSON = 1 << 1 , CS_ITER_ALGO_TWO_LEVEL = 1 << 2 } |
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. More... | |
cs_iter_algo_t * | cs_iter_algo_create_with_settings (cs_iter_algo_type_t type, int verbosity, cs_param_sles_cvg_t cvg_param) |
Create a new cs_iter_algo_t structure with the given settings. More... | |
void | cs_iter_algo_free (cs_iter_algo_t **p_algo) |
Free a cs_iter_algo_t structure. More... | |
void | cs_iter_algo_reset (cs_iter_algo_t *algo) |
Reset a cs_iter_algo_t structure. More... | |
void | cs_iter_algo_release_anderson_arrays (cs_iter_algo_aac_t *c) |
Reset a cs_iter_algo_t structure. More... | |
void | cs_iter_algo_set_verbosity (cs_iter_algo_t *algo, int verbosity) |
Define the verbosity of the given iterative algorithm. More... | |
void | cs_iter_algo_set_cvg_param (cs_iter_algo_t *algo, cs_param_sles_cvg_t cvg_param) |
Define the criteria related the convergence of the given iterative algorithm. More... | |
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. More... | |
void | cs_iter_algo_set_initial_residual (cs_iter_algo_t *algo, double value) |
Set the initial residual used to detect a divergence. More... | |
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. More... | |
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. More... | |
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. More... | |
int | cs_iter_algo_get_n_iter (const cs_iter_algo_t *algo) |
Retrieve the current number of iterations done. More... | |
int | cs_iter_algo_get_n_inner_iter (const cs_iter_algo_t *algo) |
Retrieve the cumulated number of inner iterations done. More... | |
double | cs_iter_algo_get_residual (const cs_iter_algo_t *algo) |
Retrieve the last computed residual. More... | |
cs_sles_convergence_state_t | cs_iter_algo_get_cvg_status (const cs_iter_algo_t *algo) |
Retrieve the last convergence state. More... | |
double | cs_iter_algo_get_normalization (const cs_iter_algo_t *algo) |
Get the normalization to apply when computing the tolerance threshold. More... | |
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. More... | |
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. More... | |
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. More... | |
void | cs_iter_algo_update_residual (cs_iter_algo_t *algo, double res) |
Update the value of the residual and its associated members. More... | |
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. More... | |
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. More... | |
void | cs_iter_algo_log_cvg (cs_iter_algo_t *algo, const char *label) |
Log the convergence of the iterative algorithm. More... | |
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. More... | |
typedef cs_flag_t cs_iter_algo_type_t |
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 algo. structure |
[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_sles_cvg_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] | 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 | ) |
Reset a cs_iter_algo_t structure.
[in,out] | algo | pointer to a cs_iter_algo_t |
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_sles_cvg_t | cvg_param | ||
) |
Define the criteria related the convergence of the given iterative algorithm.
[in,out] | algo | pointer to the structure to update |
[in] | 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] | value | normalization to apply |
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 |