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

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

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

revision 3792 by caltinay, Thu Oct 27 03:41:51 2011 UTC revision 3793 by gross, Wed Feb 1 07:39:43 2012 UTC
# Line 71  Paso_Preconditioner_Smoother* Paso_Preco Line 71  Paso_Preconditioner_Smoother* Paso_Preco
71  Paso_Preconditioner_LocalSmoother* Paso_Preconditioner_LocalSmoother_alloc(Paso_SparseMatrix * A_p, const bool_t jacobi, bool_t verbose)  Paso_Preconditioner_LocalSmoother* Paso_Preconditioner_LocalSmoother_alloc(Paso_SparseMatrix * A_p, const bool_t jacobi, bool_t verbose)
72  {  {
73        
74     dim_t n=A_p->numRows;     const dim_t n=A_p->numRows;
75     dim_t n_block=A_p->row_block_size;     const dim_t n_block=A_p->row_block_size;
76     dim_t block_size=A_p->block_size;     const dim_t block_size=A_p->block_size;
77        
78     double time0=Esys_timer();     double time0=Esys_timer();
79     /* allocations: */       /* allocations: */  
# Line 137  void Paso_Preconditioner_Smoother_solve( Line 137  void Paso_Preconditioner_Smoother_solve(
137                
138     }     }
139  }  }
140    
141    err_t Paso_Preconditioner_Smoother_solve_byTolerance(Paso_SystemMatrix* A_p, Paso_Preconditioner_Smoother * smoother,
142                                double * x, const double * b,
143                                const double rtol, dim_t *sweeps, const bool_t x_is_initial)
144    {
145       const dim_t n= (A_p->mainBlock->numRows) * (A_p->mainBlock->row_block_size);
146       double *b_new = smoother->localSmoother->buffer;
147       const dim_t max_sweeps=*sweeps;
148       dim_t s=0;
149       double norm_b, norm_r;
150       err_t errorCode = PRECONDITIONER_NO_ERROR;
151      
152       norm_b=Paso_lsup(n,b,A_p->mpi_info);
153       if (! x_is_initial) {
154         Paso_Copy(n, x, b);
155         Paso_Preconditioner_LocalSmoother_Sweep(A_p->mainBlock,smoother->localSmoother,x);
156         s++;
157       }
158       while (1) {
159         Paso_Copy(n, b_new, b);
160             Paso_SystemMatrix_MatrixVector((-1.), A_p, x, 1., b_new); /* b_new = b - A*x */
161         norm_r=Paso_lsup(n,b,A_p->mpi_info);
162         if (norm_r <= rtol * norm_b ) break;
163         Paso_Preconditioner_LocalSmoother_Sweep(A_p->mainBlock,smoother->localSmoother,b_new);  
164         Paso_AXPY(n, x, 1., b_new);
165         s++;
166         if (s > max_sweeps) {
167              errorCode = PRECONDITIONER_MAXITER_REACHED;
168              break;
169         }
170       }
171       *sweeps=s;
172       return errorCode;
173    }
174    
175    
176    
177  void Paso_Preconditioner_LocalSmoother_solve(Paso_SparseMatrix* A_p, Paso_Preconditioner_LocalSmoother * smoother, double * x, const double * b,  void Paso_Preconditioner_LocalSmoother_solve(Paso_SparseMatrix* A_p, Paso_Preconditioner_LocalSmoother * smoother, double * x, const double * b,
178                           const dim_t sweeps, const bool_t x_is_initial)                           const dim_t sweeps, const bool_t x_is_initial)
179  {  {

Legend:
Removed from v.3792  
changed lines
  Added in v.3793

  ViewVC Help
Powered by ViewVC 1.1.26