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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show 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
2 /*******************************************************
3 *
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
14
15 /**************************************************************/
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 Paso_Solver_RILU_free(in->rilu);
38 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 if (A->solver==NULL) {
47 /* allocate structure to hold preconditioner */
48 prec=MEMALLOC(1,Paso_Solver_Preconditioner);
49 if (Paso_checkPtr(prec)) return;
50 prec->type=UNKNOWN;
51 prec->rilu=NULL;
52 prec->ilu=NULL;
53 prec->jacobi=NULL;
54 A->solver=prec;
55 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->mainBlock);
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->mainBlock,options->verbose);
65 prec->type=PASO_ILU0;
66 break;
67 case PASO_RILU:
68 if (options->verbose) printf("RILU preconditioner is used.\n");
69 prec->rilu=Paso_Solver_getRILU(A->mainBlock,options->verbose);
70 prec->type=PASO_RILU;
71 break;
72 }
73 if (! Paso_MPIInfo_noError(A->mpi_info ) ){
74 Paso_Preconditioner_free(prec);
75 A->solver=NULL;
76 }
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 Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->solver;
85 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 case PASO_RILU:
94 Paso_Solver_solveRILU(prec->rilu,x,b);
95 break;
96 }
97 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26