/[escript]/trunk/esys2/finley/src/finleyC/Solvers/Solver_preconditioner.c
ViewVC logotype

Contents of /trunk/esys2/finley/src/finleyC/Solvers/Solver_preconditioner.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 115 - (show annotations)
Fri Mar 4 07:12:47 2005 UTC (14 years, 1 month ago) by jgs
File MIME type: text/plain
File size: 2492 byte(s)
*** empty log message ***

1 /* $Id$ */
2
3 /**************************************************************/
4
5 /* Finley: 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 "Finley.h"
15 #include "System.h"
16 #include "Solver.h"
17
18 /***********************************************************************************/
19
20 /* free space */
21
22 void Finley_Preconditioner_free(Finley_Solver_Preconditioner* in) {
23 if (in!=NULL) {
24 Finley_Solver_ILU_free(in->ilu);
25 Finley_Solver_Jacobi_free(in->jacobi);
26 MEMFREE(in);
27 }
28 }
29 /* call the iterative solver: */
30
31 void Finley_Solver_setPreconditioner(Finley_SystemMatrix* A,Finley_SolverOptions* options) {
32 Finley_Solver_Preconditioner* prec=NULL;
33 if (A->iterative==NULL) {
34 /* allocate structure to hold preconditioner */
35 prec=MEMALLOC(1,Finley_Solver_Preconditioner);
36 if (Finley_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 ESCRIPT_JACOBI:
44 if (options->verbose) printf("Jacobi preconditioner is used.\n");
45 prec->jacobi=Finley_Solver_getJacobi(A);
46 prec->type=ESCRIPT_JACOBI;
47 break;
48 case ESCRIPT_ILU0:
49 if (options->verbose) printf("ILU preconditioner is used.\n");
50 prec->ilu=Finley_Solver_getILU(A,options->verbose);
51 prec->type=ESCRIPT_ILU0;
52 break;
53 }
54 if (Finley_ErrorCode!=NO_ERROR) {
55 Finley_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 Finley_Solver_solvePreconditioner(Finley_SystemMatrix* A,double* x,double* b){
65 Finley_Solver_Preconditioner* prec=(Finley_Solver_Preconditioner*) A->iterative;
66 #pragma omp barrier
67 switch (prec->type) {
68 default:
69 case ESCRIPT_JACOBI:
70 Finley_Solver_solveJacobi(prec->jacobi,x,b);
71 break;
72 case ESCRIPT_ILU0:
73 Finley_Solver_solveILU(prec->ilu,x,b);
74 break;
75 }
76 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26