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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC revision 633 by dhawcroft, Thu Mar 23 05:37:00 2006 UTC
# Line 1  Line 1 
1  /* $Id$ */  /* $Id$ */
2    
3    
4    /*
5    ********************************************************************************
6    *               Copyright   2006 by ACcESS MNRF                                *
7    *                                                                              *
8    *                 http://www.access.edu.au                                     *
9    *           Primary Business: Queensland, Australia                            *
10    *     Licensed under the Open Software License version 3.0             *
11    *        http://www.opensource.org/licenses/osl-3.0.php                        *
12    ********************************************************************************
13    */
14    
15  /**************************************************************/  /**************************************************************/
16    
17  /* Paso: SystemMatrix: sets-up the preconditioner           */  /* Paso: SystemMatrix: sets-up the preconditioner           */
# Line 22  Line 34 
34  void Paso_Preconditioner_free(Paso_Solver_Preconditioner* in) {  void Paso_Preconditioner_free(Paso_Solver_Preconditioner* in) {
35      if (in!=NULL) {      if (in!=NULL) {
36        Paso_Solver_ILU_free(in->ilu);        Paso_Solver_ILU_free(in->ilu);
37          Paso_Solver_RILU_free(in->rilu);
38        Paso_Solver_Jacobi_free(in->jacobi);        Paso_Solver_Jacobi_free(in->jacobi);
39        MEMFREE(in);        MEMFREE(in);
40      }      }
# Line 30  void Paso_Preconditioner_free(Paso_Solve Line 43  void Paso_Preconditioner_free(Paso_Solve
43    
44  void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options) {  void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options) {
45      Paso_Solver_Preconditioner* prec=NULL;      Paso_Solver_Preconditioner* prec=NULL;
46      if (A->iterative==NULL) {      if (A->solver==NULL) {
47          /* allocate structure to hold preconditioner */          /* allocate structure to hold preconditioner */
48          prec=MEMALLOC(1,Paso_Solver_Preconditioner);          prec=MEMALLOC(1,Paso_Solver_Preconditioner);
49          if (Paso_checkPtr(prec)) return;          if (Paso_checkPtr(prec)) return;
50          prec->type=UNKNOWN;          prec->type=UNKNOWN;
51            prec->rilu=NULL;
52          prec->ilu=NULL;          prec->ilu=NULL;
53          prec->jacobi=NULL;          prec->jacobi=NULL;
54          A->iterative=prec;          A->solver=prec;
55          switch (options->preconditioner) {          switch (options->preconditioner) {
56             default:             default:
57             case PASO_JACOBI:             case PASO_JACOBI:
# Line 50  void Paso_Solver_setPreconditioner(Paso_ Line 64  void Paso_Solver_setPreconditioner(Paso_
64                prec->ilu=Paso_Solver_getILU(A,options->verbose);                prec->ilu=Paso_Solver_getILU(A,options->verbose);
65                prec->type=PASO_ILU0;                prec->type=PASO_ILU0;
66                break;                break;
67               case PASO_RILU:
68                  if (options->verbose) printf("RILU preconditioner is used.\n");
69                  prec->rilu=Paso_Solver_getRILU(A,options->verbose);
70                  prec->type=PASO_RILU;
71                  break;
72          }          }
73          if (! Paso_noError()) {          if (! Paso_noError()) {
74             Paso_Preconditioner_free(prec);             Paso_Preconditioner_free(prec);
75             A->iterative=NULL;             A->solver=NULL;
76          }          }
77      }      }
78  }  }
# Line 62  void Paso_Solver_setPreconditioner(Paso_ Line 81  void Paso_Solver_setPreconditioner(Paso_
81  /* has to be called within a parallel reqion */  /* 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 */  /* 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){  void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b){
84      Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->iterative;      Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->solver;
85      #pragma omp barrier      #pragma omp barrier
86      switch (prec->type) {      switch (prec->type) {
87          default:          default:
# Line 72  void Paso_Solver_solvePreconditioner(Pas Line 91  void Paso_Solver_solvePreconditioner(Pas
91          case PASO_ILU0:          case PASO_ILU0:
92             Paso_Solver_solveILU(prec->ilu,x,b);             Paso_Solver_solveILU(prec->ilu,x,b);
93             break;             break;
94            case PASO_RILU:
95               Paso_Solver_solveRILU(prec->rilu,x,b);
96               break;
97      }      }
98  }  }
99    

Legend:
Removed from v.155  
changed lines
  Added in v.633

  ViewVC Help
Powered by ViewVC 1.1.26