/[escript]/trunk/paso/src/Solver_preconditioner.c
ViewVC logotype

Annotation of /trunk/paso/src/Solver_preconditioner.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1819 - (hide annotations)
Tue Sep 30 05:58:06 2008 UTC (12 years, 11 months ago) by artak
File MIME type: text/plain
File size: 3601 byte(s)
Firs version of symmetric Gauss-Seidel preconditioner with coloring
1 ksteube 1312
2     /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 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 dhawcroft 631
14 ksteube 1811
15 jgs 150 /**************************************************************/
16    
17     /* Paso: SystemMatrix: sets-up the preconditioner */
18    
19     /**************************************************************/
20    
21     /* Copyrights by ACcESS Australia 2003/04 */
22     /* Author: gross@access.edu.au */
23    
24     /**************************************************************/
25    
26 gross 700 #include "Paso.h"
27     #include "SystemMatrix.h"
28 jgs 150 #include "Solver.h"
29    
30     /***********************************************************************************/
31    
32     /* free space */
33    
34     void Paso_Preconditioner_free(Paso_Solver_Preconditioner* in) {
35     if (in!=NULL) {
36     Paso_Solver_ILU_free(in->ilu);
37 gross 430 Paso_Solver_RILU_free(in->rilu);
38 jgs 150 Paso_Solver_Jacobi_free(in->jacobi);
39 artak 1819 Paso_Solver_GS_free(in->gs);
40 jgs 150 MEMFREE(in);
41     }
42     }
43     /* call the iterative solver: */
44    
45     void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options) {
46     Paso_Solver_Preconditioner* prec=NULL;
47 gross 425 if (A->solver==NULL) {
48 jgs 150 /* allocate structure to hold preconditioner */
49     prec=MEMALLOC(1,Paso_Solver_Preconditioner);
50     if (Paso_checkPtr(prec)) return;
51     prec->type=UNKNOWN;
52 gross 430 prec->rilu=NULL;
53 jgs 150 prec->ilu=NULL;
54     prec->jacobi=NULL;
55 artak 1819 prec->gs=NULL;
56 gross 425 A->solver=prec;
57 jgs 150 switch (options->preconditioner) {
58     default:
59     case PASO_JACOBI:
60     if (options->verbose) printf("Jacobi preconditioner is used.\n");
61 ksteube 1312 prec->jacobi=Paso_Solver_getJacobi(A->mainBlock);
62 jgs 150 prec->type=PASO_JACOBI;
63     break;
64     case PASO_ILU0:
65     if (options->verbose) printf("ILU preconditioner is used.\n");
66 ksteube 1312 prec->ilu=Paso_Solver_getILU(A->mainBlock,options->verbose);
67 jgs 150 prec->type=PASO_ILU0;
68     break;
69 gross 430 case PASO_RILU:
70     if (options->verbose) printf("RILU preconditioner is used.\n");
71 ksteube 1312 prec->rilu=Paso_Solver_getRILU(A->mainBlock,options->verbose);
72 gross 430 prec->type=PASO_RILU;
73     break;
74 artak 1819 case PASO_GS:
75     if (options->verbose) printf("Gauss-Seidel preconditioner is used.\n");
76     prec->gs=Paso_Solver_getGS(A->mainBlock,options->verbose);
77     prec->type=PASO_GS;
78     break;
79 jgs 150 }
80 ksteube 1312 if (! Paso_MPIInfo_noError(A->mpi_info ) ){
81 jgs 150 Paso_Preconditioner_free(prec);
82 gross 425 A->solver=NULL;
83 jgs 150 }
84     }
85     }
86    
87     /* applies the preconditioner */
88     /* has to be called within a parallel reqion */
89     /* barrier synchronization is performed before the evaluation to make sure that the input vector is available */
90     void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b){
91 gross 425 Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->solver;
92 jgs 150 switch (prec->type) {
93     default:
94     case PASO_JACOBI:
95     Paso_Solver_solveJacobi(prec->jacobi,x,b);
96     break;
97     case PASO_ILU0:
98     Paso_Solver_solveILU(prec->ilu,x,b);
99     break;
100 gross 430 case PASO_RILU:
101     Paso_Solver_solveRILU(prec->rilu,x,b);
102     break;
103 artak 1819 case PASO_GS:
104     Paso_Solver_solveGS(prec->gs,x,b);
105     break;
106 jgs 150 }
107     }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26