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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1312 - (hide annotations)
Mon Sep 24 06:18:44 2007 UTC (11 years, 11 months ago) by ksteube
Original Path: trunk/paso/src/Solver_preconditioner.c
File MIME type: text/plain
File size: 3275 byte(s)
The MPI branch is hereby closed. All future work should be in trunk.

Previously in revision 1295 I merged the latest changes to trunk into trunk-mpi-branch.
In this revision I copied all files from trunk-mpi-branch over the corresponding
trunk files. I did not use 'svn merge', it was a copy.

1 ksteube 1312
2 jgs 150 /* $Id$ */
3    
4 ksteube 1312 /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15 dhawcroft 631
16 jgs 150 /**************************************************************/
17    
18     /* Paso: SystemMatrix: sets-up the preconditioner */
19    
20     /**************************************************************/
21    
22     /* Copyrights by ACcESS Australia 2003/04 */
23     /* Author: gross@access.edu.au */
24    
25     /**************************************************************/
26    
27 gross 700 #include "Paso.h"
28     #include "SystemMatrix.h"
29 jgs 150 #include "Solver.h"
30    
31     /***********************************************************************************/
32    
33     /* free space */
34    
35     void Paso_Preconditioner_free(Paso_Solver_Preconditioner* in) {
36     if (in!=NULL) {
37     Paso_Solver_ILU_free(in->ilu);
38 gross 430 Paso_Solver_RILU_free(in->rilu);
39 jgs 150 Paso_Solver_Jacobi_free(in->jacobi);
40     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 gross 425 A->solver=prec;
56 jgs 150 switch (options->preconditioner) {
57     default:
58     case PASO_JACOBI:
59     if (options->verbose) printf("Jacobi preconditioner is used.\n");
60 ksteube 1312 prec->jacobi=Paso_Solver_getJacobi(A->mainBlock);
61 jgs 150 prec->type=PASO_JACOBI;
62     break;
63     case PASO_ILU0:
64     if (options->verbose) printf("ILU preconditioner is used.\n");
65 ksteube 1312 prec->ilu=Paso_Solver_getILU(A->mainBlock,options->verbose);
66 jgs 150 prec->type=PASO_ILU0;
67     break;
68 gross 430 case PASO_RILU:
69     if (options->verbose) printf("RILU preconditioner is used.\n");
70 ksteube 1312 prec->rilu=Paso_Solver_getRILU(A->mainBlock,options->verbose);
71 gross 430 prec->type=PASO_RILU;
72     break;
73 jgs 150 }
74 ksteube 1312 if (! Paso_MPIInfo_noError(A->mpi_info ) ){
75 jgs 150 Paso_Preconditioner_free(prec);
76 gross 425 A->solver=NULL;
77 jgs 150 }
78     }
79     }
80    
81     /* applies the preconditioner */
82     /* has to be called within a parallel reqion */
83     /* barrier synchronization is performed before the evaluation to make sure that the input vector is available */
84     void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b){
85 gross 425 Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->solver;
86 jgs 150 #pragma omp barrier
87     switch (prec->type) {
88     default:
89     case PASO_JACOBI:
90     Paso_Solver_solveJacobi(prec->jacobi,x,b);
91     break;
92     case PASO_ILU0:
93     Paso_Solver_solveILU(prec->ilu,x,b);
94     break;
95 gross 430 case PASO_RILU:
96     Paso_Solver_solveRILU(prec->rilu,x,b);
97     break;
98 jgs 150 }
99     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26