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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3283 - (hide annotations)
Mon Oct 18 22:39:28 2010 UTC (8 years, 11 months ago) by gross
File MIME type: text/plain
File size: 5861 byte(s)
AMG reengineered, BUG is Smoother fixed.


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    
21    
22 gross 3283 #define PASO_AMG_UNDECIDED -1
23     #define PASO_AMG_IN_F 0
24     #define PASO_AMG_IN_C 1
25    
26 gross 3158 /* GAUSS SEIDEL & Jacobi */
27     typedef struct Paso_Preconditioner_LocalSmoother {
28     bool_t Jacobi;
29 gross 3120 double* diag;
30     double* buffer;
31     index_t* pivot;
32 gross 3158 } Paso_Preconditioner_LocalSmoother;
33 gross 3120
34 gross 3158 typedef struct Paso_Preconditioner_Smoother {
35     Paso_Preconditioner_LocalSmoother* localSmoother;
36 gross 3120 bool_t is_local;
37 gross 3158 } Paso_Preconditioner_Smoother;
38 gross 3120
39 gross 3158 void Paso_Preconditioner_Smoother_free(Paso_Preconditioner_Smoother * in);
40     void Paso_Preconditioner_LocalSmoother_free(Paso_Preconditioner_LocalSmoother * in);
41 gross 3120
42 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);
43     Paso_Preconditioner_LocalSmoother* Paso_Preconditioner_LocalSmoother_alloc(Paso_SparseMatrix * A_p,const bool_t jacobi, const bool_t verbose);
44 gross 3120
45 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);
46     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);
47 gross 3158
48     void Paso_Preconditioner_LocalSmoother_Sweep(Paso_SparseMatrix* A, Paso_Preconditioner_LocalSmoother * gs, double * x);
49     void Paso_Preconditioner_LocalSmoother_Sweep_sequential(Paso_SparseMatrix* A, Paso_Preconditioner_LocalSmoother * gs, double * x);
50     void Paso_Preconditioner_LocalSmoother_Sweep_tiled(Paso_SparseMatrix* A, Paso_Preconditioner_LocalSmoother * gs, double * x);
51     void Paso_Preconditioner_LocalSmoother_Sweep_colored(Paso_SparseMatrix* A, Paso_Preconditioner_LocalSmoother * gs, double * x);
52    
53 gross 3193
54     /* AMG preconditioner */
55     struct Paso_Preconditioner_LocalAMG {
56 gross 3283 dim_t level;
57 gross 3193 dim_t n;
58 gross 3283 dim_t n_F;
59 gross 3193 dim_t n_block;
60 gross 3283 Paso_SparseMatrix * A_C; /* coarse level matrix */
61     Paso_SparseMatrix * P; /* prolongation n x n_C*/
62     Paso_SparseMatrix * R; /* restriction n_C x n */
63    
64     Paso_Preconditioner_LocalSmoother* Smoother;
65 gross 3193 dim_t post_sweeps;
66     dim_t pre_sweeps;
67 gross 3283 index_t reordering; /* applied reordering in direct solver */
68     dim_t refinements; /* number of refinements in direct solver (typically =0) */
69     double* r; /* buffer for residual */
70     double* x_C; /* solution of coarse level system */
71     double* b_C; /* right hand side of coarse level system */
72     struct Paso_Preconditioner_LocalAMG * AMG_C;
73 gross 3193 };
74     typedef struct Paso_Preconditioner_LocalAMG Paso_Preconditioner_LocalAMG;
75    
76     void Paso_Preconditioner_LocalAMG_free(Paso_Preconditioner_LocalAMG * in);
77     Paso_Preconditioner_LocalAMG* Paso_Preconditioner_LocalAMG_alloc(Paso_SparseMatrix * A_p,dim_t level,Paso_Options* options);
78 gross 3283 void Paso_Preconditioner_LocalAMG_solve(Paso_SparseMatrix* A, Paso_Preconditioner_LocalAMG * amg, double * x, double * b);
79     void Paso_Preconditioner_AMG_RSCoarsening_Block(Paso_SparseMatrix* A, index_t* split_marker, const double theta,const double tau);
80     void Paso_Preconditioner_AMG_RSCoarsening(Paso_SparseMatrix* A, index_t* split_marker, const double theta,const double tau);
81     void Paso_Preconditioner_AMG_RSCoarsening_search(const dim_t n, const index_t* offset, const dim_t* degree, const index_t* S, index_t*split_marker);
82 gross 3193
83    
84 gross 3120 /*===============================================*/
85     /* ILU preconditioner */
86     struct Paso_Solver_ILU {
87     double* factors;
88     };
89     typedef struct Paso_Solver_ILU Paso_Solver_ILU;
90    
91    
92    
93     /* RILU preconditioner */
94     struct Paso_Solver_RILU {
95     dim_t n;
96     dim_t n_block;
97     dim_t n_F;
98     dim_t n_C;
99     double* inv_A_FF;
100     index_t* A_FF_pivot;
101     Paso_SparseMatrix * A_FC;
102     Paso_SparseMatrix * A_CF;
103     index_t* rows_in_F;
104     index_t* rows_in_C;
105     index_t* mask_F;
106     index_t* mask_C;
107     double* x_F;
108     double* b_F;
109     double* x_C;
110     double* b_C;
111     struct Paso_Solver_RILU * RILU_of_Schur;
112     };
113     typedef struct Paso_Solver_RILU Paso_Solver_RILU;
114    
115    
116    
117     /* general preconditioner interface */
118    
119 gross 3193 typedef struct Paso_Preconditioner {
120 gross 3120 dim_t type;
121 gross 3158 dim_t sweeps;
122 gross 3120 /* jacobi preconditioner */
123 gross 3158 Paso_Preconditioner_Smoother* jacobi;
124 gross 3120 /* Gauss-Seidel preconditioner */
125 gross 3193 Paso_Preconditioner_Smoother* gs;
126     /* amg preconditioner */
127     Paso_Preconditioner_LocalAMG* localamg;
128 gross 3283 Paso_Preconditioner_LocalSmoother* localamgsubstitute;
129 gross 3120
130     /* ilu preconditioner */
131     Paso_Solver_ILU* ilu;
132     /* rilu preconditioner */
133     Paso_Solver_RILU* rilu;
134    
135 gross 3193 } Paso_Preconditioner;
136 gross 3120
137 gross 3193 void Paso_Preconditioner_free(Paso_Preconditioner*);
138     Paso_Preconditioner* Paso_Preconditioner_alloc(Paso_SystemMatrix* A,Paso_Options* options);
139     void Paso_Preconditioner_solve(Paso_Preconditioner* prec, Paso_SystemMatrix* A,double*,double*);
140 gross 3120
141    
142     /*******************************************/
143     void Paso_Solver_ILU_free(Paso_Solver_ILU * in);
144     Paso_Solver_ILU* Paso_Solver_getILU(Paso_SparseMatrix * A_p,bool_t verbose);
145     void Paso_Solver_solveILU(Paso_SparseMatrix * A, Paso_Solver_ILU * ilu, double * x, const double * b);
146    
147     void Paso_Solver_RILU_free(Paso_Solver_RILU * in);
148     Paso_Solver_RILU* Paso_Solver_getRILU(Paso_SparseMatrix * A_p,bool_t verbose);
149     void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b);
150    
151     void Paso_Solver_updateIncompleteSchurComplement(Paso_SparseMatrix* A_CC, Paso_SparseMatrix *A_CF,double* invA_FF,index_t* A_FF_pivot, Paso_SparseMatrix *A_FC);
152    
153    
154     #endif /* #ifndef INC_PRECS */

  ViewVC Help
Powered by ViewVC 1.1.26