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

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

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

revision 2698 by artak, Tue Sep 29 03:39:36 2009 UTC revision 2699 by artak, Wed Sep 30 05:43:20 2009 UTC
# Line 51  void Paso_Solver_AMG_System_free(Paso_So Line 51  void Paso_Solver_AMG_System_free(Paso_So
51    
52  void Paso_Solver_AMG_free(Paso_Solver_AMG * in) {  void Paso_Solver_AMG_free(Paso_Solver_AMG * in) {
53       if (in!=NULL) {       if (in!=NULL) {
         Paso_Solver_AMG_free(in->AMG_of_Schur);  
54          Paso_Solver_Jacobi_free(in->GS);          Paso_Solver_Jacobi_free(in->GS);
55          MEMFREE(in->inv_A_FF);          MEMFREE(in->inv_A_FF);
56          MEMFREE(in->A_FF_pivot);          MEMFREE(in->A_FF_pivot);
# Line 66  void Paso_Solver_AMG_free(Paso_Solver_AM Line 65  void Paso_Solver_AMG_free(Paso_Solver_AM
65          MEMFREE(in->b_F);          MEMFREE(in->b_F);
66          MEMFREE(in->x_C);          MEMFREE(in->x_C);
67          MEMFREE(in->b_C);          MEMFREE(in->b_C);
68          #ifdef MKL          #ifdef UMFPACK
69          #else          Paso_UMFPACK1_free((Paso_UMFPACK_Handler*)(in->solver));
            #ifdef UMFPACK  
            Paso_UMFPACK1_free((Paso_UMFPACK_Handler*)(in->solver));  
            #endif  
70          #endif          #endif
71          in->solver=NULL;          in->solver=NULL;
72            Paso_Solver_AMG_free(in->AMG_of_Schur);
73          MEMFREE(in->b_C);          MEMFREE(in->b_C);
74          MEMFREE(in);          MEMFREE(in);
75       }       }
# Line 150  Paso_Solver_AMG* Paso_Solver_getAMG(Paso Line 147  Paso_Solver_AMG* Paso_Solver_getAMG(Paso
147            
148       if (level==0 || n<=options->min_coarse_matrix_size) {       if (level==0 || n<=options->min_coarse_matrix_size) {
149           out->coarsest_level=TRUE;           out->coarsest_level=TRUE;
150           #ifdef MKL           #ifdef UMFPACK
151           #else           #else
152              #ifdef UMFPACK              #ifdef MKL
153              #else              #else
154                  out->GS=Paso_Solver_getJacobi(A_p);                  out->GS=Paso_Solver_getJacobi(A_p);
155              #endif              #endif
# Line 188  Paso_Solver_AMG* Paso_Solver_getAMG(Paso Line 185  Paso_Solver_AMG* Paso_Solver_getAMG(Paso
185          if (out->n_F==n) {          if (out->n_F==n) {
186             out->coarsest_level=TRUE;             out->coarsest_level=TRUE;
187             if (verbose) {             if (verbose) {
188                 printf("AMG coarsening eliminates all unknowns, switching to direct solver.\n");                 printf("AMG coarsening eliminates all unknowns, switching to Jacobi preconditioner.\n");
189             }             }
190          } else {          } else {
191            
# Line 370  void Paso_Solver_solveAMG(Paso_Solver_AM Line 367  void Paso_Solver_solveAMG(Paso_Solver_AM
367       double time0=0;       double time0=0;
368       double *r=NULL, *x0=NULL;       double *r=NULL, *x0=NULL;
369       bool_t verbose=0;       bool_t verbose=0;
370       #ifdef MKL       #ifdef UMFPACK
371          Paso_SparseMatrix *temp=NULL;            Paso_UMFPACK_Handler * ptr=NULL;
372       #else       #else    
373          #ifdef UMFPACK          #ifdef MKL
374             Paso_UMFPACK_Handler * ptr=NULL;            Paso_SparseMatrix *temp=NULL;
375          #endif          #endif
376       #endif       #endif
377       r=MEMALLOC(amg->n,double);       r=MEMALLOC(amg->n,double);
# Line 383  void Paso_Solver_solveAMG(Paso_Solver_AM Line 380  void Paso_Solver_solveAMG(Paso_Solver_AM
380       if (amg->coarsest_level) {       if (amg->coarsest_level) {
381                
382        time0=Paso_timer();        time0=Paso_timer();
383         #ifdef MKL        /*If all unknown are eliminated then Jacobi is the best preconditioner*/
384          temp=Paso_SparseMatrix_alloc(MATRIX_FORMAT_BLK1 + MATRIX_FORMAT_OFFSET1, amg->A->pattern,1,1, FALSE);        if (amg->n_F==amg->n) {
385          #pragma omp parallel for private(i) schedule(static)          Paso_Solver_solveJacobi(amg->GS,x,b);
386          for (i=0;i<amg->A->len;++i) {        }
387               temp->val[i]=amg->A->val[i];         else {
388          }         #ifdef UMFPACK
         Paso_MKL1(temp,x,b,0);  
         Paso_SparseMatrix_free(temp);  
        #else  
           #ifdef UMFPACK  
389               ptr=(Paso_UMFPACK_Handler *)(amg->solver);               ptr=(Paso_UMFPACK_Handler *)(amg->solver);
390               Paso_UMFPACK1(&ptr,amg->A,x,b,verbose);               Paso_UMFPACK1(&ptr,amg->A,x,b,verbose);
391               amg->solver=(void*) ptr;               amg->solver=(void*) ptr;
392            #else         #else      
393               Paso_Solver_solveJacobi(amg->GS,x,b);           #ifdef MKL
394            #endif            ptr=(Paso_MKL_Handler *)(amg->solver);
395              temp=Paso_SparseMatrix_alloc(MATRIX_FORMAT_BLK1 + MATRIX_FORMAT_OFFSET1, amg->A->pattern,1,1, FALSE);
396              #pragma omp parallel for private(i) schedule(static)
397              for (i=0;i<amg->A->len;++i) {
398                   temp->val[i]=amg->A->val[i];
399              }
400              Paso_MKL1(ptr,temp,x,b,verbose);
401              amg->solver=(void*) ptr;
402              Paso_SparseMatrix_free(temp);
403             #else
404              Paso_Solver_solveJacobi(amg->GS,x,b);
405             #endif
406         #endif         #endif
407           }
408         time0=Paso_timer()-time0;         time0=Paso_timer()-time0;
409         if (verbose) fprintf(stderr,"timing: DIRECT SOLVER: %e\n",time0);         if (verbose) fprintf(stderr,"timing: DIRECT SOLVER: %e\n",time0);
410                

Legend:
Removed from v.2698  
changed lines
  Added in v.2699

  ViewVC Help
Powered by ViewVC 1.1.26