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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26