/[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 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years ago) by ksteube
File MIME type: text/plain
File size: 3216 byte(s)
Copyright updated in all files

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     MEMFREE(in);
40     }
41     }
42     /* call the iterative solver: */
43    
44     void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options) {
45     Paso_Solver_Preconditioner* prec=NULL;
46 gross 425 if (A->solver==NULL) {
47 jgs 150 /* allocate structure to hold preconditioner */
48     prec=MEMALLOC(1,Paso_Solver_Preconditioner);
49     if (Paso_checkPtr(prec)) return;
50     prec->type=UNKNOWN;
51 gross 430 prec->rilu=NULL;
52 jgs 150 prec->ilu=NULL;
53     prec->jacobi=NULL;
54 gross 425 A->solver=prec;
55 jgs 150 switch (options->preconditioner) {
56     default:
57     case PASO_JACOBI:
58     if (options->verbose) printf("Jacobi preconditioner is used.\n");
59 ksteube 1312 prec->jacobi=Paso_Solver_getJacobi(A->mainBlock);
60 jgs 150 prec->type=PASO_JACOBI;
61     break;
62     case PASO_ILU0:
63     if (options->verbose) printf("ILU preconditioner is used.\n");
64 ksteube 1312 prec->ilu=Paso_Solver_getILU(A->mainBlock,options->verbose);
65 jgs 150 prec->type=PASO_ILU0;
66     break;
67 gross 430 case PASO_RILU:
68     if (options->verbose) printf("RILU preconditioner is used.\n");
69 ksteube 1312 prec->rilu=Paso_Solver_getRILU(A->mainBlock,options->verbose);
70 gross 430 prec->type=PASO_RILU;
71     break;
72 jgs 150 }
73 ksteube 1312 if (! Paso_MPIInfo_noError(A->mpi_info ) ){
74 jgs 150 Paso_Preconditioner_free(prec);
75 gross 425 A->solver=NULL;
76 jgs 150 }
77     }
78     }
79    
80     /* applies the preconditioner */
81     /* has to be called within a parallel reqion */
82     /* barrier synchronization is performed before the evaluation to make sure that the input vector is available */
83     void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b){
84 gross 425 Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->solver;
85 jgs 150 switch (prec->type) {
86     default:
87     case PASO_JACOBI:
88     Paso_Solver_solveJacobi(prec->jacobi,x,b);
89     break;
90     case PASO_ILU0:
91     Paso_Solver_solveILU(prec->ilu,x,b);
92     break;
93 gross 430 case PASO_RILU:
94     Paso_Solver_solveRILU(prec->rilu,x,b);
95     break;
96 jgs 150 }
97     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26