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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3793 - (hide annotations)
Wed Feb 1 07:39:43 2012 UTC (7 years, 9 months ago) by gross
File MIME type: text/plain
File size: 11049 byte(s)
new implementation of FCT solver with some modifications to the python interface
1 gross 3120
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_PRECS
16     #define INC_PRECS
17    
18     #include "SystemMatrix.h"
19     #include "performance.h"
20 lgao 3508 #include "BOOMERAMG.h"
21 gross 3120
22 gross 3793 #define PRECONDITIONER_NO_ERROR 0
23     #define PRECONDITIONER_MAXITER_REACHED 1
24     #define PRECONDITIONER_INPUT_ERROR -1
25     #define PRECONDITIONER_MEMORY_ERROR -9
26     #define PRECONDITIONER_BREAKDOWN -10
27     #define PRECONDITIONER_NEGATIVE_NORM_ERROR -11
28     #define PRECONDITIONER_DIVERGENCE -12
29 gross 3120
30 gross 3793
31 gross 3283 #define PASO_AMG_UNDECIDED -1
32     #define PASO_AMG_IN_F 0
33     #define PASO_AMG_IN_C 1
34    
35 gross 3158 /* GAUSS SEIDEL & Jacobi */
36     typedef struct Paso_Preconditioner_LocalSmoother {
37     bool_t Jacobi;
38 gross 3120 double* diag;
39     double* buffer;
40     index_t* pivot;
41 gross 3158 } Paso_Preconditioner_LocalSmoother;
42 gross 3120
43 gross 3158 typedef struct Paso_Preconditioner_Smoother {
44     Paso_Preconditioner_LocalSmoother* localSmoother;
45 gross 3120 bool_t is_local;
46 gross 3158 } Paso_Preconditioner_Smoother;
47 gross 3120
48 gross 3158 void Paso_Preconditioner_Smoother_free(Paso_Preconditioner_Smoother * in);
49     void Paso_Preconditioner_LocalSmoother_free(Paso_Preconditioner_LocalSmoother * in);
50 gross 3120
51 gross 3793
52 gross 3158 Paso_Preconditioner_Smoother* Paso_Preconditioner_Smoother_alloc(Paso_SystemMatrix * A_p, const bool_t jacobi, const bool_t is_local, const bool_t verbose);
53     Paso_Preconditioner_LocalSmoother* Paso_Preconditioner_LocalSmoother_alloc(Paso_SparseMatrix * A_p,const bool_t jacobi, const bool_t verbose);
54 gross 3120
55 gross 3159 void Paso_Preconditioner_Smoother_solve(Paso_SystemMatrix* A, Paso_Preconditioner_Smoother * gs, double * x, const double * b, const dim_t sweeps, const bool_t x_is_initial);
56     void Paso_Preconditioner_LocalSmoother_solve(Paso_SparseMatrix* A, Paso_Preconditioner_LocalSmoother * gs, double * x, const double * b, const dim_t sweeps, const bool_t x_is_initial);
57 gross 3793 err_t Paso_Preconditioner_Smoother_solve_byTolerance(Paso_SystemMatrix* A, Paso_Preconditioner_Smoother * gs, double * x, const double * b, const double tol, dim_t *sweeps, const bool_t x_is_initial);
58 gross 3158
59     void Paso_Preconditioner_LocalSmoother_Sweep(Paso_SparseMatrix* A, Paso_Preconditioner_LocalSmoother * gs, double * x);
60     void Paso_Preconditioner_LocalSmoother_Sweep_sequential(Paso_SparseMatrix* A, Paso_Preconditioner_LocalSmoother * gs, double * x);
61     void Paso_Preconditioner_LocalSmoother_Sweep_tiled(Paso_SparseMatrix* A, Paso_Preconditioner_LocalSmoother * gs, double * x);
62     void Paso_Preconditioner_LocalSmoother_Sweep_colored(Paso_SparseMatrix* A, Paso_Preconditioner_LocalSmoother * gs, double * x);
63    
64 gross 3193
65 gross 3793
66 gross 3441 /* Local preconditioner */
67     struct Paso_Preconditioner_AMG {
68     dim_t level;
69     dim_t n;
70     dim_t n_F;
71     dim_t n_block;
72     Paso_SystemMatrix * A_C; /* coarse level matrix */
73     Paso_SystemMatrix * P; /* prolongation n x n_C*/
74     Paso_SystemMatrix * R; /* restriction n_C x n */
75    
76     Paso_Preconditioner_Smoother* Smoother;
77     dim_t post_sweeps;
78     dim_t pre_sweeps;
79     index_t reordering; /* applied reordering in direct solver */
80     dim_t refinements; /* number of refinements in direct solver (typically =0) */
81     double* r; /* buffer for residual */
82     double* x_C; /* solution of coarse level system */
83     double* b_C; /* right hand side of coarse level system */
84     struct Paso_Preconditioner_AMG * AMG_C;
85     };
86     typedef struct Paso_Preconditioner_AMG Paso_Preconditioner_AMG;
87    
88     void Paso_Preconditioner_AMG_free(Paso_Preconditioner_AMG * in);
89     Paso_Preconditioner_AMG* Paso_Preconditioner_AMG_alloc(Paso_SystemMatrix * A_p,dim_t level,Paso_Options* options);
90     void Paso_Preconditioner_AMG_solve(Paso_SystemMatrix* A, Paso_Preconditioner_AMG * amg, double * x, double * b);
91 gross 3445 void Paso_Preconditioner_AMG_setStrongConnections(Paso_SystemMatrix* A, dim_t *degree_S, index_t* offset_S, index_t *S, const double theta, const double tau);
92     void Paso_Preconditioner_AMG_setStrongConnections_Block(Paso_SystemMatrix* A, dim_t *degree_S, index_t* offset_S, index_t *S, const double theta, const double tau);
93 gross 3446 double Paso_Preconditioner_AMG_getCoarseLevelSparsity(const Paso_Preconditioner_AMG * in);
94     dim_t Paso_Preconditioner_AMG_getNumCoarseUnknwons(const Paso_Preconditioner_AMG * in);
95     index_t Paso_Preconditioner_AMG_getMaxLevel(const Paso_Preconditioner_AMG * in);
96 gross 3482 void Paso_Preconditioner_AMG_transposeStrongConnections(const dim_t n, const dim_t* degree_S, const index_t* offset_S, const index_t* S, const dim_t nT, dim_t *degree_ST, index_t* offset_ST,index_t* ST);
97     void Paso_Preconditioner_AMG_CIJPCoarsening(const dim_t n, const dim_t my_n, index_t*split_marker,
98     const dim_t* degree_S, const index_t* offset_S, const index_t* S,
99     const dim_t* degree_ST, const index_t* offset_ST, const index_t* ST,
100     Paso_Connector* col_connector, Paso_Distribution* col_dist);
101 caltinay 3642
102 gross 3441 /* Local AMG preconditioner */
103 gross 3193 struct Paso_Preconditioner_LocalAMG {
104 gross 3283 dim_t level;
105 gross 3193 dim_t n;
106 gross 3283 dim_t n_F;
107 gross 3193 dim_t n_block;
108 gross 3482
109 gross 3283 Paso_SparseMatrix * A_C; /* coarse level matrix */
110     Paso_SparseMatrix * P; /* prolongation n x n_C*/
111     Paso_SparseMatrix * R; /* restriction n_C x n */
112    
113     Paso_Preconditioner_LocalSmoother* Smoother;
114 gross 3193 dim_t post_sweeps;
115     dim_t pre_sweeps;
116 gross 3283 index_t reordering; /* applied reordering in direct solver */
117     dim_t refinements; /* number of refinements in direct solver (typically =0) */
118     double* r; /* buffer for residual */
119     double* x_C; /* solution of coarse level system */
120     double* b_C; /* right hand side of coarse level system */
121     struct Paso_Preconditioner_LocalAMG * AMG_C;
122 gross 3193 };
123     typedef struct Paso_Preconditioner_LocalAMG Paso_Preconditioner_LocalAMG;
124    
125     void Paso_Preconditioner_LocalAMG_free(Paso_Preconditioner_LocalAMG * in);
126     Paso_Preconditioner_LocalAMG* Paso_Preconditioner_LocalAMG_alloc(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options);
127 gross 3283 void Paso_Preconditioner_LocalAMG_solve(Paso_SparseMatrix* A, Paso_Preconditioner_LocalAMG * amg, double * x, double * b);
128 gross 3441
129     void Paso_Preconditioner_LocalAMG_RungeStuebenSearch(const dim_t n, const index_t* offset, const dim_t* degree, const index_t* S, index_t*split_marker, const bool_t usePanel);
130     void Paso_Preconditioner_LocalAMG_setStrongConnections_Block(Paso_SparseMatrix* A, dim_t *degree, index_t *S, const double theta, const double tau);
131     void Paso_Preconditioner_LocalAMG_setStrongConnections(Paso_SparseMatrix* A, dim_t *degree, index_t *S, const double theta, const double tau);
132     Paso_SparseMatrix* Paso_Preconditioner_LocalAMG_getProlongation(Paso_SparseMatrix* A_p, const index_t* offset_S, const dim_t* degree_S, const index_t* S, const dim_t n_C, const index_t* counter_C, const index_t interpolation_method);
133     void Paso_Preconditioner_LocalAMG_setDirectProlongation_Block(Paso_SparseMatrix* P_p, const Paso_SparseMatrix* A_p, const index_t *counter_C);
134     void Paso_Preconditioner_LocalAMG_setDirectProlongation(Paso_SparseMatrix* P_p, const Paso_SparseMatrix* A_p, const index_t *counter_C);
135     void Paso_Preconditioner_LocalAMG_setClassicProlongation(Paso_SparseMatrix* P_p, Paso_SparseMatrix* A_p, const index_t* offset_S, const dim_t* degree_S, const index_t* S, const index_t *counter_C);
136     void Paso_Preconditioner_LocalAMG_setClassicProlongation_Block(Paso_SparseMatrix* P_p, Paso_SparseMatrix* A_p, const index_t* offset_S, const dim_t* degree_S, const index_t* S, const index_t *counter_C);
137 gross 3402 index_t Paso_Preconditioner_LocalAMG_getMaxLevel(const Paso_Preconditioner_LocalAMG * in);
138     double Paso_Preconditioner_LocalAMG_getCoarseLevelSparsity(const Paso_Preconditioner_LocalAMG * in);
139     dim_t Paso_Preconditioner_LocalAMG_getNumCoarseUnknwons(const Paso_Preconditioner_LocalAMG * in);
140 gross 3441 void Paso_Preconditioner_LocalAMG_enforceFFConnectivity(const dim_t n, const index_t* offset_S, const dim_t* degree_S, const index_t* S, index_t*split_marker);
141 gross 3440
142 gross 3441
143 lgao 3508 struct Paso_Preconditioner_BoomerAMG
144     {
145     Paso_BOOMERAMG_Handler* pt;
146     };
147     typedef struct Paso_Preconditioner_BoomerAMG Paso_Preconditioner_BoomerAMG;
148     void Paso_Preconditioner_BoomerAMG_free(Paso_Preconditioner_BoomerAMG * in);
149     Paso_Preconditioner_BoomerAMG* Paso_Preconditioner_BoomerAMG_alloc(Paso_SystemMatrix * A_p,Paso_Options* options);
150     void Paso_Preconditioner_BoomerAMG_solve(Paso_SystemMatrix* A, Paso_Preconditioner_BoomerAMG * amg, double * x, double * b);
151 gross 3441
152 lgao 3508
153 gross 3446 struct Paso_Preconditioner_AMG_Root
154     {
155     bool_t is_local;
156     Paso_Preconditioner_AMG* amg;
157     Paso_Preconditioner_LocalAMG* localamg;
158 lgao 3508 Paso_Preconditioner_BoomerAMG* boomeramg;
159 gross 3446 dim_t sweeps;
160     Paso_Preconditioner_Smoother* amgsubstitute;
161     };
162     typedef struct Paso_Preconditioner_AMG_Root Paso_Preconditioner_AMG_Root;
163    
164     Paso_Preconditioner_AMG_Root* Paso_Preconditioner_AMG_Root_alloc(Paso_SystemMatrix *A, Paso_Options* options);
165     void Paso_Preconditioner_AMG_Root_free(Paso_Preconditioner_AMG_Root * in);
166     void Paso_Preconditioner_AMG_Root_solve(Paso_SystemMatrix* A, Paso_Preconditioner_AMG_Root * amg, double * x, double * b);
167    
168 gross 3120 /*===============================================*/
169     /* ILU preconditioner */
170     struct Paso_Solver_ILU {
171     double* factors;
172     };
173     typedef struct Paso_Solver_ILU Paso_Solver_ILU;
174    
175    
176    
177     /* RILU preconditioner */
178     struct Paso_Solver_RILU {
179     dim_t n;
180     dim_t n_block;
181     dim_t n_F;
182     dim_t n_C;
183     double* inv_A_FF;
184     index_t* A_FF_pivot;
185     Paso_SparseMatrix * A_FC;
186     Paso_SparseMatrix * A_CF;
187     index_t* rows_in_F;
188     index_t* rows_in_C;
189     index_t* mask_F;
190     index_t* mask_C;
191     double* x_F;
192     double* b_F;
193     double* x_C;
194     double* b_C;
195     struct Paso_Solver_RILU * RILU_of_Schur;
196     };
197     typedef struct Paso_Solver_RILU Paso_Solver_RILU;
198    
199    
200    
201     /* general preconditioner interface */
202    
203 gross 3193 typedef struct Paso_Preconditioner {
204 gross 3120 dim_t type;
205 gross 3158 dim_t sweeps;
206 gross 3120 /* jacobi preconditioner */
207 gross 3158 Paso_Preconditioner_Smoother* jacobi;
208 gross 3120 /* Gauss-Seidel preconditioner */
209 gross 3193 Paso_Preconditioner_Smoother* gs;
210     /* amg preconditioner */
211 gross 3446 Paso_Preconditioner_AMG_Root *amg;
212 gross 3120
213     /* ilu preconditioner */
214     Paso_Solver_ILU* ilu;
215     /* rilu preconditioner */
216     Paso_Solver_RILU* rilu;
217    
218 gross 3193 } Paso_Preconditioner;
219 gross 3120
220 gross 3193 void Paso_Preconditioner_free(Paso_Preconditioner*);
221     Paso_Preconditioner* Paso_Preconditioner_alloc(Paso_SystemMatrix* A,Paso_Options* options);
222     void Paso_Preconditioner_solve(Paso_Preconditioner* prec, Paso_SystemMatrix* A,double*,double*);
223 gross 3120
224    
225     /*******************************************/
226     void Paso_Solver_ILU_free(Paso_Solver_ILU * in);
227     Paso_Solver_ILU* Paso_Solver_getILU(Paso_SparseMatrix * A_p,bool_t verbose);
228     void Paso_Solver_solveILU(Paso_SparseMatrix * A, Paso_Solver_ILU * ilu, double * x, const double * b);
229    
230     void Paso_Solver_RILU_free(Paso_Solver_RILU * in);
231     Paso_Solver_RILU* Paso_Solver_getRILU(Paso_SparseMatrix * A_p,bool_t verbose);
232     void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b);
233    
234     void Paso_Solver_updateIncompleteSchurComplement(Paso_SparseMatrix* A_CC, Paso_SparseMatrix *A_CF,double* invA_FF,index_t* A_FF_pivot, Paso_SparseMatrix *A_FC);
235    
236    
237     #endif /* #ifndef INC_PRECS */

  ViewVC Help
Powered by ViewVC 1.1.26