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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2802 - (hide annotations)
Thu Dec 3 01:51:55 2009 UTC (10 years, 2 months ago) by artak
File MIME type: text/plain
File size: 20008 byte(s)
Aggressive coarsening is implemented. Removes more elements but adds more iteration steps.
1 jfenwick 1851
2     /*******************************************************
3     *
4 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
5 jfenwick 1851 * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13    
14    
15     /**************************************************************/
16    
17 artak 2475 /* Paso: AMG preconditioner */
18 jfenwick 1851
19     /**************************************************************/
20    
21 jfenwick 2625 /* Author: artak@uq.edu.au */
22 jfenwick 1851
23     /**************************************************************/
24    
25     #include "Paso.h"
26     #include "Solver.h"
27 artak 2475 #include "Options.h"
28 jfenwick 1851 #include "PasoUtil.h"
29 artak 1931 #include "UMFPACK.h"
30 artak 2507 #include "MKL.h"
31     #include "SystemMatrix.h"
32 phornby 1917 #include "Pattern_coupling.h"
33 jfenwick 1851
34     /**************************************************************/
35    
36     /* free all memory used by AMG */
37    
38 artak 2659 void Paso_Solver_AMG_System_free(Paso_Solver_AMG_System * in) {
39 artak 2662 dim_t i;
40 artak 2659 if (in!=NULL) {
41 artak 2662 for (i=0;i<in->block_size;++i) {
42     Paso_Solver_AMG_free(in->amgblock[i]);
43 artak 2670 Paso_SparseMatrix_free(in->block[i]);
44 artak 2662 }
45 artak 2659 MEMFREE(in);
46     }
47     }
48    
49    
50     /* free all memory used by AMG */
51    
52 jfenwick 1851 void Paso_Solver_AMG_free(Paso_Solver_AMG * in) {
53     if (in!=NULL) {
54 artak 2112 Paso_Solver_Jacobi_free(in->GS);
55 jfenwick 1851 Paso_SparseMatrix_free(in->A_FC);
56 artak 2760 Paso_SparseMatrix_free(in->A_FF);
57     Paso_SparseMatrix_free(in->W_FC);
58 jfenwick 1851 Paso_SparseMatrix_free(in->A_CF);
59 artak 2760 Paso_SparseMatrix_free(in->P);
60     Paso_SparseMatrix_free(in->R);
61 artak 2556 Paso_SparseMatrix_free(in->A);
62 artak 2711 if(in->coarsest_level==TRUE) {
63     #ifdef MKL
64     Paso_MKL_free1(in->AOffset1);
65     Paso_SparseMatrix_free(in->AOffset1);
66     #else
67     #ifdef UMFPACK
68     Paso_UMFPACK1_free((Paso_UMFPACK_Handler*)(in->solver));
69     #endif
70     #endif
71     }
72 jfenwick 1851 MEMFREE(in->rows_in_F);
73     MEMFREE(in->rows_in_C);
74     MEMFREE(in->mask_F);
75     MEMFREE(in->mask_C);
76     MEMFREE(in->x_F);
77     MEMFREE(in->b_F);
78     MEMFREE(in->x_C);
79     MEMFREE(in->b_C);
80 gross 2551 in->solver=NULL;
81 artak 2760 Paso_Solver_AMG_free(in->AMG_of_Coarse);
82 gross 2551 MEMFREE(in->b_C);
83 jfenwick 1851 MEMFREE(in);
84     }
85     }
86    
87     /**************************************************************/
88    
89     /* constructs the block-block factorization of
90    
91     [ A_FF A_FC ]
92     A_p=
93     [ A_CF A_FF ]
94    
95     to
96    
97     [ I 0 ] [ A_FF 0 ] [ I invA_FF*A_FF ]
98     [ A_CF*invA_FF I ] [ 0 S ] [ 0 I ]
99    
100    
101     where S=A_FF-ACF*invA_FF*A_FC within the shape of S
102    
103     then AMG is applied to S again until S becomes empty
104    
105     */
106 artak 2520 Paso_Solver_AMG* Paso_Solver_getAMG(Paso_SparseMatrix *A_p,dim_t level,Paso_Options* options) {
107 jfenwick 1851 Paso_Solver_AMG* out=NULL;
108 artak 2760 /*
109     Paso_Pattern* temp1=NULL;
110 artak 2556 Paso_Pattern* temp2=NULL;
111 artak 2760 */
112 artak 2520 bool_t verbose=options->verbose;
113 jfenwick 1851 dim_t n=A_p->numRows;
114     dim_t n_block=A_p->row_block_size;
115     index_t* mis_marker=NULL;
116 artak 1881 index_t* counter=NULL;
117 artak 2760 /*index_t iPtr,*index, *where_p;*/
118     dim_t i;
119     Paso_SparseMatrix * A_c=NULL;
120 artak 2765 double time0=0;
121 artak 2784 Paso_SparseMatrix * Atemp=NULL;
122     double sparsity=0;
123 artak 2475
124 artak 2760 /*
125     double *temp,*temp_1;
126     double S;
127     index_t iptr;
128     */
129     /*char filename[8];*/
130     /*sprintf(filename,"AMGLevel%d",level);
131 artak 2726
132 artak 2760 Paso_SparseMatrix_saveMM(A_p,filename);
133 artak 2726 */
134    
135 artak 2439 /*Make sure we have block sizes 1*/
136 gross 2550 if (A_p->col_block_size>1) {
137     Paso_setError(TYPE_ERROR,"Paso_Solver_getAMG: AMG requires column block size 1.");
138     return NULL;
139     }
140     if (A_p->row_block_size>1) {
141     Paso_setError(TYPE_ERROR,"Paso_Solver_getAMG: AMG requires row block size 1.");
142     return NULL;
143     }
144 gross 2551 out=MEMALLOC(1,Paso_Solver_AMG);
145 jfenwick 1851 /* identify independend set of rows/columns */
146     mis_marker=TMPMEMALLOC(n,index_t);
147     counter=TMPMEMALLOC(n,index_t);
148 gross 2551 if ( !( Paso_checkPtr(mis_marker) || Paso_checkPtr(counter) || Paso_checkPtr(out)) ) {
149 artak 2760 out->AMG_of_Coarse=NULL;
150     out->A_FF=NULL;
151 gross 2551 out->A_FC=NULL;
152     out->A_CF=NULL;
153 artak 2760 out->W_FC=NULL;
154     out->P=NULL;
155     out->R=NULL;
156 gross 2551 out->rows_in_F=NULL;
157     out->rows_in_C=NULL;
158     out->mask_F=NULL;
159     out->mask_C=NULL;
160     out->x_F=NULL;
161     out->b_F=NULL;
162     out->x_C=NULL;
163     out->b_C=NULL;
164     out->GS=NULL;
165     out->A=Paso_SparseMatrix_getReference(A_p);
166     out->GS=NULL;
167     out->solver=NULL;
168     /*out->GS=Paso_Solver_getGS(A_p,verbose);*/
169     out->level=level;
170 artak 2661 out->n=n;
171 artak 2726 out->n_F=n+1;
172 artak 2661 out->n_block=n_block;
173 artak 2556
174 artak 2784 sparsity=(A_p->len*1.)/(1.*A_p->numRows*A_p->numCols);
175    
176     if (verbose) fprintf(stdout,"Stats: Sparsity of the Coarse Matrix with %d non-zeros (%d,%d) in level %d is %.6f\n",A_p->len,A_p->numRows,A_p->numCols,level,sparsity);
177    
178 artak 2802
179     if(sparsity>0.01) {
180 artak 2784 level=0;
181     }
182    
183 artak 2802
184 gross 2551 if (level==0 || n<=options->min_coarse_matrix_size) {
185     out->coarsest_level=TRUE;
186 artak 2784 /*out->GS=Paso_Solver_getJacobi(A_p);*/
187    
188 artak 2712 #ifdef MKL
189 artak 2711 out->AOffset1=Paso_SparseMatrix_alloc(MATRIX_FORMAT_BLK1 + MATRIX_FORMAT_OFFSET1, out->A->pattern,1,1, FALSE);
190     #pragma omp parallel for private(i) schedule(static)
191     for (i=0;i<out->A->len;++i) {
192     out->AOffset1->val[i]=out->A->val[i];
193     }
194 artak 2712 #else
195     #ifdef UMFPACK
196     #else
197 gross 2551 out->GS=Paso_Solver_getJacobi(A_p);
198     #endif
199     #endif
200 artak 2784
201 gross 2551 } else {
202     out->coarsest_level=FALSE;
203     out->GS=Paso_Solver_getJacobi(A_p);
204 artak 2442
205 gross 2551 /* identify independend set of rows/columns */
206     #pragma omp parallel for private(i) schedule(static)
207     for (i=0;i<n;++i) mis_marker[i]=-1;
208    
209 artak 2765 /*mesuring coarsening time */
210     time0=Paso_timer();
211    
212 gross 2551 if (options->coarsening_method == PASO_YAIR_SHAPIRA_COARSENING) {
213 artak 2652 Paso_Pattern_YS(A_p,mis_marker,options->coarsening_threshold);
214 gross 2551 }
215     else if (options->coarsening_method == PASO_RUGE_STUEBEN_COARSENING) {
216     Paso_Pattern_RS(A_p,mis_marker,options->coarsening_threshold);
217     }
218     else if (options->coarsening_method == PASO_AGGREGATION_COARSENING) {
219     Paso_Pattern_Aggregiation(A_p,mis_marker,options->coarsening_threshold);
220     }
221     else {
222     /*Default coarseneing*/
223 artak 2802 /*Paso_Pattern_RS_MI_Aggressive(A_p,mis_marker,options->coarsening_threshold);*/
224 artak 2760 Paso_Pattern_RS_MI(A_p,mis_marker,options->coarsening_threshold);
225 artak 2659 /*Paso_Pattern_YS(A_p,mis_marker,options->coarsening_threshold);*/
226 artak 2760 /*Paso_Pattern_RS(A_p,mis_marker,options->coarsening_threshold);*/
227 artak 2726 /*Paso_Pattern_Aggregiation(A_p,mis_marker,options->coarsening_threshold);*/
228 artak 2760
229 gross 2551 }
230 artak 2765
231 artak 2784 if (verbose) fprintf(stdout,"timing: Profilining for level %d:\n",level);
232 artak 2767
233 artak 2765 time0=Paso_timer()-time0;
234 artak 2784 if (verbose) fprintf(stdout,"timing: Coarsening: %e\n",time0);
235 artak 2760
236 artak 2686 #pragma omp parallel for private(i) schedule(static)
237     for (i = 0; i < n; ++i) counter[i]=mis_marker[i];
238 artak 2726
239 artak 2686 out->n_F=Paso_Util_cumsum(n,counter);
240    
241 artak 2726 if (out->n_F==0) {
242 artak 2686 out->coarsest_level=TRUE;
243 artak 2726 level=0;
244 artak 2686 if (verbose) {
245 artak 2726 /*printf("AMG coarsening eliminates all unknowns, switching to Jacobi preconditioner.\n");*/
246     printf("AMG coarsening does not eliminate any of the unknowns, switching to Jacobi preconditioner.\n");
247 artak 2686 }
248 artak 2726 }
249     else if (out->n_F==n) {
250     out->coarsest_level=TRUE;
251     level=0;
252     if (verbose) {
253     /*printf("AMG coarsening eliminates all unknowns, switching to Jacobi preconditioner.\n");*/
254     printf("AMG coarsening eliminates all of the unknowns, switching to Jacobi preconditioner.\n");
255    
256     }
257 artak 2686 } else {
258 artak 2475
259 artak 2686 if (Paso_noError()) {
260    
261     /*#pragma omp parallel for private(i) schedule(static)
262     for (i = 0; i < n; ++i) counter[i]=mis_marker[i];
263     out->n_F=Paso_Util_cumsum(n,counter);
264     */
265 artak 2760
266 artak 2686 out->mask_F=MEMALLOC(n,index_t);
267     out->rows_in_F=MEMALLOC(out->n_F,index_t);
268 artak 2760 if (! (Paso_checkPtr(out->mask_F) || Paso_checkPtr(out->rows_in_F) ) ) {
269 artak 2686 /* creates an index for F from mask */
270     #pragma omp parallel for private(i) schedule(static)
271     for (i = 0; i < out->n_F; ++i) out->rows_in_F[i]=-1;
272     #pragma omp parallel for private(i) schedule(static)
273     for (i = 0; i < n; ++i) {
274     if (mis_marker[i]) {
275     out->rows_in_F[counter[i]]=i;
276     out->mask_F[i]=counter[i];
277     } else {
278     out->mask_F[i]=-1;
279     }
280     }
281    
282 jfenwick 1851 }
283     }
284 artak 2802
285     /*if(level==1) {
286     printf("##TOTAL: %d, ELIMINATED: %d\n",n,out->n_F);
287     for (i = 0; i < n; ++i) {
288     printf("##%d %d\n",i,mis_marker[i]);
289     }
290     }
291     */
292 artak 2686 /*check whether coarsening process actually makes sense to continue.
293     if coarse matrix at least smaller by 30% then continue, otherwise we stop.*/
294     if ((out->n_F*100/n)<30) {
295     level=1;
296 artak 1881 }
297 gross 2551
298 artak 2686 if ( Paso_noError()) {
299     out->n_C=n-out->n_F;
300     out->rows_in_C=MEMALLOC(out->n_C,index_t);
301     out->mask_C=MEMALLOC(n,index_t);
302     if (! (Paso_checkPtr(out->mask_C) || Paso_checkPtr(out->rows_in_C) ) ) {
303     /* creates an index for C from mask */
304     #pragma omp parallel for private(i) schedule(static)
305     for (i = 0; i < n; ++i) counter[i]=! mis_marker[i];
306     Paso_Util_cumsum(n,counter);
307     #pragma omp parallel for private(i) schedule(static)
308     for (i = 0; i < out->n_C; ++i) out->rows_in_C[i]=-1;
309     #pragma omp parallel for private(i) schedule(static)
310     for (i = 0; i < n; ++i) {
311     if (! mis_marker[i]) {
312     out->rows_in_C[counter[i]]=i;
313     out->mask_C[i]=counter[i];
314     } else {
315     out->mask_C[i]=-1;
316     }
317     }
318     }
319     }
320     if ( Paso_noError()) {
321 artak 2760 /* get A_FF block: */
322     /*
323     out->A_FF=Paso_SparseMatrix_getSubmatrix(A_p,out->n_F,out->n_F,out->rows_in_F,out->mask_F);
324 artak 2686 out->A_CF=Paso_SparseMatrix_getSubmatrix(A_p,out->n_C,out->n_F,out->rows_in_C,out->mask_F);
325     out->A_FC=Paso_SparseMatrix_getSubmatrix(A_p,out->n_F,out->n_C,out->rows_in_F,out->mask_C);
326 artak 2760 */
327    
328     /*Compute W_FC*/
329     /*initialy W_FC=A_FC*/
330     out->W_FC=Paso_SparseMatrix_getSubmatrix(A_p,out->n_F,out->n_C,out->rows_in_F,out->mask_C);
331    
332     /*sprintf(filename,"W_FCbefore_%d",level);
333     Paso_SparseMatrix_saveMM(out->W_FC,filename);
334     */
335 artak 2802 /* for (i = 0; i < n; ++i) {
336     printf("##mis_marker[%d]=%d\n",i,mis_marker[i]);
337     }
338     */
339 artak 2765 time0=Paso_timer();
340 artak 2760 Paso_SparseMatrix_updateWeights(A_p,out->W_FC,mis_marker);
341 artak 2765 time0=Paso_timer()-time0;
342 artak 2784 if (verbose) fprintf(stdout,"timing: updateWeights: %e\n",time0);
343 artak 2765
344 artak 2802
345     /*sprintf(filename,"W_FCafter_%d",level);
346 artak 2760 Paso_SparseMatrix_saveMM(out->W_FC,filename);
347     */
348 artak 2802
349 artak 2760 /* get Prolongation and Restriction */
350 artak 2765 time0=Paso_timer();
351 artak 2760 out->P=Paso_SparseMatrix_getProlongation(out->W_FC,mis_marker);
352 artak 2765 time0=Paso_timer()-time0;
353 artak 2784 if (verbose) fprintf(stdout,"timing: getProlongation: %e\n",time0);
354 artak 2760
355 artak 2802
356    
357     /* sprintf(filename,"P_%d",level);
358 artak 2760 Paso_SparseMatrix_saveMM(out->P,filename);
359     */
360    
361 artak 2765 time0=Paso_timer();
362 artak 2760 out->R=Paso_SparseMatrix_getRestriction(out->P);
363 artak 2765 time0=Paso_timer()-time0;
364 artak 2784 if (verbose) fprintf(stdout,"timing: getRestriction: %e\n",time0);
365 artak 2765
366 artak 2802
367     /*sprintf(filename,"R_%d",level);
368 artak 2760 Paso_SparseMatrix_saveMM(out->R,filename);
369     */
370    
371 gross 2551 }
372 artak 2686 if ( Paso_noError()) {
373 artak 2765
374     time0=Paso_timer();
375 artak 2784
376     Atemp=Paso_SparseMatrix_MatrixMatrix(A_p,out->P);
377     A_c=Paso_SparseMatrix_MatrixMatrix(out->R,Atemp);
378    
379     Paso_SparseMatrix_free(Atemp);
380    
381     /*A_c=Paso_Solver_getCoarseMatrix(A_p,out->R,out->P);*/
382 artak 2765 time0=Paso_timer()-time0;
383 artak 2784 if (verbose) fprintf(stdout,"timing: getCoarseMatrix: %e\n",time0);
384 artak 2765
385 artak 2784
386 artak 2760 /*Paso_Solver_getCoarseMatrix(A_c, A_p,out->R,out->P);*/
387 artak 2767
388 artak 2784
389     /*sprintf(filename,"A_C_%d",level);
390 artak 2760 Paso_SparseMatrix_saveMM(A_c,filename);
391 artak 2767 */
392    
393 artak 2760 out->AMG_of_Coarse=Paso_Solver_getAMG(A_c,level-1,options);
394 gross 2551 }
395 artak 2760
396 artak 2686 /* allocate work arrays for AMG application */
397     if (Paso_noError()) {
398 artak 2767 /*
399     out->x_F=MEMALLOC(n_block*out->n_F,double);
400 artak 2686 out->b_F=MEMALLOC(n_block*out->n_F,double);
401 artak 2767 */
402 artak 2686 out->x_C=MEMALLOC(n_block*out->n_C,double);
403     out->b_C=MEMALLOC(n_block*out->n_C,double);
404    
405 artak 2767 /*if (! (Paso_checkPtr(out->x_F) || Paso_checkPtr(out->b_F) || Paso_checkPtr(out->x_C) || Paso_checkPtr(out->b_C) ) ) {*/
406     if ( ! ( Paso_checkPtr(out->x_C) || Paso_checkPtr(out->b_C) ) ) {
407    
408     /*
409     #pragma omp parallel for private(i) schedule(static)
410 artak 2686 for (i = 0; i < out->n_F; ++i) {
411     out->x_F[i]=0.;
412     out->b_F[i]=0.;
413     }
414 artak 2767 */
415    
416 artak 2686 #pragma omp parallel for private(i) schedule(static)
417     for (i = 0; i < out->n_C; ++i) {
418     out->x_C[i]=0.;
419     out->b_C[i]=0.;
420     }
421     }
422     }
423 artak 2760 Paso_SparseMatrix_free(A_c);
424 artak 2686 }
425 jfenwick 1851 }
426     }
427     TMPMEMFREE(mis_marker);
428     TMPMEMFREE(counter);
429 artak 2686
430 jfenwick 1851 if (Paso_noError()) {
431 artak 2524 if (verbose && level>0 && !out->coarsest_level) {
432 gross 2551 printf("AMG: level: %d: %d unknowns eliminated. %d left.\n",level, out->n_F,out->n_C);
433 jfenwick 1851 }
434     return out;
435     } else {
436     Paso_Solver_AMG_free(out);
437     return NULL;
438     }
439     }
440    
441     /**************************************************************/
442    
443     /* apply AMG precondition b-> x
444    
445     in fact it solves
446    
447 artak 2381 [ I 0 ] [ A_FF 0 ] [ I invA_FF*A_FC ] [ x_F ] = [b_F]
448 jfenwick 1851 [ A_CF*invA_FF I ] [ 0 S ] [ 0 I ] [ x_C ] = [b_C]
449    
450     in the form
451    
452     b->[b_F,b_C]
453     x_F=invA_FF*b_F
454     b_C=b_C-A_CF*x_F
455     x_C=AMG(b_C)
456     b_F=b_F-A_FC*x_C
457     x_F=invA_FF*b_F
458     x<-[x_F,x_C]
459    
460     should be called within a parallel region
461     barrier synconization should be performed to make sure that the input vector available
462    
463     */
464    
465     void Paso_Solver_solveAMG(Paso_Solver_AMG * amg, double * x, double * b) {
466 artak 2107 dim_t i;
467 artak 2507 double time0=0;
468 gross 2551 double *r=NULL, *x0=NULL;
469 artak 2509 bool_t verbose=0;
470 artak 2784
471 artak 2699 #ifdef UMFPACK
472     Paso_UMFPACK_Handler * ptr=NULL;
473 artak 2507 #endif
474 artak 2760
475 artak 2784
476 gross 2551 r=MEMALLOC(amg->n,double);
477     x0=MEMALLOC(amg->n,double);
478 artak 2507
479 artak 2524 if (amg->coarsest_level) {
480 artak 2507
481     time0=Paso_timer();
482 artak 2699 /*If all unknown are eliminated then Jacobi is the best preconditioner*/
483 artak 2784 /*Paso_Solver_solveJacobi(amg->GS,x,b);*/
484    
485 artak 2726 if (amg->n_F==0 || amg->n_F==amg->n) {
486 artak 2699 Paso_Solver_solveJacobi(amg->GS,x,b);
487     }
488     else {
489 artak 2712 #ifdef MKL
490     Paso_MKL1(amg->AOffset1,x,b,verbose);
491     #else
492     #ifdef UMFPACK
493 gross 2551 ptr=(Paso_UMFPACK_Handler *)(amg->solver);
494 artak 2652 Paso_UMFPACK1(&ptr,amg->A,x,b,verbose);
495 gross 2551 amg->solver=(void*) ptr;
496 artak 2712 #else
497     Paso_Solver_solveJacobi(amg->GS,x,b);
498 artak 2699 #endif
499 artak 2507 #endif
500 artak 2699 }
501 artak 2784
502 artak 2475 time0=Paso_timer()-time0;
503 artak 2784 if (verbose) fprintf(stdout,"timing: DIRECT SOLVER: %e\n",time0);
504 artak 2507
505 jfenwick 1851 } else {
506 artak 1902 /* presmoothing */
507 artak 2507 time0=Paso_timer();
508 artak 2112 Paso_Solver_solveJacobi(amg->GS,x,b);
509 artak 2507 time0=Paso_timer()-time0;
510 artak 2784 if (verbose) fprintf(stdout,"timing: Presmooting: %e\n",time0);
511 artak 1931 /* end of presmoothing */
512 artak 1939
513 artak 2507
514     time0=Paso_timer();
515 artak 1890 #pragma omp parallel for private(i) schedule(static)
516     for (i=0;i<amg->n;++i) r[i]=b[i];
517    
518     /*r=b-Ax*/
519     Paso_SparseMatrix_MatrixVector_CSR_OFFSET0(-1.,amg->A,x,1.,r);
520 artak 2760
521    
522     /* b_c <- R*r */
523     Paso_SparseMatrix_MatrixVector_CSR_OFFSET0(1.,amg->R,r,0.,amg->b_C);
524 artak 1954
525 artak 2507 time0=Paso_timer()-time0;
526 artak 2784 if (verbose) fprintf(stdout,"timing: Before next level: %e\n",time0);
527 artak 2507
528 jfenwick 1851 /* x_C=AMG(b_C) */
529 artak 2760 Paso_Solver_solveAMG(amg->AMG_of_Coarse,amg->x_C,amg->b_C);
530 artak 1890
531 artak 2507 time0=Paso_timer();
532 artak 2726
533 artak 2760 /* x_0 <- P*x_c */
534     Paso_SparseMatrix_MatrixVector_CSR_OFFSET0(1.,amg->P,amg->x_C,0.,x0);
535    
536     /* x=x+x0 */
537 artak 1954 #pragma omp parallel for private(i) schedule(static)
538 artak 2760 for (i=0;i<amg->n;++i) x[i]+=x0[i];
539 artak 1954
540 artak 2767 /*postsmoothing*/
541     time0=Paso_timer();
542     #pragma omp parallel for private(i) schedule(static)
543     for (i=0;i<amg->n;++i) r[i]=b[i];
544    
545     /*r=b-Ax */
546     Paso_SparseMatrix_MatrixVector_CSR_OFFSET0(-1.,amg->A,x,1.,r);
547     Paso_Solver_solveJacobi(amg->GS,x0,r);
548    
549    
550     #pragma omp parallel for private(i) schedule(static)
551     for (i=0;i<amg->n;++i) {
552     x[i]+=x0[i];
553     }
554    
555     time0=Paso_timer()-time0;
556 artak 2784 if (verbose) fprintf(stdout,"timing: Postsmoothing: %e\n",time0);
557 artak 2767
558     /*end of postsmoothing*/
559 artak 2107
560 artak 2760 }
561 artak 1890 MEMFREE(r);
562 artak 1954 MEMFREE(x0);
563 artak 2760
564 gross 2551 return;
565 jfenwick 1851 }

  ViewVC Help
Powered by ViewVC 1.1.26