/[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

trunk/esys2/paso/src/Solvers/Solver_preconditioner.c revision 150 by jgs, Thu Sep 15 03:44:45 2005 UTC trunk/paso/src/Solver_preconditioner.c revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 UTC
# Line 1  Line 1 
1    
2  /* $Id$ */  /* $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           */  /* Paso: SystemMatrix: sets-up the preconditioner           */
# Line 22  Line 35 
35  void Paso_Preconditioner_free(Paso_Solver_Preconditioner* in) {  void Paso_Preconditioner_free(Paso_Solver_Preconditioner* in) {
36      if (in!=NULL) {      if (in!=NULL) {
37        Paso_Solver_ILU_free(in->ilu);        Paso_Solver_ILU_free(in->ilu);
38          Paso_Solver_RILU_free(in->rilu);
39        Paso_Solver_Jacobi_free(in->jacobi);        Paso_Solver_Jacobi_free(in->jacobi);
40        MEMFREE(in);        MEMFREE(in);
41      }      }
# Line 30  void Paso_Preconditioner_free(Paso_Solve Line 44  void Paso_Preconditioner_free(Paso_Solve
44    
45  void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options) {  void Paso_Solver_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options) {
46      Paso_Solver_Preconditioner* prec=NULL;      Paso_Solver_Preconditioner* prec=NULL;
47      if (A->iterative==NULL) {      if (A->solver==NULL) {
48          /* allocate structure to hold preconditioner */          /* allocate structure to hold preconditioner */
49          prec=MEMALLOC(1,Paso_Solver_Preconditioner);          prec=MEMALLOC(1,Paso_Solver_Preconditioner);
50          if (Paso_checkPtr(prec)) return;          if (Paso_checkPtr(prec)) return;
51          prec->type=UNKNOWN;          prec->type=UNKNOWN;
52            prec->rilu=NULL;
53          prec->ilu=NULL;          prec->ilu=NULL;
54          prec->jacobi=NULL;          prec->jacobi=NULL;
55          A->iterative=prec;          A->solver=prec;
56          switch (options->preconditioner) {          switch (options->preconditioner) {
57             default:             default:
58             case PASO_JACOBI:             case PASO_JACOBI:
59                if (options->verbose) printf("Jacobi preconditioner is used.\n");                if (options->verbose) printf("Jacobi preconditioner is used.\n");
60                prec->jacobi=Paso_Solver_getJacobi(A);                prec->jacobi=Paso_Solver_getJacobi(A->mainBlock);
61                prec->type=PASO_JACOBI;                prec->type=PASO_JACOBI;
62                break;                break;
63             case PASO_ILU0:             case PASO_ILU0:
64                if (options->verbose) printf("ILU preconditioner is used.\n");                if (options->verbose) printf("ILU preconditioner is used.\n");
65                prec->ilu=Paso_Solver_getILU(A,options->verbose);                prec->ilu=Paso_Solver_getILU(A->mainBlock,options->verbose);
66                prec->type=PASO_ILU0;                prec->type=PASO_ILU0;
67                break;                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_noError()) {          if (! Paso_MPIInfo_noError(A->mpi_info ) ){
75             Paso_Preconditioner_free(prec);             Paso_Preconditioner_free(prec);
76             A->iterative=NULL;             A->solver=NULL;
77          }          }
78      }      }
79  }  }
# Line 62  void Paso_Solver_setPreconditioner(Paso_ Line 82  void Paso_Solver_setPreconditioner(Paso_
82  /* has to be called within a parallel reqion */  /* 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 */  /* 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){  void Paso_Solver_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b){
85      Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->iterative;      Paso_Solver_Preconditioner* prec=(Paso_Solver_Preconditioner*) A->solver;
86      #pragma omp barrier      #pragma omp barrier
87      switch (prec->type) {      switch (prec->type) {
88          default:          default:
# Line 72  void Paso_Solver_solvePreconditioner(Pas Line 92  void Paso_Solver_solvePreconditioner(Pas
92          case PASO_ILU0:          case PASO_ILU0:
93             Paso_Solver_solveILU(prec->ilu,x,b);             Paso_Solver_solveILU(prec->ilu,x,b);
94             break;             break;
95            case PASO_RILU:
96               Paso_Solver_solveRILU(prec->rilu,x,b);
97               break;
98      }      }
99  }  }
   
 /*  
  * $Log$  
  * Revision 1.2  2005/09/15 03:44:40  jgs  
  * Merge of development branch dev-02 back to main trunk on 2005-09-15  
  *  
  * Revision 1.1.2.2  2005/09/07 00:59:09  gross  
  * some inconsistent renaming fixed to make the linking work.  
  *  
  * Revision 1.1.2.1  2005/09/05 06:29:50  gross  
  * These files have been extracted from finley to define a stand alone libray for iterative  
  * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but  
  * has not been tested yet.  
  *  
  *  
  */  

Legend:
Removed from v.150  
changed lines
  Added in v.1312

  ViewVC Help
Powered by ViewVC 1.1.26