8.0
general documentation
Loading...
Searching...
No Matches
cs_param_sles.c File Reference
#include "cs_defs.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <bft_error.h>
#include <bft_mem.h>
#include <bft_printf.h>
#include "cs_fp_exception.h"
#include "cs_log.h"
#include "cs_multigrid.h"
#include "cs_sles.h"
#include "cs_sles_petsc.h"
#include "cs_sles_hypre.h"
#include "cs_param_sles.h"
Include dependency graph for cs_param_sles.c:

Functions

static bool _system_should_be_sym (cs_param_itsol_type_t solver)
 Return true if the prescribed solver implies a symmetric linear system.
static void _petsc_cmd (bool use_prefix, const char *prefix, const char *keyword, const char *keyval)
 Set the command line option for PETSc.
static void _petsc_bilu0_hook (const char *prefix)
 Predefined settings for a block ILU(0) with PETSc.
static void _petsc_bicc0_hook (const char *prefix)
 Predefined settings for a block ICC(0) with PETSc.
static void _petsc_bssor_hook (const char *prefix)
 Predefined settings for a block SSOR with PETSc.
static void _petsc_pcgamg_hook (const char *prefix, const cs_param_sles_t *slesp, bool is_symm, PC pc)
 Predefined settings for GAMG as a preconditioner even if another settings have been defined. One assumes that one really wants to use GAMG (may be HYPRE is not available)
static void _petsc_pchypre_hook (const char *prefix, const cs_param_sles_t *slesp, bool is_symm, PC pc)
 Predefined settings for BoomerAMG in HYPRE as a preconditioner.
static void _petsc_set_pc_type (cs_param_sles_t *slesp, KSP ksp)
 Set command line options for PC according to the kind of preconditionner.
static void _petsc_set_krylov_solver (cs_param_sles_t *slesp, KSP ksp)
 Set PETSc solver.
static void _petsc_setup_hook (void *context, void *ksp_struct)
 Set PETSc solver and preconditioner.
static void _petsc_common_block_hook (const cs_param_sles_t *slesp, KSP ksp)
 Common settings for block preconditioning (when a system is split according to the Cartesian components: x,y,z)
static void _petsc_amg_block_gamg_hook (void *context, void *ksp_struct)
 Function pointer: setup hook for setting PETSc solver and preconditioner. Case of multiplicative AMG block preconditioner for a CG with GAMG as AMG type.
static void _petsc_block_hook (void *context, void *ksp_struct)
 Function pointer: setup hook for setting PETSc solver and preconditioner. Case of block preconditioner.
static void _check_settings (cs_param_sles_t *slesp)
 Check if the settings are consitent. Can apply minor modifications.
static int _get_poly_degree (const cs_param_sles_t *slesp)
 Retrieve the value of the polynomial degree to consider according to the settings. Only for in-house solvers.
static void _set_saturne_sles (bool use_field_id, cs_param_sles_t *slesp)
 Set parameters for initializing SLES structures used for the resolution of the linear system. Case of saturne's own solvers.
static void _set_mumps_sles (bool use_field_id, cs_param_sles_t *slesp)
 Set parameters for initializing SLES structures used for the resolution of the linear system. Case of MUMPS's own solvers.
static void _set_petsc_hypre_sles (bool use_field_id, cs_param_sles_t *slesp)
 Set parameters for initializing SLES structures used for the resolution of the linear system. Case of PETSc and Hypre families of solvers.
static HYPRE_Solver _set_hypre_solver (cs_param_sles_t *slesp, HYPRE_Solver hs)
 Set the solver when HYPRE is used Check HYPRE documentation for available options: https://hypre.readthedocs.io/en/latest/index.html.
static void _hypre_boomeramg_hook (int verbosity, void *context, void *solver_p)
 Setup hook function for a Hypre KSP solver with preconditioner This function is called at the end of the setup stage for a KSP solver.
