/[escript]/branches/doubleplusgood/paso/src/TFQMR.cpp
ViewVC logotype

Diff of /branches/doubleplusgood/paso/src/TFQMR.cpp

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

revision 2557 by artak, Mon Jul 27 04:46:37 2009 UTC revision 2562 by artak, Tue Jul 28 01:25:12 2009 UTC
# Line 84  err_t Paso_Solver_TFQMR( Line 84  err_t Paso_Solver_TFQMR(
84    bool_t breakFlag=FALSE, maxIterFlag=FALSE, convergeFlag=FALSE;    bool_t breakFlag=FALSE, maxIterFlag=FALSE, convergeFlag=FALSE;
85    err_t status = SOLVER_NO_ERROR;    err_t status = SOLVER_NO_ERROR;
86    dim_t n = Paso_SystemMatrix_getTotalNumRows(A);    dim_t n = Paso_SystemMatrix_getTotalNumRows(A);
87    double  *u1=NULL, *u2=NULL, *y1=NULL, *y2=NULL, *d=NULL, *w=NULL, *v=NULL, *v_old=NULL;    double  *u1=NULL, *u2=NULL, *y1=NULL, *y2=NULL, *d=NULL, *w=NULL, *v=NULL, *v_old=NULL, *temp_vector=NULL,*res=NULL;
88    
89    double eta,theta,tau,rho,beta,alpha,sigma,rhon,c;    double eta,theta,tau,rho,beta,alpha,sigma,rhon,c;
90    
# Line 105  err_t Paso_Solver_TFQMR( Line 105  err_t Paso_Solver_TFQMR(
105    w=TMPMEMALLOC(n,double);    w=TMPMEMALLOC(n,double);
106    v=TMPMEMALLOC(n,double);    v=TMPMEMALLOC(n,double);
107    v_old=TMPMEMALLOC(n,double);    v_old=TMPMEMALLOC(n,double);
108        temp_vector=TMPMEMALLOC(n,double);
109      res=TMPMEMALLOC(n,double);
110    
111   if (u1 ==NULL || u2== NULL || y1 == NULL || y2== NULL || d==NULL || w==NULL || v==NULL || v_old==NULL) {   if (u1 ==NULL || u2== NULL || y1 == NULL || y2== NULL || d==NULL || w==NULL || v==NULL || v_old==NULL) {
112       status=SOLVER_MEMORY_ERROR;       status=SOLVER_MEMORY_ERROR;
# Line 119  err_t Paso_Solver_TFQMR( Line 120  err_t Paso_Solver_TFQMR(
120    }    }
121        
122    Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);    Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);
123    Paso_Solver_solvePreconditioner(A,r,r);    Paso_Solver_solvePreconditioner(A,res,r);
124    Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);    Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);
125        
126    Performance_startMonitor(pp,PERFORMANCE_SOLVER);    Performance_startMonitor(pp,PERFORMANCE_SOLVER);
# Line 127  err_t Paso_Solver_TFQMR( Line 128  err_t Paso_Solver_TFQMR(
128    Paso_zeroes(n,u2);    Paso_zeroes(n,u2);
129    Paso_zeroes(n,y2);    Paso_zeroes(n,y2);
130        
131    Paso_Copy(n,w,r);    Paso_Copy(n,w,res);
132    Paso_Copy(n,y1,r);    Paso_Copy(n,y1,res);
133                
134    Paso_zeroes(n,d);    Paso_zeroes(n,d);
135        
136    Performance_stopMonitor(pp,PERFORMANCE_SOLVER);    Performance_stopMonitor(pp,PERFORMANCE_SOLVER);
137    Performance_startMonitor(pp,PERFORMANCE_MVM);    Performance_startMonitor(pp,PERFORMANCE_MVM);
138    Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, y1,PASO_ZERO,v);    Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, y1,PASO_ZERO,temp_vector);
139    Performance_stopMonitor(pp,PERFORMANCE_MVM);    Performance_stopMonitor(pp,PERFORMANCE_MVM);
140    Performance_startMonitor(pp,PERFORMANCE_SOLVER);    Performance_startMonitor(pp,PERFORMANCE_SOLVER);
141        
142    Performance_stopMonitor(pp,PERFORMANCE_SOLVER);    Performance_stopMonitor(pp,PERFORMANCE_SOLVER);
143    Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);    Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);
144    Paso_Solver_solvePreconditioner(A,v,v);    Paso_Solver_solvePreconditioner(A,v,temp_vector);
145    Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);    Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);
146    Performance_startMonitor(pp,PERFORMANCE_SOLVER);    Performance_startMonitor(pp,PERFORMANCE_SOLVER);
147        
# Line 149  err_t Paso_Solver_TFQMR( Line 150  err_t Paso_Solver_TFQMR(
150    theta = 0.0;    theta = 0.0;
151    eta = 0.0;    eta = 0.0;
152        
153    tau = Paso_l2(n,r,A->mpi_info);    tau = Paso_l2(n,res,A->mpi_info);
154        
155    rho = tau * tau;    rho = tau * tau;
156                
# Line 159  err_t Paso_Solver_TFQMR( Line 160  err_t Paso_Solver_TFQMR(
160    {    {
161                        
162    
163       sigma=Paso_InnerProduct(n,r,v,A->mpi_info);       sigma=Paso_InnerProduct(n,res,v,A->mpi_info);
164            
165       if (! (breakFlag = (ABS(sigma) == 0.))) {       if (! (breakFlag = (ABS(sigma) == 0.))) {
166            
# Line 173  err_t Paso_Solver_TFQMR( Line 174  err_t Paso_Solver_TFQMR(
174                        
175            Performance_stopMonitor(pp,PERFORMANCE_SOLVER);            Performance_stopMonitor(pp,PERFORMANCE_SOLVER);
176            Performance_startMonitor(pp,PERFORMANCE_MVM);            Performance_startMonitor(pp,PERFORMANCE_MVM);
177            Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, y2,PASO_ZERO,u2);            Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, y2,PASO_ZERO,temp_vector);
178            Performance_stopMonitor(pp,PERFORMANCE_MVM);            Performance_stopMonitor(pp,PERFORMANCE_MVM);
179            Performance_startMonitor(pp,PERFORMANCE_SOLVER);            Performance_startMonitor(pp,PERFORMANCE_SOLVER);
180                        
181            Performance_stopMonitor(pp,PERFORMANCE_SOLVER);            Performance_stopMonitor(pp,PERFORMANCE_SOLVER);
182            Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);            Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);
183            Paso_Solver_solvePreconditioner(A,u2,u2);            Paso_Solver_solvePreconditioner(A,u2,temp_vector);
184            Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);            Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);
185            Performance_startMonitor(pp,PERFORMANCE_SOLVER);            Performance_startMonitor(pp,PERFORMANCE_SOLVER);
186           }           }
# Line 202  err_t Paso_Solver_TFQMR( Line 203  err_t Paso_Solver_TFQMR(
203    
204       breakFlag = (ABS(rho) == 0);       breakFlag = (ABS(rho) == 0);
205    
206       rhon = Paso_InnerProduct(n,r,w,A->mpi_info);       rhon = Paso_InnerProduct(n,res,w,A->mpi_info);
207       beta = rhon / rho;       beta = rhon / rho;
208       rho = rhon;       rho = rhon;
209        
# Line 211  err_t Paso_Solver_TFQMR( Line 212  err_t Paso_Solver_TFQMR(
212       Performance_stopMonitor(pp,PERFORMANCE_SOLVER);       Performance_stopMonitor(pp,PERFORMANCE_SOLVER);
213            
214       Performance_startMonitor(pp,PERFORMANCE_MVM);       Performance_startMonitor(pp,PERFORMANCE_MVM);
215       Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, y1,PASO_ZERO,u1);       Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, y1,PASO_ZERO,temp_vector);
216       Performance_stopMonitor(pp,PERFORMANCE_MVM);       Performance_stopMonitor(pp,PERFORMANCE_MVM);
217            
218       Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);       Performance_startMonitor(pp,PERFORMANCE_PRECONDITIONER);
219       Paso_Solver_solvePreconditioner(A,u1,u1);       Paso_Solver_solvePreconditioner(A,u1,temp_vector);
220       Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);       Performance_stopMonitor(pp,PERFORMANCE_PRECONDITIONER);
221            
222       Performance_startMonitor(pp,PERFORMANCE_SOLVER);       Performance_startMonitor(pp,PERFORMANCE_SOLVER);
# Line 248  err_t Paso_Solver_TFQMR( Line 249  err_t Paso_Solver_TFQMR(
249      TMPMEMFREE(w);      TMPMEMFREE(w);
250      TMPMEMFREE(v);      TMPMEMFREE(v);
251      TMPMEMFREE(v_old);      TMPMEMFREE(v_old);
252          TMPMEMFREE(temp_vector);
253        TMPMEMFREE(res);
254      *iter=num_iter;      *iter=num_iter;
255      *tolerance=norm_of_residual;      *tolerance=norm_of_residual;
256            

Legend:
Removed from v.2557  
changed lines
  Added in v.2562

  ViewVC Help
Powered by ViewVC 1.1.26