/[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 425 - (hide annotations)
Tue Jan 10 04:10:39 2006 UTC (13 years, 9 months ago) by gross
Original Path: trunk/paso/src/Solvers/Solver_preconditioner.c
File MIME type: text/plain
File size: 2919 byte(s)
The sparse solver can be called by paso now. 

the building has been change to reduce some code redundancy:
now all scons SCscripts are importing scons/esys_options.py which
imports platform specific settings. 



1 jgs 150 /* $Id$ */
2    
3     /**************************************************************/
4    
5     /* Paso: SystemMatrix: sets-up the preconditioner */
6    
7     /**************************************************************/
8    
9     /* Copyrights by ACcESS Australia 2003/04 */
10     /* Author: gross@access.edu.au */
11    
12     /**************************************************************/
13    
14     #include "Paso.h"
15     #include "SystemMatrix.h"
16     #include "Solver.h"
17    
18     /***********************************************************************************/
19    
20     /* free space */
21    
22     void Paso_Preconditioner_free(Paso_Solver_Preconditioner* in) {
23     if (in!=NULL) {
24     Paso_Solver_ILU_free(in->ilu);
25     Paso_Solver_Jacobi_free(in->jacobi);
26     MEMFREE(in);
27     }
28     }
29     /* call the iterative solver: */
30    
31     void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options) {
32     Paso_Solver_Preconditioner* prec=NULL;
33 gross 425 if (A->solver==NULL) {
34 jgs 150 /* allocate structure to hold preconditioner */
35     prec=MEMALLOC(1,Paso_Solver_Preconditioner);
36     if (Paso_checkPtr(prec)) return;
37     prec->type=UNKNOWN;
38     prec->ilu=NULL;
39     prec->jacobi=NULL;
40 gross 425 A->solver=prec;
41 jgs 150 switch (options->preconditioner) {
42     default:
43     case PASO_JACOBI:
44     if (options->verbose) printf("Jacobi preconditioner is used.\n");
45     prec->jacobi=Paso_Solver_getJacobi(A);
46     prec->type=PASO_JACOBI;
47     break;
48     case PASO_ILU0:
49     if (options->verbose) printf("ILU preconditioner is used.\n");
50     prec->ilu=Paso_Solver_getILU(A,options->verbose);
51     prec->type=PASO_ILU0;
52     break;
53     }
54     if (! Paso_noError()) {
55     Paso_Preconditioner_free(prec);
56 gross 425 A->solver=NULL;
57 jgs 150 }
58     }
59     }
60    
61     /* applies the preconditioner */
62     /* has to be called within a parallel reqion */
63     /* barrier synchronization is performed before the evaluation to make sure that the input vector is available */
64     void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b){
65 gross 425 Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->solver;
66 jgs 150 #pragma omp barrier
67     switch (prec->type) {
68     default:
69     case PASO_JACOBI:
70     Paso_Solver_solveJacobi(prec->jacobi,x,b);
71     break;
72     case PASO_ILU0:
73     Paso_Solver_solveILU(prec->ilu,x,b);
74     break;
75     }
76     }
77    
78     /*
79     * $Log$
80     * Revision 1.2 2005/09/15 03:44:40 jgs
81     * Merge of development branch dev-02 back to main trunk on 2005-09-15
82     *
83     * Revision 1.1.2.2 2005/09/07 00:59:09 gross
84     * some inconsistent renaming fixed to make the linking work.
85     *
86     * Revision 1.1.2.1 2005/09/05 06:29:50 gross
87     * These files have been extracted from finley to define a stand alone libray for iterative
88     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
89     * has not been tested yet.
90     *
91     *
92     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26