static void _hypre_generic_pc_hook (int verbosity, void *context, void *solver_p)
 Setup hook function for a Hypre solver with preconditioner This function is called at the end of the setup stage for a solver.
static void _set_hypre_sles (bool use_field_id, cs_param_sles_t *slesp)
 Set parameters for initializing SLES structures used for the resolution of the linear system. Case of Hypre families of solvers.
cs_param_sles_saddle_tcs_param_sles_saddle_create (void)
 Create a cs_param_sles_saddle_t structure and assign a minimalist default settings.
void cs_param_sles_saddle_init_schur (const char *basename, cs_param_sles_saddle_t *saddlep)
 Initialize a cs_param_sles_t structure for the Schur approximation nested inside a ref cs_param_sles_saddle_t structure. By default, this member is not allocated. Do nothing if the related structure is already allocated.
void cs_param_sles_saddle_copy (const cs_param_sles_saddle_t *ref, cs_param_sles_saddle_t *dest)
 Copy a cs_param_sles_saddle_t structure from ref to dest.
void cs_param_sles_saddle_free (cs_param_sles_saddle_t **p_saddlep)
 Free the structure storing the parameter settings for a saddle-point system.
cs_param_sles_tcs_param_sles_create (int field_id, const char *system_name)
 Create a cs_param_sles_t structure and assign a default settings.
void cs_param_sles_free (cs_param_sles_t **p_slesp)
 Free a cs_param_sles_t structure.
void cs_param_sles_log (cs_param_sles_t *slesp)
 Log information related to the linear settings stored in the structure.
void cs_param_sles_copy_from (cs_param_sles_t *src, cs_param_sles_t *dst)
 Copy a cs_param_sles_t structure from src to dst.
int cs_param_sles_set (bool use_field_id, cs_param_sles_t *slesp)
 Define cs_sles_t structure in accordance with the settings of a cs_param_sles_t structure (SLES = Sparse Linear Equation Solver)
void cs_param_sles_update_cvg_settings (bool use_field_id, const cs_param_sles_t *slesp)
 Update the settings associated to a cs_sles_t structure and apply those defined in the given cs_param_sles_t structure. This function is used only when a first setup has been performed.
cs_param_sles_class_t cs_param_sles_get_class_from_amg (cs_param_amg_type_t amg_type)
 Retrieve the related solver class from the amg type.
cs_param_sles_class_t cs_param_sles_check_class (cs_param_sles_class_t wanted_class)
 Check the availability of a solver library and return the requested one if this is possible or an alternative or CS_PARAM_SLES_N_CLASSES if no alternative is available.
void cs_param_sles_check_amg (cs_param_sles_t *slesp)
 Check if the setting related to the AMG is consistent with the solver class.
void cs_param_sles_petsc_cmd (bool use_prefix, const char *prefix, const char *keyword, const char *keyval)
 Set the command line option for PETSc.

Function Documentation

◆ _check_settings()

void _check_settings ( cs_param_sles_t * slesp)
static

Check if the settings are consitent. Can apply minor modifications.

Parameters
[in,out]slesppointer to a cs_param_sles_t structure

◆ _get_poly_degree()

int _get_poly_degree ( const cs_param_sles_t * slesp)
static

Retrieve the value of the polynomial degree to consider according to the settings. Only for in-house solvers.

Parameters
[in]slesppointer to a cs_param_sles_t structure
Returns
the value of the polynomial degree to consider

◆ _hypre_boomeramg_hook()

void _hypre_boomeramg_hook ( int verbosity,
void * context,
void * solver_p )
static

Setup hook function for a Hypre KSP solver with preconditioner This function is called at the end of the setup stage for a KSP solver.

Note: if the context pointer is non-NULL, it must point to valid data when the selection function is called so that value or structure should not be temporary (i.e. local);

Check HYPRE documentation for available options: https://hypre.readthedocs.io/en/latest/index.html

