Fast Auxiliary Space Preconditioning 2.7.7 Aug/28/2022
SolBSR.c
Go to the documentation of this file.
1
17#include <time.h>
18
19#ifdef _OPENMP
20#include <omp.h>
21#endif
22
23#include "fasp.h"
24#include "fasp_functs.h"
25
26/*---------------------------------*/
27/*-- Declare Private Functions --*/
28/*---------------------------------*/
29
30#include "KryUtil.inl"
31
32/*---------------------------------*/
33/*-- Public Functions --*/
34/*---------------------------------*/
35
56 dvector *b,
57 dvector *x,
58 precond *pc,
59 ITS_param *itparam)
60{
61 const SHORT prtlvl = itparam->print_level;
62 const SHORT itsolver_type = itparam->itsolver_type;
63 const SHORT stop_type = itparam->stop_type;
64 const SHORT restart = itparam->restart;
65 const INT MaxIt = itparam->maxit;
66 const REAL tol = itparam->tol;
67
68 // Local variables
70 REAL solve_start, solve_end;
71
72#if DEBUG_MODE > 0
73 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
74 printf("### DEBUG: rhs/sol size: %d %d\n", b->row, x->row);
75#endif
76
77 fasp_gettime(&solve_start);
78
79 /* Safe-guard checks on parameters */
80 ITS_CHECK ( MaxIt, tol );
81
82 switch (itsolver_type) {
83
84 case SOLVER_CG:
85 iter = fasp_solver_dbsr_pcg(A, b, x, pc, tol, MaxIt, stop_type, prtlvl);
86 break;
87
88 case SOLVER_BiCGstab:
89 iter = fasp_solver_dbsr_pbcgs(A, b, x, pc, tol, MaxIt, stop_type, prtlvl);
90 break;
91
92 case SOLVER_GMRES:
93 iter = fasp_solver_dbsr_pgmres(A, b, x, pc, tol, MaxIt, restart, stop_type, prtlvl);
94 break;
95
96 case SOLVER_VGMRES:
97 iter = fasp_solver_dbsr_pvgmres(A, b, x, pc, tol, MaxIt, restart, stop_type, prtlvl);
98 break;
99
100 case SOLVER_VFGMRES:
101 iter = fasp_solver_dbsr_pvfgmres(A, b, x, pc, tol, MaxIt, restart, stop_type, prtlvl);
102 break;
103
104 default:
105 printf("### ERROR: Unknown iterative solver type %d! [%s]\n",
106 itsolver_type, __FUNCTION__);
107 return ERROR_SOLVER_TYPE;
108
109 }
110
111 if ( (prtlvl > PRINT_MIN) && (iter >= 0) ) {
112 fasp_gettime(&solve_end);
113 fasp_cputime("Iterative method", solve_end - solve_start);
114 }
115
116#if DEBUG_MODE > 0
117 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
118#endif
119
120 return iter;
121}
122
140 dvector *b,
141 dvector *x,
142 ITS_param *itparam)
143{
144 const SHORT prtlvl = itparam->print_level;
145 INT status = FASP_SUCCESS;
146 REAL solve_start, solve_end;
147
148#if DEBUG_MODE > 0
149 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
150#endif
151
152 // solver part
153 fasp_gettime(&solve_start);
154
155 status=fasp_solver_dbsr_itsolver(A,b,x,NULL,itparam);
156
157 fasp_gettime(&solve_end);
158
159 if ( prtlvl > PRINT_NONE )
160 fasp_cputime("Krylov method totally", solve_end - solve_start);
161
162#if DEBUG_MODE > 0
163 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
164#endif
165
166 return status;
167}
168
188 dvector *b,
189 dvector *x,
190 ITS_param *itparam)
191{
192 const SHORT prtlvl = itparam->print_level;
193 INT status = FASP_SUCCESS;
194 REAL solve_start, solve_end;
195
196 INT nb=A->nb,i,k;
197 INT nb2=nb*nb;
198 INT ROW=A->ROW;
199
200#ifdef _OPENMP
201 // variables for OpenMP
202 INT myid, mybegin, myend;
203 INT nthreads = fasp_get_num_threads();
204#endif
205 // setup preconditioner
206 precond_diag_bsr diag;
207 fasp_dvec_alloc(ROW*nb2, &(diag.diag));
208
209#if DEBUG_MODE > 0
210 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
211#endif
212
213 // get all the diagonal sub-blocks
214#ifdef _OPENMP
215 if (ROW > OPENMP_HOLDS) {
216#pragma omp parallel for private(myid, mybegin, myend, i, k)
217 for (myid=0; myid<nthreads; ++myid) {
218 fasp_get_start_end(myid, nthreads, ROW, &mybegin, &myend);
219 for (i = mybegin; i < myend; ++i) {
220 for (k = A->IA[i]; k < A->IA[i+1]; ++k) {
221 if (A->JA[k] == i)
222 memcpy(diag.diag.val+i*nb2, A->val+k*nb2, nb2*sizeof(REAL));
223 }
224 }
225 }
226 }
227 else {
228#endif
229 for (i = 0; i < ROW; ++i) {
230 for (k = A->IA[i]; k < A->IA[i+1]; ++k) {
231 if (A->JA[k] == i)
232 memcpy(diag.diag.val+i*nb2, A->val+k*nb2, nb2*sizeof(REAL));
233 }
234 }
235#ifdef _OPENMP
236 }
237#endif
238
239 diag.nb=nb;
240
241#ifdef _OPENMP
242#pragma omp parallel for if(ROW>OPENMP_HOLDS)
243#endif
244 for (i=0; i<ROW; ++i){
245 fasp_smat_inv(&(diag.diag.val[i*nb2]), nb);
246 }
247
248 precond *pc = (precond *)fasp_mem_calloc(1,sizeof(precond));
249 pc->data = &diag;
251
252 // solver part
253 fasp_gettime(&solve_start);
254
255 status=fasp_solver_dbsr_itsolver(A,b,x,pc,itparam);
256
257 fasp_gettime(&solve_end);
258
259 if ( prtlvl > PRINT_NONE )
260 fasp_cputime("Diag_Krylov method totally", solve_end - solve_start);
261
262 // clean up
263 fasp_dvec_free(&(diag.diag));
264
265#if DEBUG_MODE > 0
266 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
267#endif
268
269 return status;
270}
271
290 dvector *b,
291 dvector *x,
292 ITS_param *itparam,
293 ILU_param *iluparam)
294{
295 const SHORT prtlvl = itparam->print_level;
296 REAL solve_start, solve_end;
297 INT status = FASP_SUCCESS;
298
299 ILU_data LU;
300 precond pc;
301
302#if DEBUG_MODE > 0
303 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
304 printf("### DEBUG: matrix size: %d %d %d\n", A->ROW, A->COL, A->NNZ);
305 printf("### DEBUG: rhs/sol size: %d %d\n", b->row, x->row);
306#endif
307
308 fasp_gettime(&solve_start);
309
310 // ILU setup for whole matrix
311 if ( (status = fasp_ilu_dbsr_setup(A, &LU, iluparam)) < 0 ) goto FINISHED;
312
313 // check iludata
314 if ( (status = fasp_mem_iludata_check(&LU)) < 0 ) goto FINISHED;
315
316 // set preconditioner
317 pc.data = &LU; pc.fct = fasp_precond_dbsr_ilu;
318
319 // solve
320 status = fasp_solver_dbsr_itsolver(A, b, x, &pc, itparam);
321
322 fasp_gettime(&solve_end);
323
324 if ( prtlvl > PRINT_NONE )
325 fasp_cputime("ILUk_Krylov method totally", solve_end - solve_start);
326
327FINISHED:
329
330#if DEBUG_MODE > 0
331 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
332#endif
333
334 return status;
335}
336
355 dvector *b,
356 dvector *x,
357 ITS_param *itparam,
358 AMG_param *amgparam)
359{
360 //--------------------------------------------------------------
361 // Part 1: prepare
362 // --------------------------------------------------------------
363
365 const SHORT prtlvl = itparam->print_level;
366 const SHORT max_levels = amgparam->max_levels;
367
368 // return variable
369 INT status = FASP_SUCCESS;
370
371 // data of AMG
372 AMG_data_bsr *mgl = fasp_amg_data_bsr_create(max_levels);
373
374 // timing
375 REAL setup_start, setup_end, solve_end;
376
377#if DEBUG_MODE > 0
378 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
379#endif
380
381 //--------------------------------------------------------------
382 //Part 2: set up the preconditioner
383 //--------------------------------------------------------------
384 fasp_gettime(&setup_start);
385
386 // initialize A, b, x for mgl[0]
387 mgl[0].A = fasp_dbsr_create(A->ROW, A->COL, A->NNZ, A->nb, A->storage_manner);
388 mgl[0].b = fasp_dvec_create(mgl[0].A.ROW*mgl[0].A.nb);
389 mgl[0].x = fasp_dvec_create(mgl[0].A.COL*mgl[0].A.nb);
390
391 fasp_dbsr_cp(A, &(mgl[0].A));
392
393 switch (amgparam->AMG_type) {
394
395 case SA_AMG: // Smoothed Aggregation AMG
396 status = fasp_amg_setup_sa_bsr(mgl, amgparam); break;
397
398 default:
399 status = fasp_amg_setup_ua_bsr(mgl, amgparam); break;
400
401 }
402
403 if (status < 0) goto FINISHED;
404
405 precond_data_bsr precdata;
406 precdata.print_level = amgparam->print_level;
407 precdata.maxit = amgparam->maxit;
408 precdata.tol = amgparam->tol;
409 precdata.cycle_type = amgparam->cycle_type;
410 precdata.smoother = amgparam->smoother;
411 precdata.presmooth_iter = amgparam->presmooth_iter;
412 precdata.postsmooth_iter = amgparam->postsmooth_iter;
413 precdata.coarsening_type = amgparam->coarsening_type;
414 precdata.relaxation = amgparam->relaxation;
415 precdata.coarse_scaling = amgparam->coarse_scaling;
416 precdata.amli_degree = amgparam->amli_degree;
417 precdata.amli_coef = amgparam->amli_coef;
418 precdata.tentative_smooth = amgparam->tentative_smooth;
419 precdata.max_levels = mgl[0].num_levels;
420 precdata.mgl_data = mgl;
421 precdata.A = A;
422
423 precond prec;
424 prec.data = &precdata;
425 switch (amgparam->cycle_type) {
426 case NL_AMLI_CYCLE: // Nonlinear AMLI AMG
427 prec.fct = fasp_precond_dbsr_namli; break;
428 default: // V,W-Cycle AMG
429 prec.fct = fasp_precond_dbsr_amg; break;
430 }
431
432 fasp_gettime(&setup_end);
433
434 if ( prtlvl >= PRINT_MIN )
435 fasp_cputime("BSR AMG setup", setup_end - setup_start);
436
437 //--------------------------------------------------------------
438 // Part 3: solver
439 //--------------------------------------------------------------
440 status = fasp_solver_dbsr_itsolver(A,b,x,&prec,itparam);
441
442 fasp_gettime(&solve_end);
443
444 if ( prtlvl >= PRINT_MIN )
445 fasp_cputime("BSR Krylov method", solve_end - setup_start);
446
447FINISHED:
449
450#if DEBUG_MODE > 0
451 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
452#endif
453
454 if ( status == ERROR_ALLOC_MEM ) goto MEMORY_ERROR;
455 return status;
456
457MEMORY_ERROR:
458 printf("### ERROR: Cannot allocate memory! [%s]\n", __FUNCTION__);
459 exit(status);
460}
461
484 dvector *b,
485 dvector *x,
486 ITS_param *itparam,
487 AMG_param *amgparam,
488 dCSRmat *A_nk,
489 dCSRmat *P_nk,
490 dCSRmat *R_nk)
491{
492 //--------------------------------------------------------------
493 // Part 1: prepare
494 // --------------------------------------------------------------
495 // parameters of iterative method
496 const SHORT prtlvl = itparam->print_level;
497 const SHORT max_levels = amgparam->max_levels;
498
499 // return variable
500 INT status = FASP_SUCCESS;
501
502 // data of AMG
503 AMG_data_bsr *mgl=fasp_amg_data_bsr_create(max_levels);
504
505 // timing
506 REAL setup_start, setup_end, setup_time;
507 REAL solve_start, solve_end, solve_time;
508
509#if DEBUG_MODE > 0
510 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
511#endif
512
513 //--------------------------------------------------------------
514 //Part 2: set up the preconditioner
515 //--------------------------------------------------------------
516 fasp_gettime(&setup_start);
517
518 // initialize A, b, x for mgl[0]
519 mgl[0].A = fasp_dbsr_create(A->ROW, A->COL, A->NNZ, A->nb, A->storage_manner);
520 fasp_dbsr_cp(A, &(mgl[0].A));
521 mgl[0].b = fasp_dvec_create(mgl[0].A.ROW*mgl[0].A.nb);
522 mgl[0].x = fasp_dvec_create(mgl[0].A.COL*mgl[0].A.nb);
523
524 // near kernel space
525 mgl[0].A_nk = NULL;
526 mgl[0].P_nk = P_nk;
527 mgl[0].R_nk = R_nk;
528
529 switch (amgparam->AMG_type) {
530
531 case SA_AMG: // Smoothed Aggregation AMG
532 status = fasp_amg_setup_sa_bsr(mgl, amgparam); break;
533
534 default:
535 status = fasp_amg_setup_ua_bsr(mgl, amgparam); break;
536
537 }
538
539 if (status < 0) goto FINISHED;
540
541 precond_data_bsr precdata;
542 precdata.print_level = amgparam->print_level;
543 precdata.maxit = amgparam->maxit;
544 precdata.tol = amgparam->tol;
545 precdata.cycle_type = amgparam->cycle_type;
546 precdata.smoother = amgparam->smoother;
547 precdata.presmooth_iter = amgparam->presmooth_iter;
548 precdata.postsmooth_iter = amgparam->postsmooth_iter;
549 precdata.coarsening_type = amgparam->coarsening_type;
550 precdata.relaxation = amgparam->relaxation;
551 precdata.coarse_scaling = amgparam->coarse_scaling;
552 precdata.amli_degree = amgparam->amli_degree;
553 precdata.amli_coef = amgparam->amli_coef;
554 precdata.tentative_smooth = amgparam->tentative_smooth;
555 precdata.max_levels = mgl[0].num_levels;
556 precdata.mgl_data = mgl;
557 precdata.A = A;
558
559#if WITH_UMFPACK // use UMFPACK directly
560 dCSRmat A_tran;
561 A_tran = fasp_dcsr_create(A_nk->row, A_nk->col, A_nk->nnz);
562 fasp_dcsr_transz(A_nk, NULL, &A_tran);
563 // It is equivalent to do transpose and then sort
564 // fasp_dcsr_trans(A_nk, &A_tran);
565 // fasp_dcsr_sort(&A_tran);
566 precdata.A_nk = &A_tran;
567#else
568 precdata.A_nk = A_nk;
569#endif
570
571 precdata.P_nk = P_nk;
572 precdata.R_nk = R_nk;
573
574 if (status < 0) goto FINISHED;
575
576 precond prec;
577 prec.data = &precdata;
578
580
581 fasp_gettime(&setup_end);
582
583 setup_time = setup_end - setup_start;
584
585 if ( prtlvl >= PRINT_MIN ) fasp_cputime("BSR AMG setup", setup_time);
586
587 //--------------------------------------------------------------
588 // Part 3: solver
589 //--------------------------------------------------------------
590 fasp_gettime(&solve_start);
591
592 status=fasp_solver_dbsr_itsolver(A,b,x,&prec,itparam);
593
594 fasp_gettime(&solve_end);
595
596 solve_time = solve_end - solve_start;
597
598 if ( prtlvl >= PRINT_MIN ) {
599 fasp_cputime("BSR Krylov method", setup_time+solve_time);
600 }
601
602FINISHED:
604
605#if DEBUG_MODE > 0
606 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
607#endif
608
609#if WITH_UMFPACK // use UMFPACK directly
610 fasp_dcsr_free(&A_tran);
611#endif
612 if (status == ERROR_ALLOC_MEM) goto MEMORY_ERROR;
613 return status;
614
615MEMORY_ERROR:
616 printf("### ERROR: Cannot allocate memory! [%s]\n", __FUNCTION__);
617 exit(status);
618}
619
641 dvector *b,
642 dvector *x,
643 ITS_param *itparam,
644 AMG_param *amgparam,
645 const INT nk_dim,
646 dvector *nk)
647{
648 //--------------------------------------------------------------
649 // Part 1: prepare
650 // --------------------------------------------------------------
652 const SHORT prtlvl = itparam->print_level;
653 const SHORT max_levels = amgparam->max_levels;
654
655 // local variable
656 INT i;
657
658 // return variable
659 INT status = FASP_SUCCESS;
660
661 // data of AMG
662 AMG_data_bsr *mgl=fasp_amg_data_bsr_create(max_levels);
663
664 // timing
665 REAL setup_start, setup_end, setup_time;
666 REAL solve_start, solve_end, solve_time;
667
668#if DEBUG_MODE > 0
669 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
670#endif
671
672 //--------------------------------------------------------------
673 //Part 2: set up the preconditioner
674 //--------------------------------------------------------------
675 fasp_gettime(&setup_start);
676
677 // initialize A, b, x for mgl[0]
678 mgl[0].A = fasp_dbsr_create(A->ROW, A->COL, A->NNZ, A->nb, A->storage_manner);
679 fasp_dbsr_cp(A, &(mgl[0].A));
680 mgl[0].b = fasp_dvec_create(mgl[0].A.ROW*mgl[0].A.nb);
681 mgl[0].x = fasp_dvec_create(mgl[0].A.COL*mgl[0].A.nb);
682
683 /*-----------------------*/
684 /*-- setup null spaces --*/
685 /*-----------------------*/
686
687 // null space for whole Jacobian
688 mgl[0].near_kernel_dim = nk_dim;
689 mgl[0].near_kernel_basis = (REAL **)fasp_mem_calloc(mgl->near_kernel_dim, sizeof(REAL*));
690
691 for ( i=0; i < mgl->near_kernel_dim; ++i ) mgl[0].near_kernel_basis[i] = nk[i].val;
692
693 switch (amgparam->AMG_type) {
694
695 case SA_AMG: // Smoothed Aggregation AMG
696 status = fasp_amg_setup_sa_bsr(mgl, amgparam); break;
697
698 default:
699 status = fasp_amg_setup_ua_bsr(mgl, amgparam); break;
700
701 }
702
703 if (status < 0) goto FINISHED;
704
705 precond_data_bsr precdata;
706 precdata.print_level = amgparam->print_level;
707 precdata.maxit = amgparam->maxit;
708 precdata.tol = amgparam->tol;
709 precdata.cycle_type = amgparam->cycle_type;
710 precdata.smoother = amgparam->smoother;
711 precdata.presmooth_iter = amgparam->presmooth_iter;
712 precdata.postsmooth_iter = amgparam->postsmooth_iter;
713 precdata.coarsening_type = amgparam->coarsening_type;
714 precdata.relaxation = amgparam->relaxation;
715 precdata.coarse_scaling = amgparam->coarse_scaling;
716 precdata.amli_degree = amgparam->amli_degree;
717 precdata.amli_coef = amgparam->amli_coef;
718 precdata.tentative_smooth = amgparam->tentative_smooth;
719 precdata.max_levels = mgl[0].num_levels;
720 precdata.mgl_data = mgl;
721 precdata.A = A;
722
723 if (status < 0) goto FINISHED;
724
725 precond prec;
726 prec.data = &precdata;
727 switch (amgparam->cycle_type) {
728 case NL_AMLI_CYCLE: // Nonlinear AMLI AMG
730 break;
731 default: // V,W-Cycle AMG
733 break;
734 }
735
736 fasp_gettime(&setup_end);
737
738 setup_time = setup_end - setup_start;
739
740 if ( prtlvl >= PRINT_MIN ) fasp_cputime("BSR AMG setup", setup_time);
741
742 //--------------------------------------------------------------
743 // Part 3: solver
744 //--------------------------------------------------------------
745 fasp_gettime(&solve_start);
746
747 status=fasp_solver_dbsr_itsolver(A,b,x,&prec,itparam);
748
749 fasp_gettime(&solve_end);
750
751 solve_time = solve_end - solve_start;
752
753 if ( prtlvl >= PRINT_MIN ) {
754 fasp_cputime("BSR Krylov method", setup_time+solve_time);
755 }
756
757FINISHED:
759
760#if DEBUG_MODE > 0
761 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
762#endif
763
764 if (status == ERROR_ALLOC_MEM) goto MEMORY_ERROR;
765 return status;
766
767MEMORY_ERROR:
768 printf("### ERROR: Cannot allocate memory! [%s]\n", __FUNCTION__);
769 exit(status);
770}
771
772/*---------------------------------*/
773/*-- End of File --*/
774/*---------------------------------*/
SHORT fasp_mem_iludata_check(const ILU_data *iludata)
Check wether a ILU_data has enough work space.
Definition: AuxMemory.c:205
void * fasp_mem_calloc(const unsigned int size, const unsigned int type)
Allocate, initiate, and check memory.
Definition: AuxMemory.c:65
void fasp_cputime(const char *message, const REAL cputime)
Print CPU walltime.
Definition: AuxMessage.c:179
void fasp_get_start_end(const INT procid, const INT nprocs, const INT n, INT *start, INT *end)
Assign Load to each thread.
Definition: AuxThreads.c:92
void fasp_gettime(REAL *time)
Get system time.
Definition: AuxTiming.c:36
void fasp_dvec_free(dvector *u)
Free vector data space of REAL type.
Definition: AuxVector.c:145
dvector fasp_dvec_create(const INT m)
Create dvector data space of REAL type.
Definition: AuxVector.c:62
void fasp_dvec_alloc(const INT m, dvector *u)
Create dvector data space of REAL type.
Definition: AuxVector.c:105
SHORT fasp_ilu_dbsr_setup(dBSRmat *A, ILU_data *iludata, ILU_param *iluparam)
Get ILU decoposition of a BSR matrix A.
SHORT fasp_smat_inv(REAL *a, const INT n)
Compute the inverse matrix of a small full matrix a.
dBSRmat fasp_dbsr_create(const INT ROW, const INT COL, const INT NNZ, const INT nb, const INT storage_manner)
Create BSR sparse matrix data memory space.
Definition: BlaSparseBSR.c:45
void fasp_dbsr_cp(const dBSRmat *A, dBSRmat *B)
copy a dCSRmat to a new one B=A
Definition: BlaSparseBSR.c:172
dCSRmat fasp_dcsr_create(const INT m, const INT n, const INT nnz)
Create CSR sparse matrix data memory space.
Definition: BlaSparseCSR.c:47
void fasp_dcsr_free(dCSRmat *A)
Free CSR sparse matrix data memory space.
Definition: BlaSparseCSR.c:184
void fasp_dcsr_transz(dCSRmat *A, INT *p, dCSRmat *AT)
Generalized transpose of A: (n x m) matrix given in dCSRmat format.
INT fasp_solver_dbsr_pbcgs(dBSRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned BiCGstab method for solving Au=b for BSR matrix.
Definition: KryPbcgs.c:387
INT fasp_solver_dbsr_pcg(dBSRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned conjugate gradient method for solving Au=b.
Definition: KryPcg.c:390
INT fasp_solver_dbsr_pgmres(dBSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Preconditioned GMRES method for solving Au=b.
Definition: KryPgmres.c:370
INT fasp_solver_dbsr_pvfgmres(dBSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Solve "Ax=b" using PFGMRES(right preconditioned) iterative method in which the restart parameter can ...
Definition: KryPvfgmres.c:389
INT fasp_solver_dbsr_pvgmres(dBSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Right preconditioned GMRES method in which the restart parameter can be adaptively modified during it...
Definition: KryPvgmres.c:413
SHORT fasp_amg_setup_sa_bsr(AMG_data_bsr *mgl, AMG_param *param)
Set up phase of smoothed aggregation AMG (BSR format)
SHORT fasp_amg_setup_ua_bsr(AMG_data_bsr *mgl, AMG_param *param)
Set up phase of unsmoothed aggregation AMG (BSR format)
void fasp_precond_dbsr_amg(REAL *r, REAL *z, void *data)
AMG preconditioner.
Definition: PreBSR.c:986
void fasp_precond_dbsr_amg_nk(REAL *r, REAL *z, void *data)
AMG with extra near kernel solve preconditioner.
Definition: PreBSR.c:1030
void fasp_precond_dbsr_diag(REAL *r, REAL *z, void *data)
Diagonal preconditioner z=inv(D)*r.
Definition: PreBSR.c:49
void fasp_precond_dbsr_ilu(REAL *r, REAL *z, void *data)
ILU preconditioner.
Definition: PreBSR.c:311
void fasp_precond_dbsr_namli(REAL *r, REAL *z, void *data)
Nonlinear AMLI-cycle AMG preconditioner.
Definition: PreBSR.c:1124
AMG_data_bsr * fasp_amg_data_bsr_create(SHORT max_levels)
Create and initialize AMG_data data sturcture for AMG/SAMG (BSR format)
Definition: PreDataInit.c:181
void fasp_ilu_data_free(ILU_data *iludata)
Create ILU_data sturcture.
Definition: PreDataInit.c:300
void fasp_amg_data_bsr_free(AMG_data_bsr *mgl)
Free AMG_data_bsr data memeory space.
Definition: PreDataInit.c:213
INT fasp_solver_dbsr_krylov_amg_nk(dBSRmat *A, dvector *b, dvector *x, ITS_param *itparam, AMG_param *amgparam, dCSRmat *A_nk, dCSRmat *P_nk, dCSRmat *R_nk)
Solve Ax=b by AMG with extra near kernel solve preconditioned Krylov methods.
Definition: SolBSR.c:483
INT fasp_solver_dbsr_krylov_ilu(dBSRmat *A, dvector *b, dvector *x, ITS_param *itparam, ILU_param *iluparam)
Solve Ax=b by ILUs preconditioned Krylov methods.
Definition: SolBSR.c:289
INT fasp_solver_dbsr_krylov_diag(dBSRmat *A, dvector *b, dvector *x, ITS_param *itparam)
Solve Ax=b by diagonal preconditioned Krylov methods.
Definition: SolBSR.c:187
INT fasp_solver_dbsr_krylov(dBSRmat *A, dvector *b, dvector *x, ITS_param *itparam)
Solve Ax=b by standard Krylov methods for BSR matrices.
Definition: SolBSR.c:139
INT fasp_solver_dbsr_itsolver(dBSRmat *A, dvector *b, dvector *x, precond *pc, ITS_param *itparam)
Solve Ax=b by preconditioned Krylov methods for BSR matrices.
Definition: SolBSR.c:55
INT fasp_solver_dbsr_krylov_nk_amg(dBSRmat *A, dvector *b, dvector *x, ITS_param *itparam, AMG_param *amgparam, const INT nk_dim, dvector *nk)
Solve Ax=b by AMG preconditioned Krylov methods with extra kernal space.
Definition: SolBSR.c:640
INT fasp_solver_dbsr_krylov_amg(dBSRmat *A, dvector *b, dvector *x, ITS_param *itparam, AMG_param *amgparam)
Solve Ax=b by AMG preconditioned Krylov methods.
Definition: SolBSR.c:354
Main header file for the FASP project.
#define REAL
Definition: fasp.h:67
#define SHORT
FASP integer and floating point numbers.
Definition: fasp.h:63
#define INT
Definition: fasp.h:64
#define NL_AMLI_CYCLE
Definition: fasp_const.h:180
#define SOLVER_GMRES
Definition: fasp_const.h:106
#define FASP_SUCCESS
Definition of return status and error messages.
Definition: fasp_const.h:19
#define ERROR_SOLVER_TYPE
Definition: fasp_const.h:41
#define SOLVER_VGMRES
Definition: fasp_const.h:107
#define SOLVER_BiCGstab
Definition: fasp_const.h:104
#define SA_AMG
Definition: fasp_const.h:163
#define OPENMP_HOLDS
Definition: fasp_const.h:260
#define ERROR_ALLOC_MEM
Definition: fasp_const.h:30
#define SOLVER_VFGMRES
Definition: fasp_const.h:108
#define SOLVER_CG
Definition: fasp_const.h:103
#define PRINT_NONE
Print level for all subroutines – not including DEBUG output.
Definition: fasp_const.h:73
#define PRINT_MIN
Definition: fasp_const.h:74
Data for multigrid levels in dBSRmat format.
Definition: fasp_block.h:146
INT near_kernel_dim
dimension of the near kernel for SAMG
Definition: fasp_block.h:209
dBSRmat A
pointer to the matrix at level level_num
Definition: fasp_block.h:155
dCSRmat * A_nk
Matrix data for near kernal.
Definition: fasp_block.h:218
dvector b
pointer to the right-hand side at level level_num
Definition: fasp_block.h:164
REAL ** near_kernel_basis
basis of near kernel space for SAMG
Definition: fasp_block.h:212
INT num_levels
number of levels in use <= max_levels
Definition: fasp_block.h:152
dCSRmat * R_nk
Resriction for near kernal.
Definition: fasp_block.h:224
dvector x
pointer to the iterative solution at level level_num
Definition: fasp_block.h:167
dCSRmat * P_nk
Prolongation for near kernal.
Definition: fasp_block.h:221
Parameters for AMG methods.
Definition: fasp.h:447
SHORT print_level
print level for AMG
Definition: fasp.h:453
SHORT coarsening_type
coarsening type
Definition: fasp.h:507
SHORT coarse_scaling
switch of scaling of the coarse grid correction
Definition: fasp.h:495
REAL * amli_coef
coefficients of the polynomial used by AMLI cycle
Definition: fasp.h:501
SHORT AMG_type
type of AMG method
Definition: fasp.h:450
REAL tol
stopping tolerance for AMG solver
Definition: fasp.h:459
REAL relaxation
relaxation parameter for Jacobi and SOR smoother
Definition: fasp.h:486
SHORT smoother
smoother type
Definition: fasp.h:474
SHORT cycle_type
type of AMG cycle
Definition: fasp.h:468
SHORT amli_degree
degree of the polynomial used by AMLI cycle
Definition: fasp.h:498
REAL tentative_smooth
relaxation parameter for smoothing the tentative prolongation
Definition: fasp.h:540
SHORT postsmooth_iter
number of postsmoothers
Definition: fasp.h:483
SHORT max_levels
max number of levels of AMG
Definition: fasp.h:462
SHORT presmooth_iter
number of presmoothers
Definition: fasp.h:480
INT maxit
max number of iterations of AMG
Definition: fasp.h:456
Data for ILU setup.
Definition: fasp.h:637
Parameters for ILU.
Definition: fasp.h:396
Parameters for iterative solvers.
Definition: fasp.h:379
SHORT itsolver_type
Definition: fasp.h:382
SHORT print_level
Definition: fasp.h:381
REAL tol
Definition: fasp.h:388
INT restart
Definition: fasp.h:386
SHORT stop_type
Definition: fasp.h:385
INT maxit
Definition: fasp.h:387
Block sparse row storage matrix of REAL type.
Definition: fasp_block.h:34
INT COL
number of cols of sub-blocks in matrix A, N
Definition: fasp_block.h:40
INT NNZ
number of nonzero sub-blocks in matrix A, NNZ
Definition: fasp_block.h:43
REAL * val
Definition: fasp_block.h:57
INT nb
dimension of each sub-block
Definition: fasp_block.h:46
INT * IA
integer array of row pointers, the size is ROW+1
Definition: fasp_block.h:60
INT ROW
number of rows of sub-blocks in matrix A, M
Definition: fasp_block.h:37
INT * JA
Definition: fasp_block.h:64
INT storage_manner
storage manner for each sub-block
Definition: fasp_block.h:49
Sparse matrix of REAL type in CSR format.
Definition: fasp.h:143
INT col
column of matrix A, n
Definition: fasp.h:149
INT row
row number of matrix A, m
Definition: fasp.h:146
INT nnz
number of nonzero entries
Definition: fasp.h:152
Vector with n entries of REAL type.
Definition: fasp.h:346
REAL * val
actual vector entries
Definition: fasp.h:352
INT row
number of rows
Definition: fasp.h:349
Data for preconditioners in dBSRmat format.
Definition: fasp_block.h:257
dBSRmat * A
Matrix data.
Definition: fasp_block.h:323
SHORT print_level
print level in AMG preconditioner
Definition: fasp_block.h:263
SHORT coarsening_type
coarsening type
Definition: fasp_block.h:290
SHORT coarse_scaling
switch of scaling of the coarse grid correction
Definition: fasp_block.h:299
dCSRmat * A_nk
Matrix data for near kernal.
Definition: fasp_block.h:328
REAL * amli_coef
coefficients of the polynomial used by AMLI cycle
Definition: fasp_block.h:305
REAL tol
tolerance for AMG preconditioner
Definition: fasp_block.h:272
REAL relaxation
relaxation parameter for SOR smoother
Definition: fasp_block.h:293
SHORT smoother
AMG smoother type.
Definition: fasp_block.h:278
SHORT cycle_type
AMG cycle type.
Definition: fasp_block.h:275
SHORT amli_degree
degree of the polynomial used by AMLI cycle
Definition: fasp_block.h:302
REAL tentative_smooth
smooth factor for smoothing the tentative prolongation
Definition: fasp_block.h:308
SHORT postsmooth_iter
number of postsmoothing
Definition: fasp_block.h:287
dCSRmat * R_nk
Resriction for near kernal.
Definition: fasp_block.h:334
AMG_data_bsr * mgl_data
AMG preconditioner data.
Definition: fasp_block.h:314
INT max_levels
max number of AMG levels
Definition: fasp_block.h:269
dCSRmat * P_nk
Prolongation for near kernal.
Definition: fasp_block.h:331
SHORT presmooth_iter
number of presmoothing
Definition: fasp_block.h:284
INT maxit
max number of iterations of AMG preconditioner
Definition: fasp_block.h:266
Data for diagnal preconditioners in dBSRmat format.
Definition: fasp_block.h:241
INT nb
dimension of each sub-block
Definition: fasp_block.h:244
dvector diag
diagnal elements
Definition: fasp_block.h:247
Preconditioner data and action.
Definition: fasp.h:1081
void * data
data for preconditioner, void pointer
Definition: fasp.h:1084
void(* fct)(REAL *, REAL *, void *)
action for preconditioner, void function pointer
Definition: fasp.h:1087