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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3094 - (show annotations)
Fri Aug 13 08:38:06 2010 UTC (8 years, 11 months 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
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 double* values;
46 index_t* pivot;
47 } Paso_Solver_Jacobi;
48
49 /* GS preconditioner */
50 typedef struct Paso_Solver_LocalGS {
51 double* diag;
52 index_t* pivot;
53 dim_t sweeps;
54 } Paso_Solver_LocalGS;
55
56 typedef struct Paso_Solver_GS {
57 Paso_Solver_LocalGS* localGS;
58 bool_t is_local;
59 } Paso_Solver_GS;
60
61
62
63 /*===============================================*/
64 /* ILU preconditioner */
65 struct Paso_Solver_ILU {
66 double* factors;
67 };
68 typedef struct Paso_Solver_ILU Paso_Solver_ILU;
69
70
71
72
73 /* 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 Paso_SparseMatrix * A_FC;
82 Paso_SparseMatrix * A_CF;
83 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
95 struct Paso_Solver_Smoother {
96 dim_t ID;
97 Paso_Solver_Jacobi* Jacobi;
98 Paso_Solver_LocalGS* GS;
99 };
100 typedef struct Paso_Solver_Smoother Paso_Solver_Smoother;
101
102 /* AMG preconditioner */
103 struct Paso_Solver_AMG {
104 dim_t n;
105 dim_t level;
106 bool_t coarsest_level;
107 dim_t n_block;
108 dim_t n_F;
109 dim_t n_C;
110
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
128 dim_t post_sweeps;
129 dim_t pre_sweeps;
130
131 Paso_SparseMatrix * A;
132 Paso_SparseMatrix * AOffset1;
133 Paso_SparseMatrix * AUnrolled;
134 void* solver;
135 Paso_Solver_Smoother* Smoother;
136 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 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
162 dim_t post_sweeps;
163 dim_t pre_sweeps;
164
165 Paso_SparseMatrix * A;
166 Paso_SparseMatrix * AOffset1;
167 void* solver;
168 Paso_Solver_Jacobi* GS;
169 struct Paso_Solver_AMLI * AMLI_of_Schur;
170 };
171 typedef struct Paso_Solver_AMLI Paso_Solver_AMLI;
172
173
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 /* AMG preconditioner on blocks*/
184 struct Paso_Solver_AMG_System {
185 dim_t block_size;
186 Paso_SparseMatrix *block[MAX_BLOCK_SIZE];
187 Paso_Solver_AMG *amgblock[MAX_BLOCK_SIZE];
188 };
189 typedef struct Paso_Solver_AMG_System Paso_Solver_AMG_System;
190
191 /* general preconditioner interface */
192
193 typedef struct Paso_Solver_Preconditioner {
194 dim_t type;
195
196 /* jacobi preconditioner */
197 Paso_Solver_Jacobi* jacobi;
198 /* Gauss-Seidel preconditioner */
199 Paso_Solver_GS* gs;
200
201 /* ilu preconditioner */
202 Paso_Solver_ILU* ilu;
203 /* rilu preconditioner */
204 Paso_Solver_RILU* rilu;
205 /* amg preconditioner */
206 Paso_Solver_AMG* amg;
207 /* amg on System */
208 Paso_Solver_AMG_System* amgSystem;
209 /* amg preconditioner */
210 Paso_Solver_AMLI* amli;
211 /* amg on System */
212 Paso_Solver_AMLI_System* amliSystem;
213
214 } Paso_Solver_Preconditioner;
215
216 void Paso_Solver(Paso_SystemMatrix*,double*,double*,Paso_Options*,Paso_Performance* pp);
217 void Paso_Solver_free(Paso_SystemMatrix*);
218 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 err_t Paso_Solver_TFQMR( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
221 err_t Paso_Solver_MINRES( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
222 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 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 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
236 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
242 void Paso_Solver_GS_free(Paso_Solver_GS * in);
243 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
252 /*******************************************/
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
257 void Paso_Solver_RILU_free(Paso_Solver_RILU * in);
258 Paso_Solver_RILU* Paso_Solver_getRILU(Paso_SparseMatrix * A_p,bool_t verbose);
259 void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b);
260
261 void Paso_Solver_AMG_System_free(Paso_Solver_AMG_System * in);
262 void Paso_Solver_AMG_free(Paso_Solver_AMG * in);
263 Paso_Solver_AMG* Paso_Solver_getAMG(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options);
264 void Paso_Solver_solveAMG(Paso_Solver_AMG * amg, double * x, double * b);
265
266 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 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
273
274
275
276
277
278 #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