/[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 1312 - (show annotations)
Mon Sep 24 06:18:44 2007 UTC (12 years, 1 month ago) by ksteube
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
2 /* $Id$ */
3
4 /*******************************************************
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
16 /**************************************************************/
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 #include "Paso.h"
28 #include "SystemMatrix.h"
29 #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 Paso_Solver_RILU_free(in->rilu);
39 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 if (A->solver==NULL) {
48 /* allocate structure to hold preconditioner */
49 prec=MEMALLOC(1,Paso_Solver_Preconditioner);
50 if (Paso_checkPtr(prec)) return;
51 prec->type=UNKNOWN;
52 prec->rilu=NULL;
53 prec->ilu=NULL;
54 prec->jacobi=NULL;
55 A->solver=prec;
56 switch (options->preconditioner) {
57 default:
58 case PASO_JACOBI:
59 if (options->verbose) printf("Jacobi preconditioner is used.\n");
60 prec->jacobi=Paso_Solver_getJacobi(A->mainBlock);
61 prec->type=PASO_JACOBI;
62 break;
63 case PASO_ILU0:
64 if (options->verbose) printf("ILU preconditioner is used.\n");
65 prec->ilu=Paso_Solver_getILU(A->mainBlock,options->verbose);
66 prec->type=PASO_ILU0;
67 break;
68 case PASO_RILU:
69 if (options->verbose) printf("RILU preconditioner is used.\n");
70 prec->rilu=Paso_Solver_getRILU(A->mainBlock,options->verbose);
71 prec->type=PASO_RILU;
72 break;
73 }
74 if (! Paso_MPIInfo_noError(A->mpi_info ) ){
75 Paso_Preconditioner_free(prec);
76 A->solver=NULL;
77 }
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 Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->solver;
86 #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 case PASO_RILU:
96 Paso_Solver_solveRILU(prec->rilu,x,b);
97 break;
98 }
99 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26