1 #ifndef __CS_SLES_IT_PRIV_H__
2 #define __CS_SLES_IT_PRIV_H__
86 #if !defined(HUGE_VAL)
87 #define HUGE_VAL 1.E+12
125 typedef struct _cs_sles_it_setup_t {
127 double initial_residual;
138 } cs_sles_it_setup_t;
143 typedef struct _cs_sles_it_add_t {
152 struct _cs_sles_it_t {
161 bool ignore_convergence;
165 int restart_interval;
170 cs_sles_it_solve_t *solve;
182 unsigned n_iterations_last;
184 unsigned n_iterations_min;
186 unsigned n_iterations_max;
188 unsigned long long n_iterations_tot;
204 # if defined(HAVE_MPI)
206 MPI_Comm caller_comm;
212 const struct _cs_sles_it_t *shared;
216 cs_sles_it_add_t *add_data;
218 cs_sles_it_setup_t *setup_data;
224 int fallback_n_max_iter;
235 struct _cs_sles_it_convergence_t {
241 unsigned n_iterations;
242 unsigned n_iterations_max;
271 double s =
cs_dot(c->setup_data->n_rows, x, y);
273 #if defined(HAVE_MPI)
275 if (c->comm != MPI_COMM_NULL) {
277 MPI_Allreduce(&s, &_sum, 1, MPI_DOUBLE, MPI_SUM, c->comm);
305 #if defined(HAVE_MPI)
307 if (c->comm != MPI_COMM_NULL) {
309 MPI_Allreduce(&s, &_sum, 1, MPI_DOUBLE, MPI_SUM, c->comm);
340 #if defined(HAVE_MPI)
342 if (c->comm != MPI_COMM_NULL) {
344 MPI_Allreduce(s, _sum, 2, MPI_DOUBLE, MPI_SUM, c->comm);
379 #if defined(HAVE_MPI)
381 if (c->comm != MPI_COMM_NULL) {
383 MPI_Allreduce(s, _sum, 2, MPI_DOUBLE, MPI_SUM, c->comm);
420 #if defined(HAVE_MPI)
422 if (c->comm != MPI_COMM_NULL) {
425 MPI_Allreduce(s, _sum, 3, MPI_DOUBLE, MPI_SUM, c->comm);
468 #if defined(HAVE_MPI)
470 if (c->comm != MPI_COMM_NULL) {
472 MPI_Allreduce(s, _sum, 5, MPI_DOUBLE, MPI_SUM, c->comm);
473 memcpy(s, _sum, 5*
sizeof(
double));
504 aux[0] = (c[0] - b[0]);
505 aux[1] = (c[1] - b[1]) - aux[0]*mat[3];
506 aux[2] = (c[2] - b[2]) - aux[0]*mat[6] - aux[1]*mat[7];
508 x[2] = aux[2]/mat[8];
509 x[1] = (aux[1] - mat[5]*x[2])/mat[4];
510 x[0] = (aux[0] - mat[1]*x[1] - mat[2]*x[2])/mat[0];
532 assert(db_size <= DB_SIZE_MAX);
536 for (
int ii = 0; ii < db_size; ii++) {
537 aux[ii] = (c[ii] - b[ii]);
538 for (
int jj = 0; jj < ii; jj++) {
539 aux[ii] -= aux[jj]*mat[ii*db_size + jj];
544 for (
int ii = db_size - 1; ii >= 0; ii-=1) {
546 for (
int jj = db_size - 1; jj > ii; jj-=1) {
547 x[ii] -= x[jj]*mat[ii*db_size + jj];
549 x[ii] /= mat[ii*(db_size + 1)];
570 assert(db_size <= DB_SIZE_MAX);
573 for (
int ii = 0; ii < db_size; ii++) {
575 for (
int jj = 0; jj < ii; jj++)
576 x[ii] -= x[jj]*mat[ii*db_size + jj];
580 for (
int ii = db_size - 1; ii >= 0; ii--) {
581 for (
int jj = db_size - 1; jj > ii; jj--)
582 x[ii] -= x[jj]*mat[ii*db_size + jj];
583 x[ii] /= mat[ii*(db_size + 1)];
609 const char *solver_name,
637 bool block_nn_inverse);
double cs_dot(cs_lnum_t n, const cs_real_t *x, const cs_real_t *y)
Return the dot product of 2 vectors: x.y.
Definition: cs_blas.c:1465
void cs_dot_xx_yy_xy_xz_yz(cs_lnum_t n, const cs_real_t *restrict x, const cs_real_t *restrict y, const cs_real_t *restrict z, double *xx, double *yy, double *xy, double *xz, double *yz)
Return 5 dot products of 3 vectors: x.x, y.y, x.y, x.z, and y.z.
Definition: cs_blas.c:1654
double cs_dot_xx(cs_lnum_t n, const cs_real_t *x)
Return dot products of a vector with itself: x.x.
Definition: cs_blas.c:1486
void cs_dot_xy_yz(cs_lnum_t n, const cs_real_t *restrict x, const cs_real_t *restrict y, const cs_real_t *restrict z, double *xy, double *yz)
Return 2 dot products of 3 vectors: x.y, and y.z.
Definition: cs_blas.c:1593
void cs_dot_xx_xy_yz(cs_lnum_t n, const cs_real_t *restrict x, const cs_real_t *restrict y, const cs_real_t *restrict z, double *xx, double *xy, double *yz)
Return 3 dot products of 3 vectors: x.x, x.y, and y.z.
Definition: cs_blas.c:1622
void cs_dot_xx_xy(cs_lnum_t n, const cs_real_t *restrict x, const cs_real_t *restrict y, double *xx, double *xy)
Return 2 dot products of 2 vectors: x.x, and x.y.
Definition: cs_blas.c:1566
#define restrict
Definition: cs_defs.h:139
#define BEGIN_C_DECLS
Definition: cs_defs.h:514
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
#define END_C_DECLS
Definition: cs_defs.h:515
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:110
cs_sles_convergence_state_t
Definition: cs_sles.h:56
struct _cs_sles_it_t cs_sles_it_t
Definition: cs_sles_it.h:86
struct _cs_sles_it_convergence_t cs_sles_it_convergence_t
Definition: cs_sles_it.h:90
cs_sles_it_type_t
Definition: cs_sles_it.h:55
cs_sles_pc_state_t() cs_sles_pc_apply_t(void *context, const cs_real_t *x_in, cs_real_t *x_out)
Function pointer for application of a preconditioner.
Definition: cs_sles_pc.h:145
struct _cs_sles_pc_t cs_sles_pc_t
Definition: cs_sles_pc.h:66
struct _cs_time_plot_t cs_time_plot_t
Definition: cs_time_plot.h:48
Definition: cs_timer.h:55