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
127 typedef struct _cs_sles_it_setup_t {
129 double initial_residue;
140 } cs_sles_it_setup_t;
145 typedef struct _cs_sles_it_add_t {
154 struct _cs_sles_it_t {
161 bool ignore_convergence;
166 cs_sles_it_solve_t *solve;
178 unsigned n_iterations_last;
180 unsigned n_iterations_min;
182 unsigned n_iterations_max;
184 unsigned long long n_iterations_tot;
200 # if defined(HAVE_MPI)
202 MPI_Comm caller_comm;
208 const struct _cs_sles_it_t *shared;
212 cs_sles_it_add_t *add_data;
214 cs_sles_it_setup_t *setup_data;
227 struct _cs_sles_it_convergence_t {
233 unsigned n_iterations;
234 unsigned n_iterations_max;
263 double s =
cs_dot(c->setup_data->n_rows, x, y);
265 #if defined(HAVE_MPI)
267 if (c->comm != MPI_COMM_NULL) {
269 MPI_Allreduce(&s, &_sum, 1, MPI_DOUBLE, MPI_SUM, c->comm);
297 #if defined(HAVE_MPI)
299 if (c->comm != MPI_COMM_NULL) {
301 MPI_Allreduce(&s, &_sum, 1, MPI_DOUBLE, MPI_SUM, c->comm);
332 #if defined(HAVE_MPI)
334 if (c->comm != MPI_COMM_NULL) {
336 MPI_Allreduce(s, _sum, 2, MPI_DOUBLE, MPI_SUM, c->comm);
371 #if defined(HAVE_MPI)
373 if (c->comm != MPI_COMM_NULL) {
375 MPI_Allreduce(s, _sum, 2, MPI_DOUBLE, MPI_SUM, c->comm);
412 #if defined(HAVE_MPI)
414 if (c->comm != MPI_COMM_NULL) {
417 MPI_Allreduce(s, _sum, 3, MPI_DOUBLE, MPI_SUM, c->comm);
460 #if defined(HAVE_MPI)
462 if (c->comm != MPI_COMM_NULL) {
464 MPI_Allreduce(s, _sum, 5, MPI_DOUBLE, MPI_SUM, c->comm);
465 memcpy(s, _sum, 5*
sizeof(
double));
510 #if defined(HAVE_MPI)
512 if (c->comm != MPI_COMM_NULL) {
514 MPI_Allreduce(s, _sum, 4, MPI_DOUBLE, MPI_SUM, c->comm);
515 memcpy(s, _sum, 4*
sizeof(
double));
545 aux[0] = (c[0] -
b[0]);
546 aux[1] = (c[1] -
b[1]) - aux[0]*mat[3];
547 aux[2] = (c[2] -
b[2]) - aux[0]*mat[6] - aux[1]*mat[7];
549 x[2] = aux[2]/mat[8];
550 x[1] = (aux[1] - mat[5]*x[2])/mat[4];
551 x[0] = (aux[0] - mat[1]*x[1] - mat[2]*x[2])/mat[0];
573 assert(db_size <= DB_SIZE_MAX);
577 for (
int ii = 0; ii < db_size; ii++) {
578 aux[ii] = (c[ii] -
b[ii]);
579 for (
int jj = 0; jj < ii; jj++) {
580 aux[ii] -= aux[jj]*mat[ii*db_size + jj];
585 for (
int ii = db_size - 1; ii >= 0; ii-=1) {
587 for (
int jj = db_size - 1; jj > ii; jj-=1) {
588 x[ii] -= x[jj]*mat[ii*db_size + jj];
590 x[ii] /= mat[ii*(db_size + 1)];
611 assert(db_size <= DB_SIZE_MAX);
614 for (
int ii = 0; ii < db_size; ii++) {
616 for (
int jj = 0; jj < ii; jj++)
617 x[ii] -= x[jj]*mat[ii*db_size + jj];
621 for (
int ii = db_size - 1; ii >= 0; ii--) {
622 for (
int jj = db_size - 1; jj > ii; jj--)
623 x[ii] -= x[jj]*mat[ii*db_size + jj];
624 x[ii] /= mat[ii*(db_size + 1)];
650 const char *solver_name,
678 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:1424
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:1613
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:1445
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:1552
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:1581
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:1525
#define restrict
Definition: cs_defs.h:124
#define BEGIN_C_DECLS
Definition: cs_defs.h:492
double cs_real_t
Floating-point value.
Definition: cs_defs.h:304
#define END_C_DECLS
Definition: cs_defs.h:493
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_halo_rotation_t
Definition: cs_halo.h:60
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:94
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:57
cs_sles_pc_state_t() cs_sles_pc_apply_t(void *context, cs_halo_rotation_t rotation_mode, const cs_real_t *x_in, cs_real_t *x_out)
Function pointer for application of a preconditioner.
Definition: cs_sles_pc.h:144
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
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114
double precision, save a
Definition: cs_fuel_incl.f90:146
double precision, save b
Definition: cs_fuel_incl.f90:146
Definition: cs_timer.h:57