/[escript]/trunk/paso/src/Solver.h
ViewVC logotype

Contents of /trunk/paso/src/Solver.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2987 - (show annotations)
Tue Mar 16 01:32:43 2010 UTC (9 years, 10 months ago) by gross
File MIME type: text/plain
File size: 8088 byte(s)
FCT solver rewritten
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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
14
15 #ifndef INC_SOLVER
16 #define INC_SOLVER
17
18 #include "SystemMatrix.h"
19 #include "performance.h"
20 #include "Functions.h"
21
22 #define PASO_TRACE
23 /* 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 #define SOLVER_NEGATIVE_NORM_ERROR -11
30 #define SOLVER_DIVERGENCE -12
31
32 #define TOLERANCE_FOR_SCALARS (double)(0.)
33 #define PASO_ONE (double)(1.0)
34 #define PASO_ZERO (double)(0.0)
35
36 #define MAX_BLOCK_SIZE 3
37
38 /* static double ONE=1.; */
39 /* static double ZERO=0.;*/
40 /*static double TOLERANCE_FOR_SCALARS=0.;*/
41
42 /* jacobi preconditioner */
43
44 typedef struct Paso_Solver_Jacobi {
45 dim_t n_block;
46 dim_t n;
47 double* values;
48 index_t* pivot;
49 } Paso_Solver_Jacobi;
50
51
52 /* ILU preconditioner */
53 struct Paso_Solver_ILU {
54 dim_t n_block;
55 dim_t n;
56 index_t num_colors;
57 index_t* colorOf;
58 index_t* main_iptr;
59 double* factors;
60 Paso_Pattern* pattern;
61 };
62 typedef struct Paso_Solver_ILU Paso_Solver_ILU;
63
64 /* GS preconditioner */
65 struct Paso_Solver_GS {
66 dim_t n_block;
67 dim_t n;
68 index_t num_colors;
69 index_t* colorOf;
70 index_t* main_iptr;
71 double* diag;
72 Paso_SparseMatrix * factors;
73 Paso_Pattern* pattern;
74 dim_t sweeps;
75 double* x_old;
76 };
77 typedef struct Paso_Solver_GS Paso_Solver_GS;
78
79 /* RILU preconditioner */
80 struct Paso_Solver_RILU {
81 dim_t n;
82 dim_t n_block;
83 dim_t n_F;
84 dim_t n_C;
85 double* inv_A_FF;
86 index_t* A_FF_pivot;
87 Paso_SparseMatrix * A_FC;
88 Paso_SparseMatrix * A_CF;
89 index_t* rows_in_F;
90 index_t* rows_in_C;
91 index_t* mask_F;
92 index_t* mask_C;
93 double* x_F;
94 double* b_F;
95 double* x_C;
96 double* b_C;
97 struct Paso_Solver_RILU * RILU_of_Schur;
98 };
99 typedef struct Paso_Solver_RILU Paso_Solver_RILU;
100
101 struct Paso_Solver_Smoother {
102 dim_t ID;
103 Paso_Solver_Jacobi* Jacobi;
104 Paso_Solver_GS* GS;
105 };
106 typedef struct Paso_Solver_Smoother Paso_Solver_Smoother;
107
108 /* AMG preconditioner */
109 struct Paso_Solver_AMG {
110 dim_t n;
111 dim_t level;
112 bool_t coarsest_level;
113 dim_t n_block;
114 dim_t n_F;
115 dim_t n_C;
116
117 Paso_SparseMatrix * A_FF;
118 Paso_SparseMatrix * A_FC;
119 Paso_SparseMatrix * A_CF;
120 Paso_SparseMatrix * W_FC;
121
122 Paso_SparseMatrix * P;
123 Paso_SparseMatrix * R;
124
125 index_t* rows_in_F;
126 index_t* rows_in_C;
127 index_t* mask_F;
128 index_t* mask_C;
129 double* x_F;
130 double* b_F;
131 double* x_C;
132 double* b_C;
133
134 dim_t post_sweeps;
135 dim_t pre_sweeps;
136
137 Paso_SparseMatrix * A;
138 Paso_SparseMatrix * AOffset1;
139 void* solver;
140 Paso_Solver_Smoother* Smoother;
141 struct Paso_Solver_AMG * AMG_of_Coarse;
142 };
143 typedef struct Paso_Solver_AMG Paso_Solver_AMG;
144
145
146 /* AMLI preconditioner */
147 struct Paso_Solver_AMLI {
148 dim_t n;
149 dim_t level;
150 bool_t coarsest_level;
151 dim_t n_block;
152 dim_t n_F;
153 dim_t n_C;
154 double* inv_A_FF;
155 index_t* A_FF_pivot;
156 Paso_SparseMatrix * A_FC;
157 Paso_SparseMatrix * A_CF;
158 index_t* rows_in_F;
159 index_t* rows_in_C;
160 index_t* mask_F;
161 index_t* mask_C;
162 double* x_F;
163 double* b_F;
164 double* x_C;
165 double* b_C;
166
167 dim_t post_sweeps;
168 dim_t pre_sweeps;
169
170 Paso_SparseMatrix * A;
171 Paso_SparseMatrix * AOffset1;
172 void* solver;
173 Paso_Solver_Jacobi* GS;
174 struct Paso_Solver_AMLI * AMLI_of_Schur;
175 };
176 typedef struct Paso_Solver_AMLI Paso_Solver_AMLI;
177
178
179 /* AMLI preconditioner on blocks*/
180 struct Paso_Solver_AMLI_System {
181 dim_t block_size;
182 Paso_SparseMatrix *block[MAX_BLOCK_SIZE];
183 Paso_Solver_AMLI *amliblock[MAX_BLOCK_SIZE];
184 };
185 typedef struct Paso_Solver_AMLI_System Paso_Solver_AMLI_System;
186
187
188 /* AMG preconditioner on blocks*/
189 struct Paso_Solver_AMG_System {
190 dim_t block_size;
191 Paso_SparseMatrix *block[MAX_BLOCK_SIZE];
192 Paso_Solver_AMG *amgblock[MAX_BLOCK_SIZE];
193 };
194 typedef struct Paso_Solver_AMG_System Paso_Solver_AMG_System;
195
196 /* general preconditioner interface */
197
198 typedef struct Paso_Solver_Preconditioner {
199 dim_t type;
200 /* jacobi preconditioner */
201 Paso_Solver_Jacobi* jacobi;
202 /* ilu preconditioner */
203 Paso_Solver_ILU* ilu;
204 /* rilu preconditioner */
205 Paso_Solver_RILU* rilu;
206 /* Gauss-Seidel preconditioner */
207 Paso_Solver_GS* gs;
208 /* amg preconditioner */
209 Paso_Solver_AMG* amg;
210 /* amg on System */
211 Paso_Solver_AMG_System* amgSystem;
212 /* amg preconditioner */
213 Paso_Solver_AMLI* amli;
214 /* amg on System */
215 Paso_Solver_AMLI_System* amliSystem;
216
217 } Paso_Solver_Preconditioner;
218
219 void Paso_Solver(Paso_SystemMatrix*,double*,double*,Paso_Options*,Paso_Performance* pp);
220 void Paso_Solver_free(Paso_SystemMatrix*);
221 err_t Paso_Solver_BiCGStab( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
222 err_t Paso_Solver_PCG( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
223 err_t Paso_Solver_TFQMR( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
224 err_t Paso_Solver_MINRES( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
225 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);
226 void Paso_Preconditioner_free(Paso_Solver_Preconditioner*);
227 void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options);
228 void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double*,double*);
229 void Paso_Solver_applyBlockDiagonalMatrix(dim_t n_block,dim_t n,double* D,index_t* pivot,double* x,double* b);
230
231 void Paso_Solver_ILU_free(Paso_Solver_ILU * in);
232 Paso_Solver_ILU* Paso_Solver_getILU(Paso_SparseMatrix * A_p,bool_t verbose);
233 void Paso_Solver_solveILU(Paso_Solver_ILU * ilu, double * x, double * b);
234
235 void Paso_Solver_GS_free(Paso_Solver_GS * in);
236 Paso_Solver_GS* Paso_Solver_getGS(Paso_SparseMatrix * A_p,bool_t verbose);
237 void Paso_Solver_solveGS(Paso_Solver_GS * gs, double * x, double * b);
238
239 void Paso_Solver_RILU_free(Paso_Solver_RILU * in);
240 Paso_Solver_RILU* Paso_Solver_getRILU(Paso_SparseMatrix * A_p,bool_t verbose);
241 void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b);
242
243 void Paso_Solver_AMG_System_free(Paso_Solver_AMG_System * in);
244 void Paso_Solver_AMG_free(Paso_Solver_AMG * in);
245 Paso_Solver_AMG* Paso_Solver_getAMG(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options);
246 void Paso_Solver_solveAMG(Paso_Solver_AMG * amg, double * x, double * b);
247
248 void Paso_Solver_AMLI_System_free(Paso_Solver_AMLI_System * in);
249 void Paso_Solver_AMLI_free(Paso_Solver_AMLI * in);
250 Paso_Solver_AMLI* Paso_Solver_getAMLI(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options);
251 void Paso_Solver_solveAMLI(Paso_Solver_AMLI * amli, double * x, double * b);
252
253 void Paso_Solver_updateIncompleteSchurComplement(Paso_SparseMatrix* A_CC, Paso_SparseMatrix *A_CF,double* invA_FF,index_t* A_FF_pivot, Paso_SparseMatrix *A_FC);
254 Paso_Solver_Jacobi* Paso_Solver_getJacobi(Paso_SparseMatrix * A_p);
255 void Paso_Solver_solveJacobi(Paso_Solver_Jacobi * prec, double * x, double * b);
256 void Paso_Solver_Jacobi_free(Paso_Solver_Jacobi * in);
257
258 err_t Paso_Solver_GMRES2(Paso_Function * F, const double* f0, const double* x0, double * x, dim_t *iter, double* tolerance, Paso_Performance* pp);
259 err_t Paso_Solver_NewtonGMRES(Paso_Function *F, double *x, Paso_Options* options, Paso_Performance* pp);
260
261 Paso_Function * Paso_Function_LinearSystem_alloc(Paso_SystemMatrix* A, double* b, Paso_Options* options);
262 err_t Paso_Function_LinearSystem_call(Paso_Function * F,double* value, const double* arg, Paso_Performance *pp);
263 void Paso_Function_LinearSystem_free(Paso_Function * F);
264 err_t Paso_Function_LinearSystem_setInitialGuess(Paso_SystemMatrix* A, double* x, Paso_Performance *pp);
265
266 #endif /* #ifndef INC_SOLVER */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26