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

Contents of /temp_trunk_copy/paso/src/Solver_preconditioner.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 150 - (show annotations)
Thu Sep 15 03:44:45 2005 UTC (14 years, 1 month ago) by jgs
Original Path: trunk/esys2/paso/src/Solvers/Solver_preconditioner.c
File MIME type: text/plain
File size: 2931 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-15

1 /* $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 if (A->iterative==NULL) {
34 /* 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 A->iterative=prec;
41 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 A->iterative=NULL;
57 }
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 Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->iterative;
66 #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