18 |
#include "SystemMatrix.h" |
#include "SystemMatrix.h" |
19 |
#include "performance.h" |
#include "performance.h" |
20 |
|
|
21 |
#define MAX_BLOCK_SIZE 3 |
|
22 |
|
#define PASO_AMG_UNDECIDED -1 |
23 |
|
#define PASO_AMG_IN_F 0 |
24 |
|
#define PASO_AMG_IN_C 1 |
25 |
|
|
26 |
/* GAUSS SEIDEL & Jacobi */ |
/* GAUSS SEIDEL & Jacobi */ |
27 |
typedef struct Paso_Preconditioner_LocalSmoother { |
typedef struct Paso_Preconditioner_LocalSmoother { |
53 |
|
|
54 |
/* AMG preconditioner */ |
/* AMG preconditioner */ |
55 |
struct Paso_Preconditioner_LocalAMG { |
struct Paso_Preconditioner_LocalAMG { |
|
dim_t n; |
|
56 |
dim_t level; |
dim_t level; |
57 |
|
dim_t n; |
|
/* ====================== */ |
|
|
bool_t coarsest_level; |
|
|
dim_t n_block; |
|
58 |
dim_t n_F; |
dim_t n_F; |
59 |
dim_t n_C; |
dim_t n_block; |
60 |
|
Paso_SparseMatrix * A_C; /* coarse level matrix */ |
61 |
Paso_SparseMatrix * A_FF; |
Paso_SparseMatrix * P; /* prolongation n x n_C*/ |
62 |
Paso_SparseMatrix * A_FC; |
Paso_SparseMatrix * R; /* restriction n_C x n */ |
63 |
Paso_SparseMatrix * A_CF; |
|
64 |
Paso_SparseMatrix * W_FC; |
Paso_Preconditioner_LocalSmoother* Smoother; |
|
|
|
|
Paso_SparseMatrix * P; |
|
|
Paso_SparseMatrix * R; |
|
|
|
|
|
index_t* rows_in_F; |
|
|
index_t* rows_in_C; |
|
|
index_t* mask_F; |
|
|
index_t* mask_C; |
|
|
double* x_F; |
|
|
double* b_F; |
|
|
double* x_C; |
|
|
double* b_C; |
|
|
|
|
65 |
dim_t post_sweeps; |
dim_t post_sweeps; |
66 |
dim_t pre_sweeps; |
dim_t pre_sweeps; |
67 |
|
index_t reordering; /* applied reordering in direct solver */ |
68 |
Paso_SparseMatrix * A; |
dim_t refinements; /* number of refinements in direct solver (typically =0) */ |
69 |
Paso_SparseMatrix * AOffset1; |
double* r; /* buffer for residual */ |
70 |
Paso_SparseMatrix * AUnrolled; |
double* x_C; /* solution of coarse level system */ |
71 |
void* solver; |
double* b_C; /* right hand side of coarse level system */ |
72 |
/*=================================*/ |
struct Paso_Preconditioner_LocalAMG * AMG_C; |
|
|
|
|
Paso_Preconditioner_LocalSmoother* Smoother; |
|
|
struct Paso_Preconditioner_LocalAMG * AMG_of_Coarse; |
|
73 |
}; |
}; |
74 |
typedef struct Paso_Preconditioner_LocalAMG Paso_Preconditioner_LocalAMG; |
typedef struct Paso_Preconditioner_LocalAMG Paso_Preconditioner_LocalAMG; |
75 |
|
|
76 |
void Paso_Preconditioner_LocalAMG_free(Paso_Preconditioner_LocalAMG * in); |
void Paso_Preconditioner_LocalAMG_free(Paso_Preconditioner_LocalAMG * in); |
77 |
Paso_Preconditioner_LocalAMG* Paso_Preconditioner_LocalAMG_alloc(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options); |
Paso_Preconditioner_LocalAMG* Paso_Preconditioner_LocalAMG_alloc(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options); |
78 |
void Paso_Preconditioner_LocalAMG_solve(Paso_Preconditioner_LocalAMG * amg, double * x, double * b); |
void Paso_Preconditioner_LocalAMG_solve(Paso_SparseMatrix* A, Paso_Preconditioner_LocalAMG * amg, double * x, double * b); |
79 |
|
void Paso_Preconditioner_AMG_RSCoarsening_Block(Paso_SparseMatrix* A, index_t* split_marker, const double theta,const double tau); |
80 |
|
void Paso_Preconditioner_AMG_RSCoarsening(Paso_SparseMatrix* A, index_t* split_marker, const double theta,const double tau); |
81 |
|
void Paso_Preconditioner_AMG_RSCoarsening_search(const dim_t n, const index_t* offset, const dim_t* degree, const index_t* S, index_t*split_marker); |
82 |
|
|
83 |
|
|
84 |
/*===============================================*/ |
/*===============================================*/ |
114 |
|
|
115 |
|
|
116 |
|
|
|
|
|
|
/* AMLI preconditioner */ |
|
|
struct Paso_Solver_AMLI { |
|
|
dim_t n; |
|
|
dim_t level; |
|
|
bool_t coarsest_level; |
|
|
dim_t n_block; |
|
|
dim_t n_F; |
|
|
dim_t n_C; |
|
|
double* inv_A_FF; |
|
|
index_t* A_FF_pivot; |
|
|
Paso_SparseMatrix * A_FC; |
|
|
Paso_SparseMatrix * A_CF; |
|
|
index_t* rows_in_F; |
|
|
index_t* rows_in_C; |
|
|
index_t* mask_F; |
|
|
index_t* mask_C; |
|
|
double* x_F; |
|
|
double* b_F; |
|
|
double* x_C; |
|
|
double* b_C; |
|
|
|
|
|
dim_t post_sweeps; |
|
|
dim_t pre_sweeps; |
|
|
|
|
|
Paso_SparseMatrix * A; |
|
|
Paso_SparseMatrix * AOffset1; |
|
|
void* solver; |
|
|
Paso_Preconditioner_LocalSmoother* Smoother; |
|
|
struct Paso_Solver_AMLI * AMLI_of_Schur; |
|
|
}; |
|
|
typedef struct Paso_Solver_AMLI Paso_Solver_AMLI; |
|
|
|
|
|
/* AMLI preconditioner on blocks*/ |
|
|
struct Paso_Solver_AMLI_System { |
|
|
dim_t block_size; |
|
|
Paso_SparseMatrix *block[MAX_BLOCK_SIZE]; |
|
|
Paso_Solver_AMLI *amliblock[MAX_BLOCK_SIZE]; |
|
|
}; |
|
|
typedef struct Paso_Solver_AMLI_System Paso_Solver_AMLI_System; |
|
|
|
|
|
|
|
117 |
/* general preconditioner interface */ |
/* general preconditioner interface */ |
118 |
|
|
119 |
typedef struct Paso_Preconditioner { |
typedef struct Paso_Preconditioner { |
125 |
Paso_Preconditioner_Smoother* gs; |
Paso_Preconditioner_Smoother* gs; |
126 |
/* amg preconditioner */ |
/* amg preconditioner */ |
127 |
Paso_Preconditioner_LocalAMG* localamg; |
Paso_Preconditioner_LocalAMG* localamg; |
128 |
|
Paso_Preconditioner_LocalSmoother* localamgsubstitute; |
129 |
|
|
130 |
/* ilu preconditioner */ |
/* ilu preconditioner */ |
131 |
Paso_Solver_ILU* ilu; |
Paso_Solver_ILU* ilu; |
132 |
/* rilu preconditioner */ |
/* rilu preconditioner */ |
133 |
Paso_Solver_RILU* rilu; |
Paso_Solver_RILU* rilu; |
|
|
|
|
/* amg preconditioner */ |
|
|
Paso_Solver_AMLI* amli; |
|
|
/* amg on System */ |
|
|
Paso_Solver_AMLI_System* amliSystem; |
|
134 |
|
|
135 |
} Paso_Preconditioner; |
} Paso_Preconditioner; |
136 |
|
|
139 |
void Paso_Preconditioner_solve(Paso_Preconditioner* prec, Paso_SystemMatrix* A,double*,double*); |
void Paso_Preconditioner_solve(Paso_Preconditioner* prec, Paso_SystemMatrix* A,double*,double*); |
140 |
|
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
/*******************************************/ |
/*******************************************/ |
143 |
void Paso_Solver_ILU_free(Paso_Solver_ILU * in); |
void Paso_Solver_ILU_free(Paso_Solver_ILU * in); |
144 |
Paso_Solver_ILU* Paso_Solver_getILU(Paso_SparseMatrix * A_p,bool_t verbose); |
Paso_Solver_ILU* Paso_Solver_getILU(Paso_SparseMatrix * A_p,bool_t verbose); |
148 |
Paso_Solver_RILU* Paso_Solver_getRILU(Paso_SparseMatrix * A_p,bool_t verbose); |
Paso_Solver_RILU* Paso_Solver_getRILU(Paso_SparseMatrix * A_p,bool_t verbose); |
149 |
void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b); |
void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b); |
150 |
|
|
|
|
|
|
|
|
|
void Paso_Solver_AMLI_System_free(Paso_Solver_AMLI_System * in); |
|
|
void Paso_Solver_AMLI_free(Paso_Solver_AMLI * in); |
|
|
Paso_Solver_AMLI* Paso_Solver_getAMLI(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options); |
|
|
void Paso_Solver_solveAMLI(Paso_Solver_AMLI * amli, double * x, double * b); |
|
|
|
|
151 |
void Paso_Solver_updateIncompleteSchurComplement(Paso_SparseMatrix* A_CC, Paso_SparseMatrix *A_CF,double* invA_FF,index_t* A_FF_pivot, Paso_SparseMatrix *A_FC); |
void Paso_Solver_updateIncompleteSchurComplement(Paso_SparseMatrix* A_CC, Paso_SparseMatrix *A_CF,double* invA_FF,index_t* A_FF_pivot, Paso_SparseMatrix *A_FC); |
152 |
|
|
153 |
|
|