/[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 2111 by artak, Fri Nov 28 04:39:07 2008 UTC revision 2112 by artak, Mon Dec 1 02:53:58 2008 UTC
# Line 35  Line 35 
35  void Paso_Solver_AMG_free(Paso_Solver_AMG * in) {  void Paso_Solver_AMG_free(Paso_Solver_AMG * in) {
36       if (in!=NULL) {       if (in!=NULL) {
37          Paso_Solver_AMG_free(in->AMG_of_Schur);          Paso_Solver_AMG_free(in->AMG_of_Schur);
38          Paso_Solver_ILU_free(in->GS);          Paso_Solver_Jacobi_free(in->GS);
39          MEMFREE(in->inv_A_FF);          MEMFREE(in->inv_A_FF);
40          MEMFREE(in->A_FF_pivot);          MEMFREE(in->A_FF_pivot);
41          Paso_SparseMatrix_free(in->A_FC);          Paso_SparseMatrix_free(in->A_FC);
# Line 103  Paso_Solver_AMG* Paso_Solver_getAMG(Paso Line 103  Paso_Solver_AMG* Paso_Solver_getAMG(Paso
103    out->b_C=NULL;    out->b_C=NULL;
104    out->GS=NULL;    out->GS=NULL;
105    out->A=Paso_SparseMatrix_getReference(A_p);    out->A=Paso_SparseMatrix_getReference(A_p);
106    out->GS=Paso_Solver_getILU(A_p,verbose);    /*out->GS=Paso_Solver_getGS(A_p,verbose);*/
107    /*out->GS=Paso_Solver_getJacobi(A_p);*/    out->GS=Paso_Solver_getJacobi(A_p);
108    /*out->GS->sweeps=2;*/    /*out->GS->sweeps=2;*/
109    out->level=level;    out->level=level;
110        
# Line 155  Paso_Solver_AMG* Paso_Solver_getAMG(Paso Line 155  Paso_Solver_AMG* Paso_Solver_getAMG(Paso
155             if( Paso_noError()) {             if( Paso_noError()) {
156                /* if there are no nodes in the coarse level there is no more work to do */                /* if there are no nodes in the coarse level there is no more work to do */
157                out->n_C=n-out->n_F;                out->n_C=n-out->n_F;
158                /*if (level<5) {*/                if (level<3) {
159                 if (out->n_F>50) {                 /*if (out->n_F>500) {*/
160                     out->rows_in_C=MEMALLOC(out->n_C,index_t);                     out->rows_in_C=MEMALLOC(out->n_C,index_t);
161                     out->mask_C=MEMALLOC(n,index_t);                     out->mask_C=MEMALLOC(n,index_t);
162                     if (! (Paso_checkPtr(out->mask_C) || Paso_checkPtr(out->rows_in_C) ) ) {                     if (! (Paso_checkPtr(out->mask_C) || Paso_checkPtr(out->rows_in_C) ) ) {
# Line 184  Paso_Solver_AMG* Paso_Solver_getAMG(Paso Line 184  Paso_Solver_AMG* Paso_Solver_getAMG(Paso
184                           if (Paso_noError()) {                           if (Paso_noError()) {
185                              schur=Paso_SparseMatrix_getSubmatrix(A_p,out->n_C,out->n_C,out->rows_in_C,out->mask_C);                              schur=Paso_SparseMatrix_getSubmatrix(A_p,out->n_C,out->n_C,out->rows_in_C,out->mask_C);
186                              /*find the pattern of the schur complement with fill in*/                              /*find the pattern of the schur complement with fill in*/
187                                
188                              schur_withFillIn=Paso_SparseMatrix_alloc(A_p->type,Paso_Pattern_binop(PATTERN_FORMAT_DEFAULT, schur->pattern, Paso_Pattern_multiply(PATTERN_FORMAT_DEFAULT,out->A_CF->pattern,out->A_FC->pattern)),1,1);                              schur_withFillIn=Paso_SparseMatrix_alloc(A_p->type,Paso_Pattern_binop(PATTERN_FORMAT_DEFAULT, schur->pattern, Paso_Pattern_multiply(PATTERN_FORMAT_DEFAULT,out->A_CF->pattern,out->A_FC->pattern)),1,1);
189                                                            
190                              fprintf(stderr,"Sparsity of Schure: %dx%d LEN %d Percentage %f\n",schur_withFillIn->pattern->numOutput,schur_withFillIn->pattern->numInput,schur_withFillIn->len,schur_withFillIn->len/(1.*schur_withFillIn->pattern->numOutput*schur_withFillIn->pattern->numInput));                              fprintf(stderr,"Sparsity of Schure: %dx%d LEN %d Percentage %f\n",schur_withFillIn->pattern->numOutput,schur_withFillIn->pattern->numInput,schur_withFillIn->len,schur_withFillIn->len/(1.*schur_withFillIn->pattern->numOutput*schur_withFillIn->pattern->numInput));
# Line 250  Paso_Solver_AMG* Paso_Solver_getAMG(Paso Line 250  Paso_Solver_AMG* Paso_Solver_getAMG(Paso
250    if (Paso_noError()) {    if (Paso_noError()) {
251        if (verbose) {        if (verbose) {
252           printf("AMG: %d unknowns eliminated. %d left.\n",out->n_F,n-out->n_F);           printf("AMG: %d unknowns eliminated. %d left.\n",out->n_F,n-out->n_F);
253           /*if (level<5) {*/           if (level<3) {
254           if (out->n_F<50) {           /*if (out->n_F<500) {*/
255              printf("timing: AMG: MIS/reordering/elemination : %e/%e/%e\n",time2,time0,time1);              printf("timing: AMG: MIS/reordering/elemination : %e/%e/%e\n",time2,time0,time1);
256           } else {           } else {
257              printf("timing: AMG: MIS: %e\n",time2);              printf("timing: AMG: MIS: %e\n",time2);
# Line 295  void Paso_Solver_solveAMG(Paso_Solver_AM Line 295  void Paso_Solver_solveAMG(Paso_Solver_AM
295       double *x0=MEMALLOC(amg->n,double);       double *x0=MEMALLOC(amg->n,double);
296       double time0=0;       double time0=0;
297            
298       /*if (amg->level==5) {*/       if (amg->level==3) {
299       if (amg->n_F<=50) {       /*if (amg->n_F<=500) {*/
300        time0=Paso_timer();        time0=Paso_timer();
301                    
302          /*Paso_Solver_solveJacobi(amg->GS,x,b);*/          Paso_Solver_solveJacobi(amg->GS,x,b);
303                    
304          /* #pragma omp parallel for private(i) schedule(static)          /* #pragma omp parallel for private(i) schedule(static)
305          for (i=0;i<amg->n;++i) r[i]=b[i];          for (i=0;i<amg->n;++i) r[i]=b[i];
# Line 310  void Paso_Solver_solveAMG(Paso_Solver_AM Line 310  void Paso_Solver_solveAMG(Paso_Solver_AM
310           x[i]+=x0[i];           x[i]+=x0[i];
311          }          }
312          */          */
313          Paso_UMFPACK1(amg->A,x,b,0);          /*Paso_UMFPACK1(amg->A,x,b,0);*/
314    
315         time0=Paso_timer()-time0;         time0=Paso_timer()-time0;
316         /*fprintf(stderr,"timing: DIRECT SOLVER: %e/\n",time0);*/         /*fprintf(stderr,"timing: DIRECT SOLVER: %e/\n",time0);*/
317       } else {       } else {
318            
319          /* presmoothing */          /* presmoothing */
320           Paso_Solver_solveILU(amg->GS,x,b);           Paso_Solver_solveJacobi(amg->GS,x,b);
321           /*           /*
322           #pragma omp parallel for private(i) schedule(static)           #pragma omp parallel for private(i) schedule(static)
323           for (i=0;i<amg->n;++i) r[i]=b[i];           for (i=0;i<amg->n;++i) r[i]=b[i];
# Line 377  void Paso_Solver_solveAMG(Paso_Solver_AM Line 377  void Paso_Solver_solveAMG(Paso_Solver_AM
377            
378       /*r=b-Ax*/       /*r=b-Ax*/
379       Paso_SparseMatrix_MatrixVector_CSR_OFFSET0(-1.,amg->A,x,1.,r);       Paso_SparseMatrix_MatrixVector_CSR_OFFSET0(-1.,amg->A,x,1.,r);
380       Paso_Solver_solveILU(amg->GS,x0,r);       Paso_Solver_solveJacobi(amg->GS,x0,r);
381            
382       #pragma omp parallel for private(i) schedule(static)       #pragma omp parallel for private(i) schedule(static)
383       for (i=0;i<amg->n;++i) x[i]+=x0[i];       for (i=0;i<amg->n;++i) x[i]+=x0[i];

Legend:
Removed from v.2111  
changed lines
  Added in v.2112

  ViewVC Help
Powered by ViewVC 1.1.26