Parameters
[in]verbosityverbosity level
[in,out]contextpointer to optional (untyped) value or structure
[in,out]solver_ppointer to a HYPRE solver (cast ont-the-fly)

◆ _hypre_generic_pc_hook()

void _hypre_generic_pc_hook ( int verbosity,
void * context,
void * solver_p )
static

Setup hook function for a Hypre solver with preconditioner This function is called at the end of the setup stage for a solver.

Check HYPRE documentation for available options: https://hypre.readthedocs.io/en/latest/index.html

Parameters
[in]verbosityverbosity level
[in,out]contextpointer to optional (untyped) value or structure
[in,out]solver_ppointer to a HYPRE solver (cast ont-the-fly)

◆ _petsc_amg_block_gamg_hook()

void _petsc_amg_block_gamg_hook ( void * context,
void * ksp_struct )
static

Function pointer: setup hook for setting PETSc solver and preconditioner. Case of multiplicative AMG block preconditioner for a CG with GAMG as AMG type.

Parameters
[in,out]contextpointer to optional (untyped) value or structure
[in,out]ksp_structpointer to PETSc KSP context

◆ _petsc_bicc0_hook()

void _petsc_bicc0_hook ( const char * prefix)
inlinestatic

Predefined settings for a block ICC(0) with PETSc.

Parameters
[in]prefixprefix name associated to the current SLES

◆ _petsc_bilu0_hook()

void _petsc_bilu0_hook ( const char * prefix)
inlinestatic

Predefined settings for a block ILU(0) with PETSc.

Parameters
[in]prefixprefix name associated to the current SLES

◆ _petsc_block_hook()

void _petsc_block_hook ( void * context,
void * ksp_struct )
static

Function pointer: setup hook for setting PETSc solver and preconditioner. Case of block preconditioner.

Parameters
[in,out]contextpointer to optional (untyped) value or structure
[in,out]ksp_structpointer to PETSc KSP context

◆ _petsc_bssor_hook()

void _petsc_bssor_hook ( const char * prefix)
inlinestatic

Predefined settings for a block SSOR with PETSc.

Parameters
[in]prefixprefix name associated to the current SLES

◆ _petsc_cmd()

void _petsc_cmd ( bool use_prefix,
const char * prefix,
const char * keyword,
const char * keyval )
inlinestatic

Set the command line option for PETSc.

Parameters
[in]use_prefixneed a prefix
[in]prefixoptional prefix
[in]keywordcommand keyword
[in]keyvalcommand value

◆ _petsc_common_block_hook()

void _petsc_common_block_hook ( const cs_param_sles_t * slesp,
KSP ksp )
static

Common settings for block preconditioning (when a system is split according to the Cartesian components: x,y,z)

Parameters
[in]slesppointer to the SLES parameter settings
[in,out]ksppointer to PETSc KSP structure (solver)

◆ _petsc_pcgamg_hook()

void _petsc_pcgamg_hook ( const char * prefix,
const cs_param_sles_t * slesp,
bool is_symm,
PC pc )
inlinestatic

Predefined settings for GAMG as a preconditioner even if another settings have been defined. One assumes that one really wants to use GAMG (may be HYPRE is not available)

Parameters
[in]prefixprefix name associated to the current SLES
[in]slesppointer to a set of SLES parameters
[in]is_symmthe linear system to solve is symmetric
[in,out]pcpointer to a PETSc preconditioner

◆ _petsc_pchypre_hook()

void _petsc_pchypre_hook ( const char * prefix,
const cs_param_sles_t * slesp,
bool is_symm,
PC pc )
inlinestatic

Predefined settings for BoomerAMG in HYPRE as a preconditioner.

Parameters
[in]prefixprefix name associated to the current SLES
[in]slesppointer to a set of SLES parameters
[in]is_symmthe linear system to solve is symmetric
[in,out]pcpointer to a PETSc preconditioner

