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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3303 - (hide annotations)
Mon Oct 25 04:33:31 2010 UTC (8 years, 10 months ago) by gross
File MIME type: text/plain
File size: 6334 byte(s)
more clean up work on the AMG
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 gross 3303 void Paso_Preconditioner_AMG_RungeStuebenSearch(const dim_t n, const index_t* offset, const dim_t* degree, const index_t* S, index_t*split_marker);
80     void Paso_Preconditioner_AMG_setStrongConnections_Block(Paso_SparseMatrix* A, dim_t *degree, index_t *S, const double theta, const double tau);
81     void Paso_Preconditioner_AMG_setStrongConnections(Paso_SparseMatrix* A, dim_t *degree, index_t *S, const double theta, const double tau);
82     Paso_SparseMatrix* Paso_Preconditioner_AMG_getDirectProlongation(const Paso_SparseMatrix* A_p, const dim_t* degree, const index_t* S, const dim_t n_C, const index_t* counter_C);
83     void Paso_Preconditioner_AMG_setDirectProlongation_Block(Paso_SparseMatrix* P_p, const Paso_SparseMatrix* A_p, const index_t *counter_C);
84     void Paso_Preconditioner_AMG_setDirectProlongation(Paso_SparseMatrix* P_p, const Paso_SparseMatrix* A_p, const index_t *counter_C);
85 gross 3193
86 gross 3120 /*===============================================*/
87     /* ILU preconditioner */
88     struct Paso_Solver_ILU {
89     double* factors;
90     };
91     typedef struct Paso_Solver_ILU Paso_Solver_ILU;
92    
93    
94    
95     /* RILU preconditioner */
96     struct Paso_Solver_RILU {
97     dim_t n;
98     dim_t n_block;
99     dim_t n_F;
100     dim_t n_C;
101     double* inv_A_FF;
102     index_t* A_FF_pivot;
103     Paso_SparseMatrix * A_FC;
104     Paso_SparseMatrix * A_CF;
105     index_t* rows_in_F;
106     index_t* rows_in_C;
107     index_t* mask_F;
108     index_t* mask_C;
109     double* x_F;
110     double* b_F;
111     double* x_C;
112     double* b_C;
113     struct Paso_Solver_RILU * RILU_of_Schur;
114     };
115     typedef struct Paso_Solver_RILU Paso_Solver_RILU;
116    
117    
118    
119     /* general preconditioner interface */
120    
121 gross 3193 typedef struct Paso_Preconditioner {
122 gross 3120 dim_t type;
123 gross 3158 dim_t sweeps;
124 gross 3120 /* jacobi preconditioner */
125 gross 3158 Paso_Preconditioner_Smoother* jacobi;
126 gross 3120 /* Gauss-Seidel preconditioner */
127 gross 3193 Paso_Preconditioner_Smoother* gs;
128     /* amg preconditioner */
129     Paso_Preconditioner_LocalAMG* localamg;
130 gross 3283 Paso_Preconditioner_LocalSmoother* localamgsubstitute;
131 gross 3120
132     /* ilu preconditioner */
133     Paso_Solver_ILU* ilu;
134     /* rilu preconditioner */
135     Paso_Solver_RILU* rilu;
136    
137 gross 3193 } Paso_Preconditioner;
138 gross 3120
139 gross 3193 void Paso_Preconditioner_free(Paso_Preconditioner*);
140     Paso_Preconditioner* Paso_Preconditioner_alloc(Paso_SystemMatrix* A,Paso_Options* options);
141     void Paso_Preconditioner_solve(Paso_Preconditioner* prec, Paso_SystemMatrix* A,double*,double*);
142 gross 3120
143    
144     /*******************************************/
145     void Paso_Solver_ILU_free(Paso_Solver_ILU * in);
146     Paso_Solver_ILU* Paso_Solver_getILU(Paso_SparseMatrix * A_p,bool_t verbose);
147     void Paso_Solver_solveILU(Paso_SparseMatrix * A, Paso_Solver_ILU * ilu, double * x, const double * b);
148    
149     void Paso_Solver_RILU_free(Paso_Solver_RILU * in);
150     Paso_Solver_RILU* Paso_Solver_getRILU(Paso_SparseMatrix * A_p,bool_t verbose);
151     void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b);
152    
153     void Paso_Solver_updateIncompleteSchurComplement(Paso_SparseMatrix* A_CC, Paso_SparseMatrix *A_CF,double* invA_FF,index_t* A_FF_pivot, Paso_SparseMatrix *A_FC);
154    
155    
156     #endif /* #ifndef INC_PRECS */

  ViewVC Help
Powered by ViewVC 1.1.26