8.3
general documentation
cs_iter_algo.h File Reference
#include "cs_cdo_blas.h"
#include "cs_math.h"
#include "cs_param_sles.h"
#include "cs_param_types.h"
#include "cs_sdm.h"
#include "cs_sles.h"
+ Include dependency graph for cs_iter_algo.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_tcs_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_tcs_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. 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)
 Free the members (arrays and matrix) associated to the context structure of an Anderson acceleration. 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_convergence_t cvg_param)
 Define the criteria related to 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 Documentation

◆ cs_iter_algo_type_t

Enumeration Type Documentation

◆ cs_iter_algo_type_bit_t

Enumerator
CS_ITER_ALGO_DEFAULT 
CS_ITER_ALGO_ANDERSON 
CS_ITER_ALGO_TWO_LEVEL 

Function Documentation

◆ cs_iter_algo_check_warning()

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.

Parameters
[in]func_namename of the calling function
[in]eq_namename of the equation being solved
[in]algo_namename of the iterative algo. used
[in]algopointer to the iterative algo. structure
[in]func_namename of the calling function
[in]eq_namename of the equation being solved
[in]algo_namename of the iterative algo. used
[in]algopointer to the iterative algorithm structure

◆ cs_iter_algo_create()

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.

Parameters
[in]typetype of iterative algorithm
Returns
a pointer to the new allocated structure

◆ cs_iter_algo_create_with_settings()

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.

Parameters
[in]typetype of iterative algorithm
[in]verbositylevel of information to print
[in]cvg_paramset of parameters driving the convergence of the iterative algorithm
Returns
a pointer to the new allocated structure

◆ cs_iter_algo_free()

void cs_iter_algo_free ( cs_iter_algo_t **  p_algo)

Free a cs_iter_algo_t structure.

Parameters
[in,out]p_algodouble pointer on the structure to free

◆ cs_iter_algo_get_anderson_param()

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.

Parameters
[in,out]algopointer to a cs_iter_algo_t structure
Returns
a cs_iter_algo_param_aac_t structure

◆ cs_iter_algo_get_cvg_status()

cs_sles_convergence_state_t cs_iter_algo_get_cvg_status ( const cs_iter_algo_t algo)

Retrieve the last convergence state.

Parameters
[in,out]algopointer to the structure to examine
Returns
the convergence status

◆ cs_iter_algo_get_n_inner_iter()

int cs_iter_algo_get_n_inner_iter ( const cs_iter_algo_t algo)

Retrieve the cumulated number of inner iterations done.

Parameters
[in,out]algopointer to the structure to examine
Returns
the number of iterations done

◆ cs_iter_algo_get_n_iter()

int cs_iter_algo_get_n_iter ( const cs_iter_algo_t algo)

Retrieve the current number of iterations done.

Parameters
[in,out]algopointer to the structure to examine
Returns
the number of iterations done

◆ cs_iter_algo_get_normalization()

double cs_iter_algo_get_normalization ( const cs_iter_algo_t algo)

Get the normalization to apply when computing the tolerance threshold.

Parameters
[in]algopointer to a cs_iter_algo_t structure

◆ cs_iter_algo_get_residual()

double cs_iter_algo_get_residual ( const cs_iter_algo_t algo)

Retrieve the last computed residual.

Parameters
[in,out]algopointer to the structure to examine
Returns
the number of iterations done

◆ cs_iter_algo_log_cvg()

void cs_iter_algo_log_cvg ( cs_iter_algo_t algo,
const char *  label 
)

Log the convergence of the iterative algorithm.

Parameters
[in]algopointer to the iterative algorithm structure
[in]labellabel to specify the log

◆ cs_iter_algo_release_anderson_arrays()

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.

Parameters
[in,out]cpointer to an Anderson context structure

◆ cs_iter_algo_reset()

void cs_iter_algo_reset ( cs_iter_algo_t algo)

Reset a cs_iter_algo_t structure.

Parameters
[in,out]algopointer to a cs_iter_algo_t

◆ cs_iter_algo_set_anderson_param()

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.

Parameters
[in,out]algopointer to the structure to update
[in]aac_paramset of parameters for the Anderson acceleration
[in]n_eltsnumber of elements by direction

◆ cs_iter_algo_set_cvg_param()

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.

Parameters
[in,out]algopointer to the structure to update
[in]cvg_paramset of parameters driving the convergence of the iterative algorithm

◆ cs_iter_algo_set_cvg_status()

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.

Parameters
[in,out]algopointer to the structure to update
[in]cvg_statusstatus to set

◆ cs_iter_algo_set_initial_residual()

void cs_iter_algo_set_initial_residual ( cs_iter_algo_t algo,
double  value 
)

Set the initial residual used to detect a divergence.

Parameters
[in,out]algopointer to the structure to update
[in]valuevalue of the initial residual

◆ cs_iter_algo_set_normalization()

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.

Parameters
[in,out]algopointer to the structure to update
[in]valuenormalization to apply

◆ cs_iter_algo_set_tolerance()

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.

Parameters
[in,out]algopointer to the structure to update
[in]toltolerance to apply

◆ cs_iter_algo_set_verbosity()

void cs_iter_algo_set_verbosity ( cs_iter_algo_t algo,
int  verbosity 
)

Define the verbosity of the given iterative algorithm.

Parameters
[in,out]algopointer to the structure to update
[in]verbositylevel of information to print

◆ cs_iter_algo_update_anderson()

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.

Parameters
[in,out]algopointer to a cs_iter_algo_t structure
[in,out]cur_iteratecurrent iterate
[in]pre_iterateprevious iterate
[in]dotprodfunction to compute a dot product
[in]sqnormfunction to compute a square norm

◆ cs_iter_algo_update_cvg_tol_auto()

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.

Parameters
[in,out]algopointer to a cs_iter_algo_t structure
Returns
the convergence state

◆ cs_iter_algo_update_cvg_tol_given()

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.

Parameters
[in,out]algopointer to a cs_iter_algo_t structure
[in]toltolerance threshold to apply
Returns
the convergence state

◆ cs_iter_algo_update_inner_iters()

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.

Parameters
[in,out]algopointer to the structure to update
[in]n_last_inner_iterlast number of inner loop iterations

◆ cs_iter_algo_update_residual()

void cs_iter_algo_update_residual ( cs_iter_algo_t algo,
double  res 
)

Update the value of the residual and its associated members.

Parameters
[in,out]algopointer to a cs_iter_algo_t structure
[in]resnew value of the residual