◆ _petsc_set_krylov_solver()

void _petsc_set_krylov_solver ( cs_param_sles_t * slesp,
KSP ksp )
static

Set PETSc solver.

Parameters
[in]slesppointer to SLES parameters
[in,out]ksppointer to PETSc KSP context

◆ _petsc_set_pc_type()

void _petsc_set_pc_type ( cs_param_sles_t * slesp,
KSP ksp )
static

Set command line options for PC according to the kind of preconditionner.

Parameters
[in,out]slespset of parameters for the linear algebra
[in,out]kspPETSc solver structure

◆ _petsc_setup_hook()

void _petsc_setup_hook ( void * context,
void * ksp_struct )
static

Set PETSc solver and preconditioner.

Parameters
[in,out]contextpointer to optional (untyped) value or structure
[in,out]ksp_structpointer to PETSc KSP context

◆ _set_hypre_sles()

void _set_hypre_sles ( bool use_field_id,
cs_param_sles_t * slesp )
static

Set parameters for initializing SLES structures used for the resolution of the linear system. Case of Hypre families of solvers.

Check HYPRE documentation for available options: https://hypre.readthedocs.io/en/latest/index.html

Parameters
[in]use_field_idif false use system name
[in,out]slesppointer to a cs_param_sles_t structure

◆ _set_hypre_solver()

HYPRE_Solver _set_hypre_solver ( cs_param_sles_t * slesp,
HYPRE_Solver hs )
static

Set the solver when HYPRE is used Check HYPRE documentation for available options: https://hypre.readthedocs.io/en/latest/index.html.

Parameters
[in]slesppointer to a set of SLES parameters
[in,out]hspointer to the HYPRE solver structure
Returns
a HYPRE_Solver structure (pointer) for the preconditioner

◆ _set_mumps_sles()

void _set_mumps_sles ( bool use_field_id,
cs_param_sles_t * slesp )
static

Set parameters for initializing SLES structures used for the resolution of the linear system. Case of MUMPS's own solvers.

Parameters
[in]use_field_idif false use system name
[in,out]slesppointer to a cs_param_sles_t structure

◆ _set_petsc_hypre_sles()

void _set_petsc_hypre_sles ( bool use_field_id,
cs_param_sles_t * slesp )
static

Set parameters for initializing SLES structures used for the resolution of the linear system. Case of PETSc and Hypre families of solvers.

Parameters
[in]use_field_idif false use system name
[in,out]slesppointer to a cs_param_sles_t structure

◆ _set_saturne_sles()

void _set_saturne_sles ( bool use_field_id,
cs_param_sles_t * slesp )
static

Set parameters for initializing SLES structures used for the resolution of the linear system. Case of saturne's own solvers.

Parameters
[in]use_field_idif false use system name
[in,out]slesppointer to a cs_param_sles_t structure

◆ _system_should_be_sym()

bool _system_should_be_sym ( cs_param_itsol_type_t solver)
inlinestatic

Return true if the prescribed solver implies a symmetric linear system.

◆ cs_param_sles_check_amg()

void cs_param_sles_check_amg ( cs_param_sles_t * slesp)

Check if the setting related to the AMG is consistent with the solver class.

Parameters
[in,out]slesppointer to a cs_pparam_sles_t structure

◆ cs_param_sles_check_class()

cs_param_sles_class_t cs_param_sles_check_class ( cs_param_sles_class_t wanted_class)

Check the availability of a solver library and return the requested one if this is possible or an alternative or CS_PARAM_SLES_N_CLASSES if no alternative is available.

Parameters
[in]wanted_classrequested class of solvers
Returns
the available solver class related to the requested class

◆ cs_param_sles_copy_from()

void cs_param_sles_copy_from ( cs_param_sles_t * src,
cs_param_sles_t * dst )

Copy a cs_param_sles_t structure from src to dst.

