-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcoo_mumps_solver.h
More file actions
78 lines (66 loc) · 2.64 KB
/
coo_mumps_solver.h
File metadata and controls
78 lines (66 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#ifdef GMGPOLAR_USE_MUMPS
#include "dmumps_c.h"
#include "../../LinearAlgebra/Matrix/coo_matrix.h"
#include "../../LinearAlgebra/Vector/vector.h"
/*
* Wraps MUMPS for solving sparse linear systems given in COO format.
* For general matrices, all non-zero entries must be provided.
* For symmetric matrices (is_symmetric = true), only the upper or lower
* triangular entries should be provided, and the matrix is assumed to be
* positive definite. In GMGPolar this holds true since the domain mapping is invertible.
*/
class CooMumpsSolver
{
public:
explicit CooMumpsSolver(SparseMatrixCOO<double> matrix);
~CooMumpsSolver();
// rhs is overwritten in-place with the solution on return.
void solve(Vector<double>& rhs);
private:
void initialize();
void finalize();
void configureICNTL();
void configureCNTL();
/* ------------------------------------------------ */
/* MUMPS uses 1-based indexing in the documentation */
/* ------------------------------------------------ */
int& ICNTL(int i)
{
return mumps_solver_.icntl[i - 1];
}
double& CNTL(int i)
{
return mumps_solver_.cntl[i - 1];
}
int& INFOG(int i)
{
return mumps_solver_.infog[i - 1];
}
/* ----------------------------------- */
/* MUMPS jobs and constant definitions */
/* ----------------------------------- */
static constexpr int USE_COMM_WORLD = -987654;
static constexpr int PAR_NOT_PARALLEL = 0;
static constexpr int PAR_PARALLEL = 1;
static constexpr int JOB_INIT = -1;
static constexpr int JOB_END = -2;
static constexpr int JOB_REMOVE_SAVED_DATA = -3;
static constexpr int JOB_FREE_INTERNAL_DATA = -4;
static constexpr int JOB_SUPPRESS_OOC_FILES = -200;
static constexpr int JOB_ANALYSIS_PHASE = 1;
static constexpr int JOB_FACTORIZATION_PHASE = 2;
static constexpr int JOB_COMPUTE_SOLUTION = 3;
static constexpr int JOB_ANALYSIS_AND_FACTORIZATION = 4;
static constexpr int JOB_FACTORIZATION_AND_SOLUTION = 5;
static constexpr int JOB_ANALYSIS_FACTORIZATION_SOLUTION = 6;
static constexpr int JOB_SAVE_INTERNAL_DATA = 7;
static constexpr int JOB_RESTORE_INTERNAL_DATA = 8;
static constexpr int JOB_DISTRIBUTE_RHS = 9;
static constexpr int SYM_UNSYMMETRIC = 0;
static constexpr int SYM_POSITIVE_DEFINITE = 1;
static constexpr int SYM_GENERAL_SYMMETRIC = 2;
SparseMatrixCOO<double> matrix_;
DMUMPS_STRUC_C mumps_solver_ = {};
};
#endif // GMGPOLAR_USE_MUMPS