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

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

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

revision 2381 by artak, Tue Apr 14 03:46:59 2009 UTC revision 2479 by gross, Thu Jun 18 06:50:37 2009 UTC
# Line 54  void Paso_Solver(Paso_SystemMatrix* A,do Line 54  void Paso_Solver(Paso_SystemMatrix* A,do
54     dim_t numSol = Paso_SystemMatrix_getTotalNumCols(A);     dim_t numSol = Paso_SystemMatrix_getTotalNumCols(A);
55     dim_t numEqua = Paso_SystemMatrix_getTotalNumRows(A);     dim_t numEqua = Paso_SystemMatrix_getTotalNumRows(A);
56     double blocktimer_precond, blocktimer_start = blocktimer_time();     double blocktimer_precond, blocktimer_start = blocktimer_time();
57    
58    
59       Paso_resetError();       Paso_resetError();
60       tolerance=options->tolerance;       tolerance=options->tolerance;
# Line 75  void Paso_Solver(Paso_SystemMatrix* A,do Line 76  void Paso_Solver(Paso_SystemMatrix* A,do
76          Paso_setError(TYPE_ERROR,"Paso_Solver: Iterative solver requires a square matrix.");          Paso_setError(TYPE_ERROR,"Paso_Solver: Iterative solver requires a square matrix.");
77          return;          return;
78       }       }
79         time_iter=Paso_timer();
80       /* this for testing only */       /* this for testing only */
81       if (method==PASO_NONLINEAR_GMRES) {       if (method==PASO_NONLINEAR_GMRES) {
82          Paso_Function* F=NULL;          Paso_Function* F=NULL;
# Line 162  void Paso_Solver(Paso_SystemMatrix* A,do Line 164  void Paso_Solver(Paso_SystemMatrix* A,do
164              Paso_Solver_setPreconditioner(A,options);              Paso_Solver_setPreconditioner(A,options);
165              Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER_INIT);              Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER_INIT);
166              blocktimer_increment("Paso_Solver_setPreconditioner()", blocktimer_precond);              blocktimer_increment("Paso_Solver_setPreconditioner()", blocktimer_precond);
167                options->set_up_time=Paso_timer()-time_iter;
168              if (! Paso_noError()) return;              if (! Paso_noError()) return;
               time_iter=Paso_timer();  
169                /* get an initial guess by evaluating the preconditioner */                /* get an initial guess by evaluating the preconditioner */
170                Paso_Solver_solvePreconditioner(A,x,b);                Paso_Solver_solvePreconditioner(A,x,b);
171                /* start the iteration process :*/                /* start the iteration process :*/
# Line 207  void Paso_Solver(Paso_SystemMatrix* A,do Line 209  void Paso_Solver(Paso_SystemMatrix* A,do
209                          MPI_Allreduce(&loc_norm,&norm_max_of_residual, 1, MPI_DOUBLE, MPI_MAX, A->mpi_info->comm);                          MPI_Allreduce(&loc_norm,&norm_max_of_residual, 1, MPI_DOUBLE, MPI_MAX, A->mpi_info->comm);
210                      #endif                      #endif
211                      norm2_of_residual =sqrt(norm2_of_residual);                      norm2_of_residual =sqrt(norm2_of_residual);
212                        options->residual_norm=norm2_of_residual;
213                            
214                    if (options->verbose) printf("Paso_Solver: Step %5d: l2/lmax-norm of residual is  %e/%e",totIter,norm2_of_residual,norm_max_of_residual);                    if (options->verbose) printf("Paso_Solver: Step %5d: l2/lmax-norm of residual is  %e/%e",totIter,norm2_of_residual,norm_max_of_residual);
215                    if (totIter>1 && norm2_of_residual>=last_norm2_of_residual &&  norm_max_of_residual>=last_norm_max_of_residual) {                    if (totIter>1 && norm2_of_residual>=last_norm2_of_residual &&  norm_max_of_residual>=last_norm_max_of_residual) {
# Line 261  void Paso_Solver(Paso_SystemMatrix* A,do Line 264  void Paso_Solver(Paso_SystemMatrix* A,do
264                          }                          }
265                        } else {                        } else {
266                           if (options->verbose) printf(". convergence! \n");                           if (options->verbose) printf(". convergence! \n");
267                             options->converged=TRUE;
268                        }                        }
269                     }                     }
270                   } /* while */                   } /* while */
271                }                }
272                MEMFREE(r);                MEMFREE(r);
273                time_iter=Paso_timer()-time_iter;                options->num_level=0;
274                if (options->verbose)  {                options->num_inner_iter=0;
275                 printf("\ntiming: Paso_Solver:  %.4e sec\n",time_iter);                options->num_iter=totIter;
                if (Paso_noError()) {  
                  if (totIter>1) {  
                     if(totIter==options->iter_max) {  
                         printf("timing: Total MAX steps, time per iteration step: %.4e sec\n",time_iter/totIter);  
                     } else {  
                         printf("timing: Total %d steps, time per iteration step: %.4e sec\n",totIter,time_iter/totIter);      
                     }  
                  }  
                  else {  
                     printf("timing: Total 1 step, time per iteration step: %.4e sec\n",time_iter);  
                     }    
                }  
                else {  
                    printf("timing: Total: Diverged.\n");  
                }  
               }  
276             }             }
277          }          }
278        }        }
279       options->time=Paso_timer()-time_iter;
280     Performance_stopMonitor(pp,PERFORMANCE_ALL);     Performance_stopMonitor(pp,PERFORMANCE_ALL);
281     blocktimer_increment("Paso_Solver()", blocktimer_start);     blocktimer_increment("Paso_Solver()", blocktimer_start);
282    
283  }  }

Legend:
Removed from v.2381  
changed lines
  Added in v.2479

  ViewVC Help
Powered by ViewVC 1.1.26