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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3094 - (hide annotations)
Fri Aug 13 08:38:06 2010 UTC (9 years ago) by gross
File MIME type: text/plain
File size: 8956 byte(s)
The MPI and sequational GAUSS_SEIDEL have been merged.
The couring and main diagonal pointer is now manged by the patternm which means that they are calculated once only even if the preconditioner is deleted.



1 ksteube 1312
2     /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * 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 gross 2987 #define SOLVER_DIVERGENCE -12
31 jgs 150
32 jfenwick 1974 #define TOLERANCE_FOR_SCALARS (double)(0.)
33     #define PASO_ONE (double)(1.0)
34     #define PASO_ZERO (double)(0.0)
35 artak 1787
36 artak 2662 #define MAX_BLOCK_SIZE 3
37    
38 jfenwick 1974 /* static double ONE=1.; */
39     /* static double ZERO=0.;*/
40     /*static double TOLERANCE_FOR_SCALARS=0.;*/
41 jgs 150
42 artak 1819 /* jacobi preconditioner */
43    
44     typedef struct Paso_Solver_Jacobi {
45     double* values;
46     index_t* pivot;
47     } Paso_Solver_Jacobi;
48    
49 gross 3094 /* GS preconditioner */
50     typedef struct Paso_Solver_LocalGS {
51     double* diag;
52     index_t* pivot;
53     dim_t sweeps;
54     } Paso_Solver_LocalGS;
55 artak 1819
56 gross 3094 typedef struct Paso_Solver_GS {
57     Paso_Solver_LocalGS* localGS;
58     bool_t is_local;
59     } Paso_Solver_GS;
60    
61    
62    
63     /*===============================================*/
64 jgs 150 /* ILU preconditioner */
65     struct Paso_Solver_ILU {
66 gross 431 double* factors;
67 jgs 150 };
68     typedef struct Paso_Solver_ILU Paso_Solver_ILU;
69    
70 artak 1819
71 lgao 3051
72    
73 gross 430 /* RILU preconditioner */
74     struct Paso_Solver_RILU {
75     dim_t n;
76     dim_t n_block;
77     dim_t n_F;
78     dim_t n_C;
79     double* inv_A_FF;
80     index_t* A_FF_pivot;
81 ksteube 1312 Paso_SparseMatrix * A_FC;
82     Paso_SparseMatrix * A_CF;
83 gross 430 index_t* rows_in_F;
84     index_t* rows_in_C;
85     index_t* mask_F;
86     index_t* mask_C;
87     double* x_F;
88     double* b_F;
89     double* x_C;
90     double* b_C;
91     struct Paso_Solver_RILU * RILU_of_Schur;
92     };
93     typedef struct Paso_Solver_RILU Paso_Solver_RILU;
94 jgs 150
95 artak 2828 struct Paso_Solver_Smoother {
96     dim_t ID;
97     Paso_Solver_Jacobi* Jacobi;
98 gross 3094 Paso_Solver_LocalGS* GS;
99 artak 2828 };
100     typedef struct Paso_Solver_Smoother Paso_Solver_Smoother;
101    
102 artak 1842 /* AMG preconditioner */
103     struct Paso_Solver_AMG {
104     dim_t n;
105 artak 1890 dim_t level;
106 artak 2524 bool_t coarsest_level;
107 artak 1842 dim_t n_block;
108     dim_t n_F;
109     dim_t n_C;
110 artak 2760
111     Paso_SparseMatrix * A_FF;
112     Paso_SparseMatrix * A_FC;
113     Paso_SparseMatrix * A_CF;
114     Paso_SparseMatrix * W_FC;
115    
116     Paso_SparseMatrix * P;
117     Paso_SparseMatrix * R;
118    
119     index_t* rows_in_F;
120     index_t* rows_in_C;
121     index_t* mask_F;
122     index_t* mask_C;
123     double* x_F;
124     double* b_F;
125     double* x_C;
126     double* b_C;
127 artak 2803
128     dim_t post_sweeps;
129     dim_t pre_sweeps;
130    
131 artak 2760 Paso_SparseMatrix * A;
132     Paso_SparseMatrix * AOffset1;
133 artak 3011 Paso_SparseMatrix * AUnrolled;
134 artak 2760 void* solver;
135 artak 2828 Paso_Solver_Smoother* Smoother;
136 artak 2760 struct Paso_Solver_AMG * AMG_of_Coarse;
137     };
138     typedef struct Paso_Solver_AMG Paso_Solver_AMG;
139    
140    
141     /* AMLI preconditioner */
142     struct Paso_Solver_AMLI {
143     dim_t n;
144     dim_t level;
145     bool_t coarsest_level;
146     dim_t n_block;
147     dim_t n_F;
148     dim_t n_C;
149 artak 1842 double* inv_A_FF;
150     index_t* A_FF_pivot;
151     Paso_SparseMatrix * A_FC;
152     Paso_SparseMatrix * A_CF;
153     index_t* rows_in_F;
154     index_t* rows_in_C;
155     index_t* mask_F;
156     index_t* mask_C;
157     double* x_F;
158     double* b_F;
159     double* x_C;
160     double* b_C;
161 artak 2807
162     dim_t post_sweeps;
163     dim_t pre_sweeps;
164    
165 artak 1890 Paso_SparseMatrix * A;
166 artak 2711 Paso_SparseMatrix * AOffset1;
167 gross 2551 void* solver;
168 artak 2112 Paso_Solver_Jacobi* GS;
169 artak 2760 struct Paso_Solver_AMLI * AMLI_of_Schur;
170 artak 1842 };
171 artak 2760 typedef struct Paso_Solver_AMLI Paso_Solver_AMLI;
172 gross 430
173 artak 2760
174     /* AMLI preconditioner on blocks*/
175     struct Paso_Solver_AMLI_System {
176     dim_t block_size;
177     Paso_SparseMatrix *block[MAX_BLOCK_SIZE];
178     Paso_Solver_AMLI *amliblock[MAX_BLOCK_SIZE];
179     };
180     typedef struct Paso_Solver_AMLI_System Paso_Solver_AMLI_System;
181    
182    
183 artak 2659 /* AMG preconditioner on blocks*/
184     struct Paso_Solver_AMG_System {
185 artak 2662 dim_t block_size;
186     Paso_SparseMatrix *block[MAX_BLOCK_SIZE];
187     Paso_Solver_AMG *amgblock[MAX_BLOCK_SIZE];
188 artak 2659 };
189     typedef struct Paso_Solver_AMG_System Paso_Solver_AMG_System;
190 jgs 150
191     /* general preconditioner interface */
192    
193     typedef struct Paso_Solver_Preconditioner {
194     dim_t type;
195 gross 3094
196 jgs 150 /* jacobi preconditioner */
197     Paso_Solver_Jacobi* jacobi;
198 gross 3094 /* Gauss-Seidel preconditioner */
199     Paso_Solver_GS* gs;
200    
201 jgs 150 /* ilu preconditioner */
202     Paso_Solver_ILU* ilu;
203 artak 1819 /* rilu preconditioner */
204 gross 430 Paso_Solver_RILU* rilu;
205 artak 1842 /* amg preconditioner */
206     Paso_Solver_AMG* amg;
207 artak 2659 /* amg on System */
208     Paso_Solver_AMG_System* amgSystem;
209 artak 2760 /* amg preconditioner */
210     Paso_Solver_AMLI* amli;
211     /* amg on System */
212     Paso_Solver_AMLI_System* amliSystem;
213 artak 2659
214 jgs 150 } Paso_Solver_Preconditioner;
215    
216 gross 584 void Paso_Solver(Paso_SystemMatrix*,double*,double*,Paso_Options*,Paso_Performance* pp);
217 jgs 150 void Paso_Solver_free(Paso_SystemMatrix*);
218 ksteube 1312 err_t Paso_Solver_BiCGStab( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
219     err_t Paso_Solver_PCG( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
220 artak 1703 err_t Paso_Solver_TFQMR( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
221 artak 1862 err_t Paso_Solver_MINRES( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
222 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);
223 gross 3094 err_t Paso_Solver_GMRES2(Paso_Function * F, const double* f0, const double* x0, double * x, dim_t *iter, double* tolerance, Paso_Performance* pp);
224    
225     err_t Paso_Solver_NewtonGMRES(Paso_Function *F, double *x, Paso_Options* options, Paso_Performance* pp);
226     Paso_Function * Paso_Function_LinearSystem_alloc(Paso_SystemMatrix* A, double* b, Paso_Options* options);
227     err_t Paso_Function_LinearSystem_call(Paso_Function * F,double* value, const double* arg, Paso_Performance *pp);
228     void Paso_Function_LinearSystem_free(Paso_Function * F);
229     err_t Paso_Function_LinearSystem_setInitialGuess(Paso_SystemMatrix* A, double* x, Paso_Performance *pp);
230    
231 jgs 150 void Paso_Preconditioner_free(Paso_Solver_Preconditioner*);
232     void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options);
233     void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double*,double*);
234     void Paso_Solver_applyBlockDiagonalMatrix(dim_t n_block,dim_t n,double* D,index_t* pivot,double* x,double* b);
235 gross 431
236 gross 3094 Paso_Solver_Jacobi* Paso_Solver_getJacobi(Paso_SystemMatrix * A_p);
237     void Paso_Solver_solveJacobi(Paso_SystemMatrix * A_p, Paso_Solver_Jacobi * prec, double * x, double * b);
238     void Paso_Solver_solveLocalJacobi(Paso_SparseMatrix * A_p, Paso_Solver_Jacobi * prec, double * x, double * b);
239     void Paso_Solver_Jacobi_free(Paso_Solver_Jacobi * in);
240     Paso_Solver_Jacobi* Paso_Solver_getLocalJacobi(Paso_SparseMatrix * A_p);
241 gross 431
242 artak 1819 void Paso_Solver_GS_free(Paso_Solver_GS * in);
243 gross 3094 void Paso_Solver_LocalGS_free(Paso_Solver_LocalGS * in);
244     Paso_Solver_GS* Paso_Solver_getGS(Paso_SystemMatrix * A_p, dim_t sweeps, bool_t is_local, bool_t verbose);
245     Paso_Solver_LocalGS* Paso_Solver_getLocalGS(Paso_SparseMatrix * A_p, dim_t sweeps, bool_t verbose);
246     void Paso_Solver_solveGS(Paso_SystemMatrix* A, Paso_Solver_GS * gs, double * x, const double * b);
247     void Paso_Solver_solveLocalGS(Paso_SparseMatrix* A, Paso_Solver_LocalGS * gs, double * x, const double * b);
248     void Paso_Solver_solveLocalGS_sequential(Paso_SparseMatrix* A, Paso_Solver_LocalGS * gs, double * x, const double * b);
249     void Paso_Solver_solveLocalGS_tiled(Paso_SparseMatrix* A, Paso_Solver_LocalGS * gs, double * x, const double * b);
250     void Paso_Solver_solveLocalGS_colored(Paso_SparseMatrix* A, Paso_Solver_LocalGS * gs, double * x, const double * b);
251 artak 1819
252 gross 3094 /*******************************************/
253     void Paso_Solver_ILU_free(Paso_Solver_ILU * in);
254     Paso_Solver_ILU* Paso_Solver_getILU(Paso_SparseMatrix * A_p,bool_t verbose);
255     void Paso_Solver_solveILU(Paso_SparseMatrix * A, Paso_Solver_ILU * ilu, double * x, const double * b);
256 lgao 3051
257 gross 431 void Paso_Solver_RILU_free(Paso_Solver_RILU * in);
258 ksteube 1312 Paso_Solver_RILU* Paso_Solver_getRILU(Paso_SparseMatrix * A_p,bool_t verbose);
259 gross 431 void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b);
260    
261 artak 2659 void Paso_Solver_AMG_System_free(Paso_Solver_AMG_System * in);
262 artak 1842 void Paso_Solver_AMG_free(Paso_Solver_AMG * in);
263 artak 2520 Paso_Solver_AMG* Paso_Solver_getAMG(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options);
264 artak 1842 void Paso_Solver_solveAMG(Paso_Solver_AMG * amg, double * x, double * b);
265    
266 artak 2760 void Paso_Solver_AMLI_System_free(Paso_Solver_AMLI_System * in);
267     void Paso_Solver_AMLI_free(Paso_Solver_AMLI * in);
268     Paso_Solver_AMLI* Paso_Solver_getAMLI(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options);
269     void Paso_Solver_solveAMLI(Paso_Solver_AMLI * amli, double * x, double * b);
270    
271 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);
272 jgs 150
273 gross 1476
274    
275 gross 3094
276    
277    
278 jgs 150 #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