/[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 1823 - (hide annotations)
Wed Oct 1 05:56:05 2008 UTC (11 years ago) by artak
File MIME type: text/plain
File size: 3649 byte(s)
GS preconditioner now works for block_size 2 and 3 as well. Sweep parameter introdiced, but not working yet
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 artak 1823 prec->gs->sweeps=options->sweeps;
78 artak 1819 prec->type=PASO_GS;
79     break;
80 jgs 150 }
81 ksteube 1312 if (! Paso_MPIInfo_noError(A->mpi_info ) ){
82 jgs 150 Paso_Preconditioner_free(prec);
83 gross 425 A->solver=NULL;
84 jgs 150 }
85     }
86     }
87    
88     /* applies the preconditioner */
89     /* has to be called within a parallel reqion */
90     /* barrier synchronization is performed before the evaluation to make sure that the input vector is available */
91     void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b){
92 gross 425 Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->solver;
93 jgs 150 switch (prec->type) {
94     default:
95     case PASO_JACOBI:
96     Paso_Solver_solveJacobi(prec->jacobi,x,b);
97     break;
98     case PASO_ILU0:
99     Paso_Solver_solveILU(prec->ilu,x,b);
100     break;
101 gross 430 case PASO_RILU:
102     Paso_Solver_solveRILU(prec->rilu,x,b);
103     break;
104 artak 1819 case PASO_GS:
105     Paso_Solver_solveGS(prec->gs,x,b);
106     break;
107 jgs 150 }
108     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26