Fast Auxiliary Space Preconditioning 2.7.7 Aug/28/2022
Loading...
Searching...
No Matches
XtrStrumpack.c
Go to the documentation of this file.
1
14#include <time.h>
15
16#include "fasp.h"
17#include "fasp_functs.h"
18
19#if WITH_STRUMPACK
20#include "StrumpackSparseSolver.h"
21#endif
22
23/*---------------------------------*/
24/*-- Public Functions --*/
25/*---------------------------------*/
26
42{
43
44#if WITH_STRUMPACK
45
46 const INT n = ptrA->col;
47 INT* row_ptr = ptrA->IA;
48 INT* col_ind = ptrA->JA;
49 double* val = ptrA->val;
50 INT status = FASP_SUCCESS;
51
52 int verbose = 0;
53 if (prtlvl > PRINT_MORE) verbose = 1;
54
55#if DEBUG_MODE
56 const INT m = ptrA->row;
57 const INT nnz = ptrA->nnz;
58 printf("### DEBUG: %s ...... [Start]\n", __FUNCTION__);
59 printf("### DEBUG: nr=%d, nc=%d, nnz=%d\n", m, n, nnz);
60#endif
61
62 REAL start_time, end_time;
63 fasp_gettime(&start_time);
64
65 /* Set Strumpack */
66 STRUMPACK_SparseSolver S;
67 STRUMPACK_init_mt(&S, STRUMPACK_DOUBLE, STRUMPACK_MT, 0, NULL, verbose);
68 STRUMPACK_set_Krylov_solver(S, STRUMPACK_DIRECT);
69 STRUMPACK_set_matching(S, STRUMPACK_MATCHING_NONE);
70 STRUMPACK_set_reordering_method(S, STRUMPACK_METIS);
71 STRUMPACK_set_compression(S, STRUMPACK_NONE);
72 STRUMPACK_set_csr_matrix(S, &n, row_ptr, col_ind, val, 0);
73
74 /* Call STRUMPACK as a solver */
75 status = STRUMPACK_reorder(S);
76 // status = STRUMPACK_factor(S);
77 status = STRUMPACK_solve(S, b->val, u->val, 0);
78
79 if (prtlvl > PRINT_MIN) {
80 fasp_gettime(&end_time);
81 fasp_cputime("STRUMPACK costs", end_time - start_time);
82 }
83
84 /* Clean up factorization */
85 STRUMPACK_destroy(&S);
86
87#if DEBUG_MODE
88 printf("### DEBUG: %s ...... [Finish]\n", __FUNCTION__);
89#endif
90
91 return status;
92
93#else
94
95 printf("### ERROR: STRUMPACK is not available!\n");
96 return ERROR_SOLVER_EXIT;
97
98#endif
99}
100
101/*---------------------------------*/
102/*-- End of File --*/
103/*---------------------------------*/
void fasp_cputime(const char *message, const REAL cputime)
Print CPU walltime.
Definition: AuxMessage.c:179
void fasp_gettime(REAL *time)
Get system time.
Definition: AuxTiming.c:37
INT fasp_solver_strumpack(dCSRmat *ptrA, dvector *b, dvector *u, const SHORT prtlvl)
Solve Au=b by UMFpack.
Definition: XtrStrumpack.c:41
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 FASP_SUCCESS
Definition of return status and error messages.
Definition: fasp_const.h:19
#define PRINT_MORE
Definition: fasp_const.h:76
#define ERROR_SOLVER_EXIT
Definition: fasp_const.h:49
#define PRINT_MIN
Definition: fasp_const.h:74
Sparse matrix of REAL type in CSR format.
Definition: fasp.h:151
INT col
column of matrix A, n
Definition: fasp.h:157
REAL * val
nonzero entries of A
Definition: fasp.h:169
INT row
row number of matrix A, m
Definition: fasp.h:154
INT * IA
integer array of row pointers, the size is m+1
Definition: fasp.h:163
INT nnz
number of nonzero entries
Definition: fasp.h:160
INT * JA
integer array of column indexes, the size is nnz
Definition: fasp.h:166
Vector with n entries of REAL type.
Definition: fasp.h:354
REAL * val
actual vector entries
Definition: fasp.h:360