1 |
ksteube |
1312 |
|
2 |
|
|
/******************************************************* |
3 |
ksteube |
1811 |
* |
4 |
|
|
* Copyright (c) 2003-2008 by University of Queensland |
5 |
|
|
* Earth Systems Science Computational Center (ESSCC) |
6 |
|
|
* http://www.uq.edu.au/esscc |
7 |
|
|
* |
8 |
|
|
* Primary Business: Queensland, Australia |
9 |
|
|
* Licensed under the Open Software License version 3.0 |
10 |
|
|
* http://www.opensource.org/licenses/osl-3.0.php |
11 |
|
|
* |
12 |
|
|
*******************************************************/ |
13 |
dhawcroft |
631 |
|
14 |
ksteube |
1811 |
|
15 |
jgs |
150 |
#ifndef INC_SOLVER |
16 |
|
|
#define INC_SOLVER |
17 |
|
|
|
18 |
gross |
700 |
#include "SystemMatrix.h" |
19 |
|
|
#include "performance.h" |
20 |
gross |
1476 |
#include "Functions.h" |
21 |
jgs |
150 |
|
22 |
ksteube |
1312 |
#define PASO_TRACE |
23 |
jgs |
150 |
/* error codes used in the solver */ |
24 |
|
|
#define SOLVER_NO_ERROR 0 |
25 |
|
|
#define SOLVER_MAXITER_REACHED 1 |
26 |
|
|
#define SOLVER_INPUT_ERROR -1 |
27 |
|
|
#define SOLVER_MEMORY_ERROR -9 |
28 |
|
|
#define SOLVER_BREAKDOWN -10 |
29 |
artak |
1787 |
#define SOLVER_NEGATIVE_NORM_ERROR -11 |
30 |
jgs |
150 |
|
31 |
artak |
1787 |
|
32 |
jgs |
154 |
static double ONE=1.; |
33 |
|
|
static double ZERO=0.; |
34 |
|
|
static double TOLERANCE_FOR_SCALARS=0.; |
35 |
jgs |
150 |
|
36 |
|
|
/* ILU preconditioner */ |
37 |
|
|
struct Paso_Solver_ILU { |
38 |
gross |
431 |
dim_t n_block; |
39 |
jgs |
150 |
dim_t n; |
40 |
gross |
431 |
index_t num_colors; |
41 |
|
|
index_t* colorOf; |
42 |
|
|
index_t* main_iptr; |
43 |
|
|
double* factors; |
44 |
ksteube |
1312 |
Paso_Pattern* pattern; |
45 |
jgs |
150 |
}; |
46 |
|
|
typedef struct Paso_Solver_ILU Paso_Solver_ILU; |
47 |
|
|
|
48 |
gross |
430 |
/* RILU preconditioner */ |
49 |
|
|
struct Paso_Solver_RILU { |
50 |
|
|
dim_t n; |
51 |
|
|
dim_t n_block; |
52 |
|
|
dim_t n_F; |
53 |
|
|
dim_t n_C; |
54 |
|
|
double* inv_A_FF; |
55 |
|
|
index_t* A_FF_pivot; |
56 |
ksteube |
1312 |
Paso_SparseMatrix * A_FC; |
57 |
|
|
Paso_SparseMatrix * A_CF; |
58 |
gross |
430 |
index_t* rows_in_F; |
59 |
|
|
index_t* rows_in_C; |
60 |
|
|
index_t* mask_F; |
61 |
|
|
index_t* mask_C; |
62 |
|
|
double* x_F; |
63 |
|
|
double* b_F; |
64 |
|
|
double* x_C; |
65 |
|
|
double* b_C; |
66 |
|
|
struct Paso_Solver_RILU * RILU_of_Schur; |
67 |
|
|
}; |
68 |
|
|
typedef struct Paso_Solver_RILU Paso_Solver_RILU; |
69 |
jgs |
150 |
|
70 |
gross |
430 |
|
71 |
jgs |
150 |
/* jacobi preconditioner */ |
72 |
|
|
|
73 |
|
|
typedef struct Paso_Solver_Jacobi { |
74 |
|
|
dim_t n_block; |
75 |
|
|
dim_t n; |
76 |
|
|
double* values; |
77 |
|
|
index_t* pivot; |
78 |
|
|
} Paso_Solver_Jacobi; |
79 |
|
|
|
80 |
|
|
/* general preconditioner interface */ |
81 |
|
|
|
82 |
|
|
typedef struct Paso_Solver_Preconditioner { |
83 |
|
|
dim_t type; |
84 |
|
|
/* jacobi preconditioner */ |
85 |
|
|
Paso_Solver_Jacobi* jacobi; |
86 |
|
|
/* ilu preconditioner */ |
87 |
|
|
Paso_Solver_ILU* ilu; |
88 |
gross |
430 |
/* ilu preconditioner */ |
89 |
|
|
Paso_Solver_RILU* rilu; |
90 |
jgs |
150 |
} Paso_Solver_Preconditioner; |
91 |
|
|
|
92 |
gross |
584 |
void Paso_Solver(Paso_SystemMatrix*,double*,double*,Paso_Options*,Paso_Performance* pp); |
93 |
jgs |
150 |
void Paso_Solver_free(Paso_SystemMatrix*); |
94 |
ksteube |
1312 |
err_t Paso_Solver_BiCGStab( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp); |
95 |
|
|
err_t Paso_Solver_PCG( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp); |
96 |
artak |
1703 |
err_t Paso_Solver_TFQMR( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp); |
97 |
artak |
1787 |
err_t Paso_Solver_MINRES( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, double *tol, Paso_Performance* pp); |
98 |
ksteube |
1312 |
err_t Paso_Solver_GMRES(Paso_SystemMatrix * A, double * r, double * x, dim_t *num_iter, double * tolerance,dim_t length_of_recursion,dim_t restart, Paso_Performance* pp); |
99 |
jgs |
150 |
void Paso_Preconditioner_free(Paso_Solver_Preconditioner*); |
100 |
|
|
void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options); |
101 |
|
|
void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double*,double*); |
102 |
|
|
void Paso_Solver_applyBlockDiagonalMatrix(dim_t n_block,dim_t n,double* D,index_t* pivot,double* x,double* b); |
103 |
gross |
431 |
|
104 |
jgs |
150 |
void Paso_Solver_ILU_free(Paso_Solver_ILU * in); |
105 |
ksteube |
1312 |
Paso_Solver_ILU* Paso_Solver_getILU(Paso_SparseMatrix * A_p,bool_t verbose); |
106 |
jgs |
150 |
void Paso_Solver_solveILU(Paso_Solver_ILU * ilu, double * x, double * b); |
107 |
gross |
431 |
|
108 |
|
|
void Paso_Solver_RILU_free(Paso_Solver_RILU * in); |
109 |
ksteube |
1312 |
Paso_Solver_RILU* Paso_Solver_getRILU(Paso_SparseMatrix * A_p,bool_t verbose); |
110 |
gross |
431 |
void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b); |
111 |
|
|
|
112 |
ksteube |
1312 |
void Paso_Solver_updateIncompleteSchurComplement(Paso_SparseMatrix* A_CC, Paso_SparseMatrix *A_CF,double* invA_FF,index_t* A_FF_pivot, Paso_SparseMatrix *A_FC); |
113 |
|
|
Paso_Solver_Jacobi* Paso_Solver_getJacobi(Paso_SparseMatrix * A_p); |
114 |
jgs |
150 |
void Paso_Solver_solveJacobi(Paso_Solver_Jacobi * prec, double * x, double * b); |
115 |
|
|
void Paso_Solver_Jacobi_free(Paso_Solver_Jacobi * in); |
116 |
|
|
|
117 |
gross |
1639 |
err_t Paso_Solver_GMRES2(Paso_Function * F, const double* f0, const double* x0, double * x, dim_t *iter, double* tolerance, Paso_Performance* pp); |
118 |
gross |
1476 |
err_t Paso_Solver_NewtonGMRES(Paso_Function *F, double *x, Paso_Options* options, Paso_Performance* pp); |
119 |
|
|
|
120 |
gross |
1639 |
Paso_Function * Paso_Function_LinearSystem_alloc(Paso_SystemMatrix* A, double* b, Paso_Options* options); |
121 |
gross |
1804 |
err_t Paso_Function_LinearSystem_call(Paso_Function * F,double* value, const double* arg, Paso_Performance *pp); |
122 |
gross |
1639 |
void Paso_Function_LinearSystem_free(Paso_Function * F); |
123 |
gross |
1804 |
err_t Paso_Function_LinearSystem_setInitialGuess(Paso_SystemMatrix* A, double* x, Paso_Performance *pp); |
124 |
gross |
1476 |
|
125 |
jgs |
150 |
#endif /* #ifndef INC_SOLVER */ |