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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2662 - (show annotations)
Tue Sep 15 03:05:23 2009 UTC (10 years ago) by artak
File MIME type: text/plain
File size: 6447 byte(s)
Migrating to block_sizes greather than 3 made easy.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 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
31 #define TOLERANCE_FOR_SCALARS (double)(0.)
32 #define PASO_ONE (double)(1.0)
33 #define PASO_ZERO (double)(0.0)
34
35 #define MAX_BLOCK_SIZE 3
36
37 /* static double ONE=1.; */
38 /* static double ZERO=0.;*/
39 /*static double TOLERANCE_FOR_SCALARS=0.;*/
40
41 /* jacobi preconditioner */
42
43 typedef struct Paso_Solver_Jacobi {
44 dim_t n_block;
45 dim_t n;
46 double* values;
47 index_t* pivot;
48 } Paso_Solver_Jacobi;
49
50
51 /* ILU preconditioner */
52 struct Paso_Solver_ILU {
53 dim_t n_block;
54 dim_t n;
55 index_t num_colors;
56 index_t* colorOf;
57 index_t* main_iptr;
58 double* factors;
59 Paso_Pattern* pattern;
60 };
61 typedef struct Paso_Solver_ILU Paso_Solver_ILU;
62
63 /* GS preconditioner */
64 struct Paso_Solver_GS {
65 dim_t n_block;
66 dim_t n;
67 index_t num_colors;
68 index_t* colorOf;
69 index_t* main_iptr;
70 double* diag;
71 Paso_SparseMatrix * factors;
72 Paso_Pattern* pattern;
73 dim_t sweeps;
74 double* x_old;
75 };
76 typedef struct Paso_Solver_GS Paso_Solver_GS;
77
78 /* RILU preconditioner */
79 struct Paso_Solver_RILU {
80 dim_t n;
81 dim_t n_block;
82 dim_t n_F;
83 dim_t n_C;
84 double* inv_A_FF;
85 index_t* A_FF_pivot;
86 Paso_SparseMatrix * A_FC;
87 Paso_SparseMatrix * A_CF;
88 index_t* rows_in_F;
89 index_t* rows_in_C;
90 index_t* mask_F;
91 index_t* mask_C;
92 double* x_F;
93 double* b_F;
94 double* x_C;
95 double* b_C;
96 struct Paso_Solver_RILU * RILU_of_Schur;
97 };
98 typedef struct Paso_Solver_RILU Paso_Solver_RILU;
99
100 /* AMG preconditioner */
101 struct Paso_Solver_AMG {
102 dim_t n;
103 dim_t level;
104 bool_t coarsest_level;
105 dim_t n_block;
106 dim_t n_F;
107 dim_t n_C;
108 double* inv_A_FF;
109 index_t* A_FF_pivot;
110 Paso_SparseMatrix * A_FC;
111 Paso_SparseMatrix * A_CF;
112 index_t* rows_in_F;
113 index_t* rows_in_C;
114 index_t* mask_F;
115 index_t* mask_C;
116 double* x_F;
117 double* b_F;
118 double* x_C;
119 double* b_C;
120 Paso_SparseMatrix * A;
121 void* solver;
122 Paso_Solver_Jacobi* GS;
123 struct Paso_Solver_AMG * AMG_of_Schur;
124 };
125 typedef struct Paso_Solver_AMG Paso_Solver_AMG;
126
127 /* AMG preconditioner on blocks*/
128 struct Paso_Solver_AMG_System {
129 dim_t block_size;
130 Paso_SparseMatrix *block[MAX_BLOCK_SIZE];
131 Paso_Solver_AMG *amgblock[MAX_BLOCK_SIZE];
132 };
133 typedef struct Paso_Solver_AMG_System Paso_Solver_AMG_System;
134
135
136 /* general preconditioner interface */
137
138 typedef struct Paso_Solver_Preconditioner {
139 dim_t type;
140 /* jacobi preconditioner */
141 Paso_Solver_Jacobi* jacobi;
142 /* ilu preconditioner */
143 Paso_Solver_ILU* ilu;
144 /* rilu preconditioner */
145 Paso_Solver_RILU* rilu;
146 /* Gauss-Seidel preconditioner */
147 Paso_Solver_GS* gs;
148 /* amg preconditioner */
149 Paso_Solver_AMG* amg;
150 /* amg on System */
151 Paso_Solver_AMG_System* amgSystem;
152
153 } Paso_Solver_Preconditioner;
154
155 void Paso_Solver(Paso_SystemMatrix*,double*,double*,Paso_Options*,Paso_Performance* pp);
156 void Paso_Solver_free(Paso_SystemMatrix*);
157 err_t Paso_Solver_BiCGStab( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
158 err_t Paso_Solver_PCG( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
159 err_t Paso_Solver_TFQMR( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
160 err_t Paso_Solver_MINRES( Paso_SystemMatrix * A, double* B, double * X, dim_t *iter, double * tolerance, Paso_Performance* pp);
161 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);
162 void Paso_Preconditioner_free(Paso_Solver_Preconditioner*);
163 void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options);
164 void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double*,double*);
165 void Paso_Solver_applyBlockDiagonalMatrix(dim_t n_block,dim_t n,double* D,index_t* pivot,double* x,double* b);
166
167 void Paso_Solver_ILU_free(Paso_Solver_ILU * in);
168 Paso_Solver_ILU* Paso_Solver_getILU(Paso_SparseMatrix * A_p,bool_t verbose);
169 void Paso_Solver_solveILU(Paso_Solver_ILU * ilu, double * x, double * b);
170
171 void Paso_Solver_GS_free(Paso_Solver_GS * in);
172 Paso_Solver_GS* Paso_Solver_getGS(Paso_SparseMatrix * A_p,bool_t verbose);
173 void Paso_Solver_solveGS(Paso_Solver_GS * gs, double * x, double * b);
174
175 void Paso_Solver_RILU_free(Paso_Solver_RILU * in);
176 Paso_Solver_RILU* Paso_Solver_getRILU(Paso_SparseMatrix * A_p,bool_t verbose);
177 void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b);
178
179 void Paso_Solver_AMG_System_free(Paso_Solver_AMG_System * in);
180 void Paso_Solver_AMG_free(Paso_Solver_AMG * in);
181 Paso_Solver_AMG* Paso_Solver_getAMG(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options);
182 void Paso_Solver_solveAMG(Paso_Solver_AMG * amg, double * x, double * b);
183
184 void Paso_Solver_updateIncompleteSchurComplement(Paso_SparseMatrix* A_CC, Paso_SparseMatrix *A_CF,double* invA_FF,index_t* A_FF_pivot, Paso_SparseMatrix *A_FC);
185 Paso_Solver_Jacobi* Paso_Solver_getJacobi(Paso_SparseMatrix * A_p);
186 void Paso_Solver_solveJacobi(Paso_Solver_Jacobi * prec, double * x, double * b);
187 void Paso_Solver_Jacobi_free(Paso_Solver_Jacobi * in);
188
189 err_t Paso_Solver_GMRES2(Paso_Function * F, const double* f0, const double* x0, double * x, dim_t *iter, double* tolerance, Paso_Performance* pp);
190 err_t Paso_Solver_NewtonGMRES(Paso_Function *F, double *x, Paso_Options* options, Paso_Performance* pp);
191
192 Paso_Function * Paso_Function_LinearSystem_alloc(Paso_SystemMatrix* A, double* b, Paso_Options* options);
193 err_t Paso_Function_LinearSystem_call(Paso_Function * F,double* value, const double* arg, Paso_Performance *pp);
194 void Paso_Function_LinearSystem_free(Paso_Function * F);
195 err_t Paso_Function_LinearSystem_setInitialGuess(Paso_SystemMatrix* A, double* x, Paso_Performance *pp);
196
197 #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