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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 631 - (hide annotations)
Thu Mar 23 04:27:32 2006 UTC (13 years, 5 months ago) by dhawcroft
Original Path: trunk/paso/src/Solvers/Solver_preconditioner.c
File MIME type: text/plain
File size: 3949 byte(s)
Prepended all paso source files with new Copyright notice
1 jgs 150 /* $Id$ */
2    
3 dhawcroft 631
4     /*
5     ********************************************************************************
6     * Copyright © 2006 by ACcESS MNRF *
7     * *
8     * http://www.access.edu.au *
9     * Primary Business: Queensland, Australia *
10     * Licensed under the Open Software License version 3.0 *
11     * http://www.opensource.org/licenses/osl-3.0.php *
12     ********************************************************************************
13     */
14    
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     #include "Paso.h"
27     #include "SystemMatrix.h"
28     #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     prec->jacobi=Paso_Solver_getJacobi(A);
60     prec->type=PASO_JACOBI;
61     break;
62     case PASO_ILU0:
63     if (options->verbose) printf("ILU preconditioner is used.\n");
64     prec->ilu=Paso_Solver_getILU(A,options->verbose);
65     prec->type=PASO_ILU0;
66     break;
67 gross 430 case PASO_RILU:
68     if (options->verbose) printf("RILU preconditioner is used.\n");
69 gross 431 prec->rilu=Paso_Solver_getRILU(A,options->verbose);
70 gross 430 prec->type=PASO_RILU;
71     break;
72 jgs 150 }
73     if (! Paso_noError()) {
74     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 #pragma omp barrier
86     switch (prec->type) {
87     default:
88     case PASO_JACOBI:
89     Paso_Solver_solveJacobi(prec->jacobi,x,b);
90     break;
91     case PASO_ILU0:
92     Paso_Solver_solveILU(prec->ilu,x,b);
93     break;
94 gross 430 case PASO_RILU:
95     Paso_Solver_solveRILU(prec->rilu,x,b);
96     break;
97 jgs 150 }
98     }
99    
100     /*
101     * $Log$
102     * Revision 1.2 2005/09/15 03:44:40 jgs
103     * Merge of development branch dev-02 back to main trunk on 2005-09-15
104     *
105     * Revision 1.1.2.2 2005/09/07 00:59:09 gross
106     * some inconsistent renaming fixed to make the linking work.
107     *
108     * Revision 1.1.2.1 2005/09/05 06:29:50 gross
109     * These files have been extracted from finley to define a stand alone libray for iterative
110     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
111     * has not been tested yet.
112     *
113     *
114     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26