ESScript  Revision_
Preconditioner.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15 
16 
17 #ifndef INC_PRECS
18 #define INC_PRECS
19 
20 #include "SystemMatrix.h"
21 #include "performance.h"
22 #include "BOOMERAMG.h"
23 #include "MergedSolver.h"
24 
25 #define PRECONDITIONER_NO_ERROR 0
26 #define PRECONDITIONER_MAXITER_REACHED 1
27 #define PRECONDITIONER_INPUT_ERROR -1
28 #define PRECONDITIONER_MEMORY_ERROR -9
29 #define PRECONDITIONER_BREAKDOWN -10
30 #define PRECONDITIONER_NEGATIVE_NORM_ERROR -11
31 #define PRECONDITIONER_DIVERGENCE -12
32 
33 
34 /*
35 #define PASO_AMG_UNDECIDED -1
36 #define PASO_AMG_IN_F 0
37 #define PASO_AMG_IN_C 1
38 */
39 
40 
41 /* GAUSS SEIDEL & Jacobi */
43  bool Jacobi;
44  double* diag;
45  double* buffer;
48 
51  bool is_local;
53 
56 
57 
58 Paso_Preconditioner_Smoother* Paso_Preconditioner_Smoother_alloc(Paso_SystemMatrix * A_p, const bool jacobi, const bool is_local, const bool verbose);
60 
61 void Paso_Preconditioner_Smoother_solve(Paso_SystemMatrix* A, Paso_Preconditioner_Smoother * gs, double * x, const double * b, const dim_t sweeps, const bool x_is_initial);
62 void Paso_Preconditioner_LocalSmoother_solve(Paso_SparseMatrix* A, Paso_Preconditioner_LocalSmoother * gs, double * x, const double * b, const dim_t sweeps, const bool x_is_initial);
63 err_t Paso_Preconditioner_Smoother_solve_byTolerance(Paso_SystemMatrix* A, Paso_Preconditioner_Smoother * gs, double * x, const double * b, const double atol, dim_t *sweeps, const bool x_is_initial);
64 
69 
70 
71 
72 /* Local preconditioner */
75  Paso_SystemMatrix * A_C; /* coarse level matrix */
76  Paso_SystemMatrix * P; /* prolongation n x n_C*/
77  Paso_SystemMatrix * R; /* restriction n_C x n */
78 
82  dim_t options_smoother; /* used in direct solver */
83  bool verbose; /* used in direct solver */
84  index_t reordering; /* applied reordering in direct solver */
85  dim_t refinements; /* number of refinements in direct solver (typically =0) */
86  double* r; /* buffer for residual */
87  double* x_C; /* solution of coarse level system */
88  double* b_C; /* right hand side of coarse level system */
89  Paso_MergedSolver* merged_solver; /* used on the coarsest level */
91 };
93 
96 void Paso_Preconditioner_AMG_solve(Paso_SystemMatrix* A, Paso_Preconditioner_AMG * amg, double * x, double * b);
97 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);
98 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);
99 Paso_SystemMatrix* Paso_Preconditioner_AMG_getProlongation(Paso_SystemMatrix* A_p, const index_t* offset_S, const dim_t* degree_S, const index_t* S, const dim_t n_C, index_t* counter_C, const index_t interpolation_method);
100 void Paso_Preconditioner_AMG_setClassicProlongation(Paso_SystemMatrix* P, Paso_SystemMatrix* A, const index_t* offset_S, const dim_t* degree_S, const index_t* S,const index_t *counter_C);
101 void Paso_Preconditioner_AMG_setClassicProlongation_Block(Paso_SystemMatrix* P, Paso_SystemMatrix* A, const index_t* offset_S, const dim_t* degree_S, const index_t* S,const index_t *counter_C);
102 void Paso_Preconditioner_AMG_setDirectProlongation(Paso_SystemMatrix* P, Paso_SystemMatrix* A, const index_t* offset_S, const dim_t* degree_S, const index_t* S,const index_t *counter_C);
103 void Paso_Preconditioner_AMG_setDirectProlongation_Block(Paso_SystemMatrix* P, Paso_SystemMatrix* A, const index_t* offset_S, const dim_t* degree_S, const index_t* S,const index_t *counter_C);
107 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);
108 void Paso_Preconditioner_AMG_CIJPCoarsening(const dim_t n, const dim_t my_n, AMGBlockSelect*split_marker,
109  const dim_t* degree_S, const index_t* offset_S, const index_t* S,
110  const dim_t* degree_ST, const index_t* offset_ST, const index_t* ST,
111  Paso_Connector* col_connector, Paso_Distribution* col_dist);
117 
118 /* Local AMG preconditioner */
121  Paso_SparseMatrix * A_C; /* coarse level matrix */
122  Paso_SparseMatrix * P; /* prolongation n x n_C*/
123  Paso_SparseMatrix * R; /* restriction n_C x n */
124 
128  index_t reordering; /* applied reordering in direct solver */
129  dim_t refinements; /* number of refinements in direct solver (typically =0) */
130  double* r; /* buffer for residual */
131  double* x_C; /* solution of coarse level system */
132  double* b_C; /* right hand side of coarse level system */
134 };
136 
140 
141 void Paso_Preconditioner_LocalAMG_RungeStuebenSearch(const dim_t n, const index_t* offset, const dim_t* degree, const index_t* S, AMGBlockSelect*split_marker, const bool usePanel);
142 void Paso_Preconditioner_LocalAMG_setStrongConnections_Block(Paso_SparseMatrix* A, dim_t *degree, index_t *S, const double theta, const double tau);
143 void Paso_Preconditioner_LocalAMG_setStrongConnections(Paso_SparseMatrix* A, dim_t *degree, index_t *S, const double theta, const double tau);
144 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);
147 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);
148 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);
152 void Paso_Preconditioner_LocalAMG_enforceFFConnectivity(const dim_t n, const index_t* offset_S, const dim_t* degree_S, const index_t* S, AMGBlockSelect*split_marker);
153 
154 
156 {
158 };
163 
164 
166 {
167  bool is_local;
173 };
175 
179 
180 /*===============================================*/
181 /* ILU preconditioner */
183  double* factors;
184 };
186 
187 
188 
189 /* RILU preconditioner */
195  double* inv_A_FF;
203  double* x_F;
204  double* b_F;
205  double* x_C;
206  double* b_C;
208 };
210 
211 
212 
213 /* general preconditioner interface */
214 
215 typedef struct Paso_Preconditioner {
218  /* jacobi preconditioner */
220  /* Gauss-Seidel preconditioner */
222  /* amg preconditioner */
224 
225  /* ilu preconditioner */
227  /* rilu preconditioner */
229 
231 
234 void Paso_Preconditioner_solve(Paso_Preconditioner* prec, Paso_SystemMatrix* A,double*,double*);
235 
236 
237 /*******************************************/
240 void Paso_Solver_solveILU(Paso_SparseMatrix * A, Paso_Solver_ILU * ilu, double * x, const double * b);
241 
244 void Paso_Solver_solveRILU(Paso_Solver_RILU * rilu, double * x, double * b);
245 
247 
248 
249 #endif /* #ifndef INC_PRECS */