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

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

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

trunk/paso/src/Solver_preconditioner.c revision 3119 by gross, Thu Aug 26 06:49:42 2010 UTC trunk/paso/src/Preconditioner.c revision 3120 by gross, Mon Aug 30 10:48:00 2010 UTC
# Line 25  Line 25 
25    
26  #include "Paso.h"  #include "Paso.h"
27  #include "SystemMatrix.h"  #include "SystemMatrix.h"
 #include "Solver.h"  
28  #include "PasoUtil.h"  #include "PasoUtil.h"
29    #include "Preconditioner.h"
30    
31  /***********************************************************************************/  /***********************************************************************************/
32    
# Line 46  void Paso_Preconditioner_free(Paso_Solve Line 46  void Paso_Preconditioner_free(Paso_Solve
46      }      }
47  }  }
48    
49    Paso_Solver_Preconditioner* Paso_Preconditioner_alloc(Paso_SystemMatrix* A,Paso_Options* options) {
 /*  call the iterative solver: */  
   
 void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options) {  
50    
51      Paso_Solver_Preconditioner* prec=NULL;      Paso_Solver_Preconditioner* prec=NULL;
52      dim_t i;      dim_t i;
     /*char filename[7];*/  
     if (A->solver==NULL) {  
         /* allocate structure to hold preconditioner */  
         prec=MEMALLOC(1,Paso_Solver_Preconditioner);  
53    
54          if (Paso_checkPtr(prec)) return;      prec=MEMALLOC(1,Paso_Solver_Preconditioner);
55    
56        if (! Paso_checkPtr(prec)) {
57                    
58          prec->type=UNKNOWN;          prec->type=UNKNOWN;
59          prec->rilu=NULL;          prec->rilu=NULL;
# Line 71  void Paso_Solver_setPreconditioner(Paso_ Line 66  void Paso_Solver_setPreconditioner(Paso_
66          prec->amliSystem=NULL;          prec->amliSystem=NULL;
67      if (options->verbose && options->use_local_preconditioner) printf("Apply preconditioner locally only.\n");      if (options->verbose && options->use_local_preconditioner) printf("Apply preconditioner locally only.\n");
68    
         A->solver=prec;  
69          switch (options->preconditioner) {          switch (options->preconditioner) {
70             default:             default:
71             case PASO_JACOBI:             case PASO_JACOBI:
# Line 136  void Paso_Solver_setPreconditioner(Paso_ Line 130  void Paso_Solver_setPreconditioner(Paso_
130              case PASO_AMLI:              case PASO_AMLI:
131                        
132            prec->amliSystem=MEMALLOC(1,Paso_Solver_AMLI_System);            prec->amliSystem=MEMALLOC(1,Paso_Solver_AMLI_System);
133                if (Paso_checkPtr(prec->amliSystem)) return;                if (! Paso_checkPtr(prec->amliSystem)) {
134                                    
135                prec->amliSystem->block_size=A->row_block_size;                prec->amliSystem->block_size=A->row_block_size;
136                                
# Line 158  void Paso_Solver_setPreconditioner(Paso_ Line 152  void Paso_Solver_setPreconditioner(Paso_
152                  }                  }
153                }                }
154                prec->type=PASO_AMLI;                prec->type=PASO_AMLI;
155              }
156                break;                break;
157    
158          }          }
159          if (! Paso_MPIInfo_noError(A->mpi_info ) ){      }
160              Paso_Preconditioner_free(prec);      if (! Paso_MPIInfo_noError(A->mpi_info ) ){
161              A->solver=NULL;           Paso_Preconditioner_free(prec);
162          }      return NULL;
163        } else {
164        return prec;
165      }      }
166  }  }
167    
168  /* applies the preconditioner */  /* applies the preconditioner */
169  /* has to be called within a parallel reqion */  /* has to be called within a parallel reqion */
170  /* 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 */
171  void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b){  void Paso_Preconditioner_solve(Paso_Solver_Preconditioner* prec, Paso_SystemMatrix* A,double* x,double* b){
     Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->solver;  
172      dim_t i,j;      dim_t i,j;
173      dim_t n=A->mainBlock->numRows;      dim_t n=A->mainBlock->numRows;
   
       
   
   
174      switch (prec->type) {      switch (prec->type) {
175          default:          default:
176          case PASO_JACOBI:          case PASO_JACOBI:

Legend:
Removed from v.3119  
changed lines
  Added in v.3120

  ViewVC Help
Powered by ViewVC 1.1.26