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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3642 - (show annotations)
Thu Oct 27 03:41:51 2011 UTC (7 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 4567 byte(s)
Assorted spelling/comment fixes in paso.

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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: preconditioner set up */
18
19 /**************************************************************/
20
21 /* Author: Lutz Gross, l.gross@uq.edu.au */
22
23 /**************************************************************/
24
25 #include "Paso.h"
26 #include "SystemMatrix.h"
27 #include "PasoUtil.h"
28 #include "Preconditioner.h"
29
30 /***********************************************************************************/
31
32 /* free space */
33
34 void Paso_Preconditioner_free(Paso_Preconditioner* in) {
35 if (in!=NULL) {
36 Paso_Preconditioner_Smoother_free(in->jacobi);
37 Paso_Preconditioner_Smoother_free(in->gs);
38 Paso_Preconditioner_AMG_Root_free(in->amg);
39 /*********************************/
40 Paso_Solver_ILU_free(in->ilu);
41 Paso_Solver_RILU_free(in->rilu);
42 /*********************************/
43
44 MEMFREE(in);
45 }
46 }
47
48 Paso_Preconditioner* Paso_Preconditioner_alloc(Paso_SystemMatrix* A,Paso_Options* options) {
49
50 Paso_Preconditioner* prec=NULL;
51
52 prec=MEMALLOC(1,Paso_Preconditioner);
53
54 if (! Esys_checkPtr(prec)) {
55
56 prec->type=UNKNOWN;
57
58
59 prec->jacobi=NULL;
60 prec->gs=NULL;
61 prec->amg=NULL;
62
63 /*********************************/
64 prec->rilu=NULL;
65 prec->ilu=NULL;
66 /*********************************/
67
68 if (options->verbose && options->use_local_preconditioner) printf("Paso: Apply preconditioner locally only.\n");
69
70 switch (options->preconditioner) {
71 default:
72 case PASO_JACOBI:
73 if (options->verbose) printf("Paso_Preconditioner: Jacobi(%d) preconditioner is used.\n",options->sweeps);
74 prec->jacobi=Paso_Preconditioner_Smoother_alloc(A, TRUE, options->use_local_preconditioner, options->verbose);
75 prec->type=PASO_JACOBI;
76 prec->sweeps=options->sweeps;
77 break;
78 case PASO_GS:
79 if (options->verbose) printf("Paso_Preconditioner: Gauss-Seidel(%d) preconditioner is used.\n",options->sweeps);
80 prec->gs=Paso_Preconditioner_Smoother_alloc(A, FALSE, options->use_local_preconditioner, options->verbose);
81 prec->type=PASO_GS;
82 prec->sweeps=options->sweeps;
83 break;
84 case PASO_BOOMERAMG:
85 case PASO_AMLI:
86 case PASO_AMG:
87 prec->amg=Paso_Preconditioner_AMG_Root_alloc(A, options);
88 prec->type=PASO_AMG;
89 break;
90
91 /***************************************************************************************/
92 case PASO_ILU0:
93 if (options->verbose) printf("Paso_Preconditioner: ILU preconditioner is used.\n");
94 prec->ilu=Paso_Solver_getILU(A->mainBlock,options->verbose);
95 prec->type=PASO_ILU0;
96 Esys_MPIInfo_noError(A->mpi_info);
97 break;
98 case PASO_RILU:
99 if (options->verbose) printf("Paso_Preconditioner: RILU preconditioner is used.\n");
100 prec->rilu=Paso_Solver_getRILU(A->mainBlock,options->verbose);
101 Esys_MPIInfo_noError(A->mpi_info);
102 prec->type=PASO_RILU;
103 break;
104 }
105 }
106 if (! Esys_noError() ){
107 Paso_Preconditioner_free(prec);
108 return NULL;
109 } else {
110 return prec;
111 }
112 }
113
114 /* Applies the preconditioner. */
115 /* Has to be called within a parallel region. */
116 /* Barrier synchronization is performed before the evaluation to make sure that the input vector is available */
117 void Paso_Preconditioner_solve(Paso_Preconditioner* prec, Paso_SystemMatrix* A,double* x,double* b){
118
119 switch (prec->type) {
120 default:
121 case PASO_JACOBI:
122 Paso_Preconditioner_Smoother_solve(A, prec->jacobi,x,b,prec->sweeps, FALSE);
123 break;
124 case PASO_GS:
125 Paso_Preconditioner_Smoother_solve(A, prec->gs,x,b,prec->sweeps, FALSE);
126 break;
127 case PASO_AMG:
128 Paso_Preconditioner_AMG_Root_solve(A, prec->amg ,x,b);
129 break;
130
131 /*=========================================================*/
132 case PASO_ILU0:
133 Paso_Solver_solveILU(A->mainBlock, prec->ilu,x,b);
134 break;
135 case PASO_RILU:
136 Paso_Solver_solveRILU(prec->rilu,x,b);
137 break;
138
139 }
140 }
141

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26