Parameters
[in]srcreference cs_param_sles_t structure to copy
[in,out]dstcopy of the reference at exit

◆ cs_param_sles_create()

cs_param_sles_t * cs_param_sles_create ( int field_id,
const char * system_name )

Create a cs_param_sles_t structure and assign a default settings.

Parameters
[in]field_idid related to to the variable field or -1
[in]system_namename of the system to solve or NULL
Returns
a pointer to a cs_param_sles_t stucture

◆ cs_param_sles_free()

void cs_param_sles_free ( cs_param_sles_t ** p_slesp)

Free a cs_param_sles_t structure.

Parameters
[in,out]slesppointer to a \cs_param_sles_t structure to free

◆ cs_param_sles_get_class_from_amg()

cs_param_sles_class_t cs_param_sles_get_class_from_amg ( cs_param_amg_type_t amg_type)

Retrieve the related solver class from the amg type.

Parameters
[in]amg_typetype of AMG to consider
Returns
the related solver class or CS_PARAM_SLES_CLASS_CS

◆ cs_param_sles_log()

void cs_param_sles_log ( cs_param_sles_t * slesp)

Log information related to the linear settings stored in the structure.

Parameters
[in]slesppointer to a cs_param_sles_log

◆ cs_param_sles_petsc_cmd()

void cs_param_sles_petsc_cmd ( bool use_prefix,
const char * prefix,
const char * keyword,
const char * keyval )

Set the command line option for PETSc.

Parameters
[in]use_prefixneed a prefix
[in]prefixoptional prefix
[in]keywordcommand keyword
[in]keyvalcommand value

◆ cs_param_sles_saddle_copy()

void cs_param_sles_saddle_copy ( const cs_param_sles_saddle_t * ref,
cs_param_sles_saddle_t * dest )

Copy a cs_param_sles_saddle_t structure from ref to dest.

Parameters
[in]refreference structure to be copied
[in,out]destdestination structure

◆ cs_param_sles_saddle_create()

cs_param_sles_saddle_t * cs_param_sles_saddle_create ( void )

Create a cs_param_sles_saddle_t structure and assign a minimalist default settings.

Returns
a pointer to the new cs_param_sles_saddle_t structure

◆ cs_param_sles_saddle_free()

void cs_param_sles_saddle_free ( cs_param_sles_saddle_t ** p_saddlep)

Free the structure storing the parameter settings for a saddle-point system.

Parameters
[in,out]p_saddlepdouble pointer to the structure to free

◆ cs_param_sles_saddle_init_schur()

void cs_param_sles_saddle_init_schur ( const char * basename,
cs_param_sles_saddle_t * saddlep )

Initialize a cs_param_sles_t structure for the Schur approximation nested inside a ref cs_param_sles_saddle_t structure. By default, this member is not allocated. Do nothing if the related structure is already allocated.

Parameters
[in]basenameprefix for the naming of the Schur system
[in,out]saddleppointer to the structure to update

◆ cs_param_sles_set()

int cs_param_sles_set ( bool use_field_id,
cs_param_sles_t * slesp )

Define cs_sles_t structure in accordance with the settings of a cs_param_sles_t structure (SLES = Sparse Linear Equation Solver)

Parameters
[in]use_field_idif false use system name to define a SLES
[in,out]slesppointer to a cs_param_sles_t structure
Returns
an error code (-1 if a problem is encountered, 0 otherwise)

◆ cs_param_sles_update_cvg_settings()

void cs_param_sles_update_cvg_settings ( bool use_field_id,
const cs_param_sles_t * slesp )

Update the settings associated to a cs_sles_t structure and apply those defined in the given cs_param_sles_t structure. This function is used only when a first setup has been performed.

One modifies only some specific options like the max. number of iterations or the relative tolerance

Parameters
[in]use_field_idif false use a name to retrieve the cs_sles_t struc.
[in]slesppointer to a cs_param_sles_t structure