My Project
programmer's documentation
|
#include "cs_defs.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include "bft_mem.h"
#include "bft_error.h"
#include "bft_printf.h"
#include "cs_base.h"
#include "cs_blas.h"
#include "cs_field.h"
#include "cs_log.h"
#include "cs_halo.h"
#include "cs_map.h"
#include "cs_mesh.h"
#include "cs_matrix.h"
#include "cs_matrix_default.h"
#include "cs_matrix_util.h"
#include "cs_parall.h"
#include "cs_post.h"
#include "cs_timer.h"
#include "cs_timer_stats.h"
#include "cs_sles_pc.h"
Functions | |
cs_sles_pc_t * | cs_sles_pc_define (void *context, cs_sles_pc_get_type_t *get_type_func, cs_sles_pc_setup_t *setup_func, cs_sles_pc_tolerance_t *tolerance_func, cs_sles_pc_apply_t *apply_func, cs_sles_pc_free_t *free_func, cs_sles_pc_log_t *log_func, cs_sles_pc_clone_t *clone_func, cs_sles_pc_destroy_t *destroy_func) |
Define sparse linear equation preconditioner. More... | |
void | cs_sles_pc_destroy (cs_sles_pc_t **pc) |
Destroy a sparse linear equation preconditioner. More... | |
cs_sles_pc_t * | cs_sles_pc_clone (const cs_sles_pc_t *src) |
Create a new preconditioner context based on the copy of another. More... | |
const char * | cs_sles_pc_get_type (cs_sles_pc_t *pc) |
Return type name of preconditioner context. More... | |
const char * | cs_sles_pc_get_type_name (cs_sles_pc_t *pc) |
Return type name of preconditioner context. More... | |
void * | cs_sles_pc_get_context (cs_sles_pc_t *pc) |
Return pointer to preconditioner context structure pointer. More... | |
cs_sles_pc_apply_t * | cs_sles_pc_get_apply_func (const cs_sles_pc_t *pc) |
Return a pointer to the function used to apply a preconditioner. More... | |
void | cs_sles_pc_set_tolerance (cs_sles_pc_t *pc, double precision, double r_norm) |
Set the required tolerance for preconditioners involving an iterative solver. More... | |
void | cs_sles_pc_setup (cs_sles_pc_t *pc, const char *name, const cs_matrix_t *a, int verbosity) |
Setup sparse linear equation preconditioner. More... | |
cs_sles_pc_state_t | cs_sles_pc_apply (cs_sles_pc_t *pc, cs_halo_rotation_t rotation_mode, cs_real_t *x_in, cs_real_t *x_out) |
Apply a preconditioner. More... | |
void | cs_sles_pc_free (cs_sles_pc_t *pc) |
Free preconditioner setup. More... | |
void | cs_sles_pc_log (cs_sles_pc_t *pc, cs_log_t log_type) |
Log preconditioner setup, history and performance data. More... | |
cs_sles_pc_t * | cs_sles_pc_none_create (void) |
Create an "identity" (or null) preconditioner. More... | |
cs_sles_pc_t * | cs_sles_pc_jacobi_create (void) |
Create a Jacobi preconditioner. More... | |
cs_sles_pc_t * | cs_sles_pc_poly_1_create (void) |
Create a Polynomial preconditioner of degree 1. More... | |
cs_sles_pc_t * | cs_sles_pc_poly_2_create (void) |
Create a Polynomial preconditioner of degree 2. More... | |
cs_sles_pc_state_t cs_sles_pc_apply | ( | cs_sles_pc_t * | pc, |
cs_halo_rotation_t | rotation_mode, | ||
cs_real_t * | x_in, | ||
cs_real_t * | x_out | ||
) |
Apply a preconditioner.
If no options were previously provided for the matching system, default options will be used.
In cases where it is desired that the preconditioner modify a vector "in place", x_in should be set to NULL, and x_out contain the vector to be modified ( ).
[in,out] | pc | pointer to preconditioner object |
[in] | rotation_mode | halo update option for rotational periodicity |
[in] | x_in | input vector |
[in,out] | x_out | input/output vector |
cs_sles_pc_t* cs_sles_pc_clone | ( | const cs_sles_pc_t * | src | ) |
Create a new preconditioner context based on the copy of another.
The intended use of this function is to allow associating different preconditioners to related systems, so as to allow simultaneous setups and differentiate logging, while using the same settings by default.
If no preconditioner (i.e. NULL) is passed, it will return NULL.
[in] | src | pointer to source preconditioner object |
cs_sles_pc_t* cs_sles_pc_define | ( | void * | context, |
cs_sles_pc_get_type_t * | get_type_func, | ||
cs_sles_pc_setup_t * | setup_func, | ||
cs_sles_pc_tolerance_t * | tolerance_func, | ||
cs_sles_pc_apply_t * | apply_func, | ||
cs_sles_pc_free_t * | free_func, | ||
cs_sles_pc_log_t * | log_func, | ||
cs_sles_pc_clone_t * | clone_func, | ||
cs_sles_pc_destroy_t * | destroy_func | ||
) |
Define sparse linear equation preconditioner.
The context pointer is used to point to a structure adapted to the function pointers given here, and combined with those functions, allows using both built-in, external, or user-defined preconditioners.
[in,out] | context | pointer to preconditioner context structure (cs_sles_pc subsystem becomes owner) |
[in] | get_type_func | pointer to function returning type name |
[in] | setup_func | pointer to preconditioner setup function |
[in] | tolerance_func | pointer to tolerance setting functio |
[in] | apply_func | pointer to preconditioner application function (also calls setup_func if not done yet or free_func called since last apply) |
[in] | free_func | pointer function freeing system setup |
[in] | log_func | pointer to system info logging function (optional, but recommended) |
[in] | clone_func | pointer to settings clone function |
[in] | destroy_func | pointer to function destroying preconditioner context |
void cs_sles_pc_destroy | ( | cs_sles_pc_t ** | pc | ) |
Destroy a sparse linear equation preconditioner.
[in,out] | pc | pointer to preconditioner context structure |
void cs_sles_pc_free | ( | cs_sles_pc_t * | pc | ) |
Free preconditioner setup.
This function frees resolution-related data, such as multigrid hierarchy, preconditioning, and any other temporary arrays or objects required for resolution, but maintains context information such as that used for logging (especially performance data).
[in,out] | pc | pointer to preconditioner object |
cs_sles_pc_apply_t* cs_sles_pc_get_apply_func | ( | const cs_sles_pc_t * | pc | ) |
Return a pointer to the function used to apply a preconditioner.
This allows calling the preconditioner with one less level of indirection.
[in] | pc | pointer to preconditioner object |
void* cs_sles_pc_get_context | ( | cs_sles_pc_t * | pc | ) |
Return pointer to preconditioner context structure pointer.
The context structure depends on the type of preconditioner used, which may in turn be determined by the string returned by cs_sles_pc_get_type(). If may be used by appropriate functions specific to that type.
[in] | pc | pointer to preconditioner object |
const char* cs_sles_pc_get_type | ( | cs_sles_pc_t * | pc | ) |
Return type name of preconditioner context.
The returned string is intended to help determine which type is associated with the void * pointer returned by cs_sles_pc_get_context for a given preconditioner definition, so as to be able to call additional specific functions beyond the generic functions assigned to a cs_sles_pc_t object.
[in] | pc | pointer to preconditioner object |
const char* cs_sles_pc_get_type_name | ( | cs_sles_pc_t * | pc | ) |
Return type name of preconditioner context.
The returned string is intended mainly for logging.
[in] | pc | pointer to preconditioner object |
cs_sles_pc_t* cs_sles_pc_jacobi_create | ( | void | ) |
Create a Jacobi preconditioner.
void cs_sles_pc_log | ( | cs_sles_pc_t * | pc, |
cs_log_t | log_type | ||
) |
Log preconditioner setup, history and performance data.
This function frees resolution-related data, such as multigrid hierarchy, preconditioning, and any other temporary arrays or objects required for resolution, but maintains context information such as that used for logging (especially performance data).
[in,out] | pc | pointer to preconditioner object |
[in] | log_type | log type |
cs_sles_pc_t* cs_sles_pc_none_create | ( | void | ) |
Create an "identity" (or null) preconditioner.
cs_sles_pc_t* cs_sles_pc_poly_1_create | ( | void | ) |
Create a Polynomial preconditioner of degree 1.
Create a polynomial preconditioner of degree 1.
cs_sles_pc_t* cs_sles_pc_poly_2_create | ( | void | ) |
Create a Polynomial preconditioner of degree 2.
Create a polynomial preconditioner of degree 2.
void cs_sles_pc_set_tolerance | ( | cs_sles_pc_t * | pc, |
double | precision, | ||
double | r_norm | ||
) |
Set the required tolerance for preconditioners involving an iterative solver.
This will usually not be relevant to non-iterative preconditioners, in which case this is a no-op.
If no options were previously provided for the matching system, default options will be used.
The system is considered to have converged when residue/r_norm <= precision, residue being the L2 norm of a.vx-rhs.
[in,out] | pc | pointer to preconditioner object |
[in] | precision | preconditioner precision |
[in] | r_norm | residue normalization |
void cs_sles_pc_setup | ( | cs_sles_pc_t * | pc, |
const char * | name, | ||
const cs_matrix_t * | a, | ||
int | verbosity | ||
) |
Setup sparse linear equation preconditioner.
Use of this function is optional: if a cs_sles_solve is called for the same system before this function is called, the latter will be called automatically.
If no options were previously provided for the matching system, default options will be used.
[in,out] | pc | pointer to preconditioner object |
[in] | name | linear system name |
[in] | a | matrix |
[in] | verbosity | verbosity level |