Fast Auxiliary Space Preconditioning 2.7.7 Aug/28/2022
Loading...
Searching...
No Matches
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 dBSRmat* A, dvector* b, dvector* x, precond* pc, ITS_param* itparam)
57{
58 const SHORT prtlvl = itparam->print_level;
59 const SHORT itsolver_type = itparam->itsolver_type;
60 const SHORT stop_type = itparam->stop_type;
61 const SHORT restart = itparam->restart;
62 const INT MaxIt = itparam->maxit;
63 const REAL tol = itparam->tol;
64 const REAL abstol = itparam->abstol;
65
66 // Local variables
68 REAL solve_start, solve_end;
69
70#if DEBUG_MODE > 0
71 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
72 printf("### DEBUG: rhs/sol size: %d %d\n", b->row, x->row);
73#endif
74
75 fasp_gettime(&solve_start);
76
77 /* Safe-guard checks on parameters */
78 ITS_CHECK(MaxIt, tol);
79
80 switch (itsolver_type) {
81
82 case SOLVER_CG:
83 iter = fasp_solver_dbsr_pcg(A, b, x, pc, tol, abstol, MaxIt, stop_type,
84 prtlvl);
85 break;
86
87 case SOLVER_BiCGstab:
88 iter = fasp_solver_dbsr_pbcgs(A, b, x, pc, tol, abstol, MaxIt, stop_type,
89 prtlvl);
90 break;
91
92 case SOLVER_GMRES:
93 iter = fasp_solver_dbsr_pgmres(A, b, x, pc, tol, abstol, MaxIt, restart,
94 stop_type, prtlvl);
95 break;
96
97 case SOLVER_VGMRES:
98 iter = fasp_solver_dbsr_pvgmres(A, b, x, pc, tol, abstol, MaxIt, restart,
99 stop_type, prtlvl);
100 break;
101
102 case SOLVER_VFGMRES:
103 iter = fasp_solver_dbsr_pvfgmres(A, b, x, pc, tol, abstol, MaxIt, restart,
104 stop_type, prtlvl);
105 break;
106
107 default:
108 printf("### ERROR: Unknown iterative solver type %d! [%s]\n", itsolver_type,
109 __FUNCTION__);
110 return ERROR_SOLVER_TYPE;
111 }
112
113 if ((prtlvl > PRINT_MIN) && (iter >= 0)) {
114 fasp_gettime(&solve_end);
115 fasp_cputime("Iterative method", solve_end - solve_start);
116 }
117
118#if DEBUG_MODE > 0
119 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
120#endif
121
122 return iter;
123}
124
142{
143 const SHORT prtlvl = itparam->print_level;
144 INT status = FASP_SUCCESS;
145 REAL solve_start, solve_end;
146
147#if DEBUG_MODE > 0
148 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
149#endif
150
151 // solver part
152 fasp_gettime(&solve_start);
153
154 status = fasp_solver_dbsr_itsolver(A, b, x, NULL, itparam);
155
156 fasp_gettime(&solve_end);
157
158 if (prtlvl > PRINT_NONE)
159 fasp_cputime("Krylov method totally", solve_end - solve_start);
160
161#if DEBUG_MODE > 0
162 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
163#endif
164
165 return status;
166}
167
187{
188 const SHORT prtlvl = itparam->print_level;
189 INT status = FASP_SUCCESS;
190 REAL solve_start, solve_end;
191
192 INT nb = A->nb, i, k;
193 INT nb2 = nb * nb;
194 INT ROW = A->ROW;
195
196#ifdef _OPENMP
197 // variables for OpenMP
198 INT myid, mybegin, myend;
199 INT nthreads = fasp_get_num_threads();
200#endif
201 // setup preconditioner
202 precond_diag_bsr diag;
203 fasp_dvec_alloc(ROW * nb2, &(diag.diag));
204
205#if DEBUG_MODE > 0
206 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
207#endif
208
209 // get all the diagonal sub-blocks
210#ifdef _OPENMP
211 if (ROW > OPENMP_HOLDS) {
212#pragma omp parallel for private(myid, mybegin, myend, i, k)
213 for (myid = 0; myid < nthreads; ++myid) {
214 fasp_get_start_end(myid, nthreads, ROW, &mybegin, &myend);
215 for (i = mybegin; i < myend; ++i) {
216 for (k = A->IA[i]; k < A->IA[i + 1]; ++k) {
217 if (A->JA[k] == i)
218 memcpy(diag.diag.val + i * nb2, A->val + k * nb2,
219 nb2 * sizeof(REAL));
220 }
221 }
222 }
223 } else {
224#endif
225 for (i = 0; i < ROW; ++i) {
226 for (k = A->IA[i]; k < A->IA[i + 1]; ++k) {
227 if (A->JA[k] == i)
228 memcpy(diag.diag.val + i * nb2, A->val + k * nb2,
229 nb2 * sizeof(REAL));
230 }
231 }
232#ifdef _OPENMP
233 }
234#endif
235
236 diag.nb = nb;
237
238#ifdef _OPENMP
239#pragma omp parallel for if (ROW > OPENMP_HOLDS)
240#endif
241 for (i = 0; i < ROW; ++i) {
242 fasp_smat_inv(&(diag.diag.val[i * nb2]), nb);
243 }
244
245 precond* pc = (precond*)fasp_mem_calloc(1, sizeof(precond));
246 pc->data = &diag;
248
249 // solver part
250 fasp_gettime(&solve_start);
251
252 status = fasp_solver_dbsr_itsolver(A, b, x, pc, itparam);
253
254 fasp_gettime(&solve_end);
255
256 if (prtlvl > PRINT_NONE)
257 fasp_cputime("Diag_Krylov method totally", solve_end - solve_start);
258
259 // clean up
260 fasp_dvec_free(&(diag.diag));
261
262#if DEBUG_MODE > 0
263 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
264#endif
265
266 return status;
267}
268
287 dBSRmat* A, dvector* b, dvector* x, ITS_param* itparam, ILU_param* iluparam)
288{
289 const SHORT prtlvl = itparam->print_level;
290 REAL solve_start, solve_end;
291 INT status = FASP_SUCCESS;
292
293 ILU_data LU;
294 precond pc;
295
296#if DEBUG_MODE > 0
297 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
298 printf("### DEBUG: matrix size: %d %d %d\n", A->ROW, A->COL, A->NNZ);
299 printf("### DEBUG: rhs/sol size: %d %d\n", b->row, x->row);
300#endif
301
302 fasp_gettime(&solve_start);
303
304 // ILU setup for whole matrix
305 if ((status = fasp_ilu_dbsr_setup(A, &LU, iluparam)) < 0) goto FINISHED;
306
307 // check iludata
308 if ((status = fasp_mem_iludata_check(&LU)) < 0) goto FINISHED;
309
310 // set preconditioner
311 pc.data = &LU;
313
314 // solve
315 status = fasp_solver_dbsr_itsolver(A, b, x, &pc, itparam);
316
317 fasp_gettime(&solve_end);
318
319 if (prtlvl > PRINT_NONE)
320 fasp_cputime("ILUk_Krylov method totally", solve_end - solve_start);
321
322FINISHED:
324
325#if DEBUG_MODE > 0
326 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
327#endif
328
329 return status;
330}
331
350 dBSRmat* A, dvector* b, dvector* x, ITS_param* itparam, AMG_param* amgparam)
351{
352 //--------------------------------------------------------------
353 // Part 1: prepare
354 // --------------------------------------------------------------
355
357 const SHORT prtlvl = itparam->print_level;
358 const SHORT max_levels = amgparam->max_levels;
359
360 // return variable
361 INT status = FASP_SUCCESS;
362
363 // data of AMG
364 AMG_data_bsr* mgl = fasp_amg_data_bsr_create(max_levels);
365
366 // timing
367 REAL setup_start, setup_end, solve_end;
368
369#if DEBUG_MODE > 0
370 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
371#endif
372
373 //--------------------------------------------------------------
374 // Part 2: set up the preconditioner
375 //--------------------------------------------------------------
376 fasp_gettime(&setup_start);
377
378 // initialize A, b, x for mgl[0]
379 mgl[0].A = fasp_dbsr_create(A->ROW, A->COL, A->NNZ, A->nb, A->storage_manner);
380 mgl[0].b = fasp_dvec_create(mgl[0].A.ROW * mgl[0].A.nb);
381 mgl[0].x = fasp_dvec_create(mgl[0].A.COL * mgl[0].A.nb);
382
383 fasp_dbsr_cp(A, &(mgl[0].A));
384
385 switch (amgparam->AMG_type) {
386
387 case SA_AMG: // Smoothed Aggregation AMG
388 status = fasp_amg_setup_sa_bsr(mgl, amgparam);
389 break;
390
391 default:
392 status = fasp_amg_setup_ua_bsr(mgl, amgparam);
393 break;
394 }
395
396 if (status < 0) goto FINISHED;
397
398 precond_data_bsr precdata;
399 precdata.print_level = amgparam->print_level;
400 precdata.maxit = amgparam->maxit;
401 precdata.tol = amgparam->tol;
402 precdata.cycle_type = amgparam->cycle_type;
403 precdata.smoother = amgparam->smoother;
404 precdata.presmooth_iter = amgparam->presmooth_iter;
405 precdata.postsmooth_iter = amgparam->postsmooth_iter;
406 precdata.coarsening_type = amgparam->coarsening_type;
407 precdata.relaxation = amgparam->relaxation;
408 precdata.coarse_scaling = amgparam->coarse_scaling;
409 precdata.amli_degree = amgparam->amli_degree;
410 precdata.amli_coef = amgparam->amli_coef;
411 precdata.tentative_smooth = amgparam->tentative_smooth;
412 precdata.max_levels = mgl[0].num_levels;
413 precdata.mgl_data = mgl;
414 precdata.A = A;
415
416 precond prec;
417 prec.data = &precdata;
418 switch (amgparam->cycle_type) {
419 case NL_AMLI_CYCLE: // Nonlinear AMLI AMG
421 break;
422 default: // V,W-Cycle AMG
424 break;
425 }
426
427 fasp_gettime(&setup_end);
428
429 if (prtlvl >= PRINT_MIN) fasp_cputime("BSR AMG setup", setup_end - setup_start);
430
431 //--------------------------------------------------------------
432 // Part 3: solver
433 //--------------------------------------------------------------
434 status = fasp_solver_dbsr_itsolver(A, b, x, &prec, itparam);
435
436 fasp_gettime(&solve_end);
437
438 if (prtlvl >= PRINT_MIN) fasp_cputime("BSR Krylov method", solve_end - setup_start);
439
440FINISHED:
441 fasp_amg_data_bsr_free(mgl, amgparam);
442
443#if DEBUG_MODE > 0
444 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
445#endif
446
447 if (status == ERROR_ALLOC_MEM) goto MEMORY_ERROR;
448 return status;
449
450MEMORY_ERROR:
451 printf("### ERROR: Cannot allocate memory! [%s]\n", __FUNCTION__);
452 exit(status);
453}
454
477 dvector* b,
478 dvector* x,
479 ITS_param* itparam,
480 AMG_param* amgparam,
481 dCSRmat* A_nk,
482 dCSRmat* P_nk,
483 dCSRmat* R_nk)
484{
485 //--------------------------------------------------------------
486 // Part 1: prepare
487 // --------------------------------------------------------------
488 // parameters of iterative method
489 const SHORT prtlvl = itparam->print_level;
490 const SHORT max_levels = amgparam->max_levels;
491
492 // return variable
493 INT status = FASP_SUCCESS;
494
495 // data of AMG
496 AMG_data_bsr* mgl = fasp_amg_data_bsr_create(max_levels);
497
498 // timing
499 REAL setup_start, setup_end, setup_time;
500 REAL solve_start, solve_end, solve_time;
501
502#if DEBUG_MODE > 0
503 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
504#endif
505
506 //--------------------------------------------------------------
507 // Part 2: set up the preconditioner
508 //--------------------------------------------------------------
509 fasp_gettime(&setup_start);
510
511 // initialize A, b, x for mgl[0]
512 mgl[0].A = fasp_dbsr_create(A->ROW, A->COL, A->NNZ, A->nb, A->storage_manner);
513 fasp_dbsr_cp(A, &(mgl[0].A));
514 mgl[0].b = fasp_dvec_create(mgl[0].A.ROW * mgl[0].A.nb);
515 mgl[0].x = fasp_dvec_create(mgl[0].A.COL * mgl[0].A.nb);
516
517 // near kernel space
518 mgl[0].A_nk = NULL;
519 mgl[0].P_nk = P_nk;
520 mgl[0].R_nk = R_nk;
521
522 switch (amgparam->AMG_type) {
523
524 case SA_AMG: // Smoothed Aggregation AMG
525 status = fasp_amg_setup_sa_bsr(mgl, amgparam);
526 break;
527
528 default:
529 status = fasp_amg_setup_ua_bsr(mgl, amgparam);
530 break;
531 }
532
533 if (status < 0) goto FINISHED;
534
535 precond_data_bsr precdata;
536 precdata.print_level = amgparam->print_level;
537 precdata.maxit = amgparam->maxit;
538 precdata.tol = amgparam->tol;
539 precdata.cycle_type = amgparam->cycle_type;
540 precdata.smoother = amgparam->smoother;
541 precdata.presmooth_iter = amgparam->presmooth_iter;
542 precdata.postsmooth_iter = amgparam->postsmooth_iter;
543 precdata.coarsening_type = amgparam->coarsening_type;
544 precdata.relaxation = amgparam->relaxation;
545 precdata.coarse_scaling = amgparam->coarse_scaling;
546 precdata.amli_degree = amgparam->amli_degree;
547 precdata.amli_coef = amgparam->amli_coef;
548 precdata.tentative_smooth = amgparam->tentative_smooth;
549 precdata.max_levels = mgl[0].num_levels;
550 precdata.mgl_data = mgl;
551 precdata.A = A;
552
553#if WITH_UMFPACK // use UMFPACK directly
554 dCSRmat A_tran;
555 A_tran = fasp_dcsr_create(A_nk->row, A_nk->col, A_nk->nnz);
556 fasp_dcsr_transz(A_nk, NULL, &A_tran);
557 // It is equivalent to do transpose and then sort
558 // fasp_dcsr_trans(A_nk, &A_tran);
559 // fasp_dcsr_sort(&A_tran);
560 precdata.A_nk = &A_tran;
561#else
562 precdata.A_nk = A_nk;
563#endif
564
565 precdata.P_nk = P_nk;
566 precdata.R_nk = R_nk;
567
568 if (status < 0) goto FINISHED;
569
570 precond prec;
571 prec.data = &precdata;
572
574
575 fasp_gettime(&setup_end);
576
577 setup_time = setup_end - setup_start;
578
579 if (prtlvl >= PRINT_MIN) fasp_cputime("BSR AMG setup", setup_time);
580
581 //--------------------------------------------------------------
582 // Part 3: solver
583 //--------------------------------------------------------------
584 fasp_gettime(&solve_start);
585
586 status = fasp_solver_dbsr_itsolver(A, b, x, &prec, itparam);
587
588 fasp_gettime(&solve_end);
589
590 solve_time = solve_end - solve_start;
591
592 if (prtlvl >= PRINT_MIN) {
593 fasp_cputime("BSR Krylov method", setup_time + solve_time);
594 }
595
596FINISHED:
597 fasp_amg_data_bsr_free(mgl, amgparam);
598
599#if DEBUG_MODE > 0
600 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
601#endif
602
603#if WITH_UMFPACK // use UMFPACK directly
604 fasp_dcsr_free(&A_tran);
605#endif
606 if (status == ERROR_ALLOC_MEM) goto MEMORY_ERROR;
607 return status;
608
609MEMORY_ERROR:
610 printf("### ERROR: Cannot allocate memory! [%s]\n", __FUNCTION__);
611 exit(status);
612}
613
635 dvector* b,
636 dvector* x,
637 ITS_param* itparam,
638 AMG_param* amgparam,
639 const INT nk_dim,
640 dvector* nk)
641{
642 //--------------------------------------------------------------
643 // Part 1: prepare
644 // --------------------------------------------------------------
646 const SHORT prtlvl = itparam->print_level;
647 const SHORT max_levels = amgparam->max_levels;
648
649 // local variable
650 INT i;
651
652 // return variable
653 INT status = FASP_SUCCESS;
654
655 // data of AMG
656 AMG_data_bsr* mgl = fasp_amg_data_bsr_create(max_levels);
657
658 // timing
659 REAL setup_start, setup_end, setup_time;
660 REAL solve_start, solve_end, solve_time;
661
662#if DEBUG_MODE > 0
663 printf("### DEBUG: [-Begin-] %s ...\n", __FUNCTION__);
664#endif
665
666 //--------------------------------------------------------------
667 // Part 2: set up the preconditioner
668 //--------------------------------------------------------------
669 fasp_gettime(&setup_start);
670
671 // initialize A, b, x for mgl[0]
672 mgl[0].A = fasp_dbsr_create(A->ROW, A->COL, A->NNZ, A->nb, A->storage_manner);
673 fasp_dbsr_cp(A, &(mgl[0].A));
674 mgl[0].b = fasp_dvec_create(mgl[0].A.ROW * mgl[0].A.nb);
675 mgl[0].x = fasp_dvec_create(mgl[0].A.COL * mgl[0].A.nb);
676
677 /*-----------------------*/
678 /*-- setup null spaces --*/
679 /*-----------------------*/
680
681 // null space for whole Jacobian
682 mgl[0].near_kernel_dim = nk_dim;
683 mgl[0].near_kernel_basis =
684 (REAL**)fasp_mem_calloc(mgl->near_kernel_dim, sizeof(REAL*));
685
686 for (i = 0; i < mgl->near_kernel_dim; ++i) mgl[0].near_kernel_basis[i] = nk[i].val;
687
688 switch (amgparam->AMG_type) {
689
690 case SA_AMG: // Smoothed Aggregation AMG
691 status = fasp_amg_setup_sa_bsr(mgl, amgparam);
692 break;
693
694 default:
695 status = fasp_amg_setup_ua_bsr(mgl, amgparam);
696 break;
697 }
698
699 if (status < 0) goto FINISHED;
700
701 precond_data_bsr precdata;
702 precdata.print_level = amgparam->print_level;
703 precdata.maxit = amgparam->maxit;
704 precdata.tol = amgparam->tol;
705 precdata.cycle_type = amgparam->cycle_type;
706 precdata.smoother = amgparam->smoother;
707 precdata.presmooth_iter = amgparam->presmooth_iter;
708 precdata.postsmooth_iter = amgparam->postsmooth_iter;
709 precdata.coarsening_type = amgparam->coarsening_type;
710 precdata.relaxation = amgparam->relaxation;
711 precdata.coarse_scaling = amgparam->coarse_scaling;
712 precdata.amli_degree = amgparam->amli_degree;
713 precdata.amli_coef = amgparam->amli_coef;
714 precdata.tentative_smooth = amgparam->tentative_smooth;
715 precdata.max_levels = mgl[0].num_levels;
716 precdata.mgl_data = mgl;
717 precdata.A = A;
718
719 if (status < 0) goto FINISHED;
720
721 precond prec;
722 prec.data = &precdata;
723 switch (amgparam->cycle_type) {
724 case NL_AMLI_CYCLE: // Nonlinear AMLI AMG
726 break;
727 default: // V,W-Cycle AMG
729 break;
730 }
731
732 fasp_gettime(&setup_end);
733
734 setup_time = setup_end - setup_start;
735
736 if (prtlvl >= PRINT_MIN) fasp_cputime("BSR AMG setup", setup_time);
737
738 //--------------------------------------------------------------
739 // Part 3: solver
740 //--------------------------------------------------------------
741 fasp_gettime(&solve_start);
742
743 status = fasp_solver_dbsr_itsolver(A, b, x, &prec, itparam);
744
745 fasp_gettime(&solve_end);
746
747 solve_time = solve_end - solve_start;
748
749 if (prtlvl >= PRINT_MIN) {
750 fasp_cputime("BSR Krylov method", setup_time + solve_time);
751 }
752
753FINISHED:
754 fasp_amg_data_bsr_free(mgl, amgparam);
755
756#if DEBUG_MODE > 0
757 printf("### DEBUG: [--End--] %s ...\n", __FUNCTION__);
758#endif
759
760 if (status == ERROR_ALLOC_MEM) goto MEMORY_ERROR;
761 return status;
762
763MEMORY_ERROR:
764 printf("### ERROR: Cannot allocate memory! [%s]\n", __FUNCTION__);
765 exit(status);
766}
767
768/*---------------------------------*/
769/*-- End of File --*/
770/*---------------------------------*/
SHORT fasp_mem_iludata_check(const ILU_data *iludata)
Check wether a ILU_data has enough work space.
Definition: AuxMemory.c:203
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:93
void fasp_gettime(REAL *time)
Get system time.
Definition: AuxTiming.c:37
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:48
void fasp_dbsr_cp(const dBSRmat *A, dBSRmat *B)
copy a dCSRmat to a new one B=A
Definition: BlaSparseBSR.c:169
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 REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned BiCGstab method for solving Au=b for BSR matrix.
Definition: KryPbcgs.c:383
INT fasp_solver_dbsr_pcg(dBSRmat *A, dvector *b, dvector *u, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT StopType, const SHORT PrtLvl)
Preconditioned conjugate gradient method for solving Au=b.
Definition: KryPcg.c:386
INT fasp_solver_dbsr_pgmres(dBSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, const INT MaxIt, const SHORT restart, const SHORT StopType, const SHORT PrtLvl)
Preconditioned GMRES method for solving Au=b.
Definition: KryPgmres.c:376
INT fasp_solver_dbsr_pvfgmres(dBSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, 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:386
INT fasp_solver_dbsr_pvgmres(dBSRmat *A, dvector *b, dvector *x, precond *pc, const REAL tol, const REAL abstol, 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:416
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:1149
void fasp_precond_dbsr_amg_nk(REAL *r, REAL *z, void *data)
AMG with extra near kernel solve preconditioner.
Definition: PreBSR.c:1194
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:347
void fasp_precond_dbsr_namli(REAL *r, REAL *z, void *data)
Nonlinear AMLI-cycle AMG preconditioner.
Definition: PreBSR.c:1294
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:283
void fasp_ilu_data_free(ILU_data *iludata)
Create ILU_data sturcture.
Definition: PreDataInit.c:445
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:476
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:286
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:186
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:141
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:634
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:349
Main header file for the FASP project.
#define REAL
Definition: fasp.h:75
#define SHORT
FASP integer and floating point numbers.
Definition: fasp.h:71
#define INT
Definition: fasp.h:72
#define NL_AMLI_CYCLE
Definition: fasp_const.h:182
#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:164
#define OPENMP_HOLDS
Definition: fasp_const.h:269
#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:223
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:232
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:226
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:238
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:235
Parameters for AMG methods.
Definition: fasp.h:455
SHORT print_level
print level for AMG
Definition: fasp.h:461
SHORT coarsening_type
coarsening type
Definition: fasp.h:515
SHORT coarse_scaling
switch of scaling of the coarse grid correction
Definition: fasp.h:503
REAL * amli_coef
coefficients of the polynomial used by AMLI cycle
Definition: fasp.h:509
SHORT AMG_type
type of AMG method
Definition: fasp.h:458
REAL tol
stopping tolerance for AMG solver
Definition: fasp.h:467
REAL relaxation
relaxation parameter for Jacobi and SOR smoother
Definition: fasp.h:494
SHORT smoother
smoother type
Definition: fasp.h:482
SHORT cycle_type
type of AMG cycle
Definition: fasp.h:476
SHORT amli_degree
degree of the polynomial used by AMLI cycle
Definition: fasp.h:506
REAL tentative_smooth
relaxation parameter for smoothing the tentative prolongation
Definition: fasp.h:551
SHORT postsmooth_iter
number of postsmoothers
Definition: fasp.h:491
SHORT max_levels
max number of levels of AMG
Definition: fasp.h:470
SHORT presmooth_iter
number of presmoothers
Definition: fasp.h:488
INT maxit
max number of iterations of AMG
Definition: fasp.h:464
Data for ILU setup.
Definition: fasp.h:651
Parameters for ILU.
Definition: fasp.h:404
Parameters for iterative solvers.
Definition: fasp.h:386
SHORT itsolver_type
Definition: fasp.h:389
SHORT print_level
Definition: fasp.h:388
REAL tol
Definition: fasp.h:395
INT restart
Definition: fasp.h:393
SHORT stop_type
Definition: fasp.h:392
REAL abstol
Definition: fasp.h:396
INT maxit
Definition: fasp.h:394
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:151
INT col
column of matrix A, n
Definition: fasp.h:157
INT row
row number of matrix A, m
Definition: fasp.h:154
INT nnz
number of nonzero entries
Definition: fasp.h:160
Vector with n entries of REAL type.
Definition: fasp.h:354
REAL * val
actual vector entries
Definition: fasp.h:360
INT row
number of rows
Definition: fasp.h:357
Data for preconditioners in dBSRmat format.
Definition: fasp_block.h:271
dBSRmat * A
Matrix data.
Definition: fasp_block.h:337
SHORT print_level
print level in AMG preconditioner
Definition: fasp_block.h:277
SHORT coarsening_type
coarsening type
Definition: fasp_block.h:304
SHORT coarse_scaling
switch of scaling of the coarse grid correction
Definition: fasp_block.h:313
dCSRmat * A_nk
Matrix data for near kernal.
Definition: fasp_block.h:342
REAL * amli_coef
coefficients of the polynomial used by AMLI cycle
Definition: fasp_block.h:319
REAL tol
tolerance for AMG preconditioner
Definition: fasp_block.h:286
REAL relaxation
relaxation parameter for SOR smoother
Definition: fasp_block.h:307
SHORT smoother
AMG smoother type.
Definition: fasp_block.h:292
SHORT cycle_type
AMG cycle type.
Definition: fasp_block.h:289
SHORT amli_degree
degree of the polynomial used by AMLI cycle
Definition: fasp_block.h:316
REAL tentative_smooth
smooth factor for smoothing the tentative prolongation
Definition: fasp_block.h:322
SHORT postsmooth_iter
number of postsmoothing
Definition: fasp_block.h:301
dCSRmat * R_nk
Resriction for near kernal.
Definition: fasp_block.h:348
AMG_data_bsr * mgl_data
AMG preconditioner data.
Definition: fasp_block.h:328
INT max_levels
max number of AMG levels
Definition: fasp_block.h:283
dCSRmat * P_nk
Prolongation for near kernal.
Definition: fasp_block.h:345
SHORT presmooth_iter
number of presmoothing
Definition: fasp_block.h:298
INT maxit
max number of iterations of AMG preconditioner
Definition: fasp_block.h:280
Data for diagnal preconditioners in dBSRmat format.
Definition: fasp_block.h:255
INT nb
dimension of each sub-block
Definition: fasp_block.h:258
dvector diag
diagnal elements
Definition: fasp_block.h:261
Preconditioner data and action.
Definition: fasp.h:1095
void * data
data for preconditioner, void pointer
Definition: fasp.h:1098
void(* fct)(REAL *, REAL *, void *)
action for preconditioner, void function pointer
Definition: fasp.h:1101