10 #if defined(HAVE_MUMPS)
12 #define USE_COMM_WORLD -987654
14 void mumpserror(
int id,
int subid)
17 Msg::Error(
"MUMPS INFO(1) = %d, INFO(2) = %d",
id, subid);
21 Msg::Error(
"Matrix is singular in structure, structural rank: %d", subid);
23 case -10:
Msg::Error(
"Matrix is numerically singular");
break;
24 case -13:
Msg::Error(
"Not enough memory");
break;
25 case -40:
Msg::Error(
"Matrix is not symmetric positive definite");
break;
26 default:
Msg::Error(
"Check MUMPS user's guide");
break;
31 linearSystemMUMPS<double>::linearSystemMUMPS()
37 bool linearSystemMUMPS<double>::isAllocated()
const
51 _irn.reserve(10 * _n);
52 _jcn.reserve(10 * _n);
56 void linearSystemMUMPS<double>::clear()
68 void linearSystemMUMPS<double>::zeroMatrix()
77 void linearSystemMUMPS<double>::zeroRightHandSide()
79 for(std::size_t i = 0; i < _b.size(); i++) _b[i] = 0.;
82 void linearSystemMUMPS<double>::zeroSolution()
84 for(std::size_t i = 0; i < _x.size(); i++) _x[i] = 0.;
87 int linearSystemMUMPS<double>::systemSolve()
90 std::vector<DMUMPS_REAL> b = _b;
95 const std::string sym = getParameter(
"symmetry");
98 else if(sym ==
"symmetric")
103 id.comm_fortran = USE_COMM_WORLD;
108 mumpserror(
id.info[0],
id.info[1]);
113 for(std::size_t i = 0; i < _irn.size(); i++) _irn[i]++;
114 for(std::size_t i = 0; i < _jcn.size(); i++) _jcn[i]++;
115 id.irn = &*_irn.begin();
116 id.jcn = &*_jcn.begin();
118 id.rhs = &*_b.begin();
121 id.icntl[1 - 1] = -1;
122 id.icntl[2 - 1] = -1;
123 id.icntl[3 - 1] = -1;
126 id.icntl[18 - 1] = 0;
128 Msg::Debug(
"MUMPS analysis, LU factorization, and back substitution");
131 mumpserror(
id.info[0],
id.info[1]);
137 mumpserror(
id.info[0],
id.info[1]);
142 for(std::size_t i = 0; i < _irn.size(); i++) _irn[i]--;
143 for(std::size_t i = 0; i < _jcn.size(); i++) _jcn[i]--;
148 void linearSystemMUMPS<double>::insertInSparsityPattern(
int row,
int col) {}
150 double linearSystemMUMPS<double>::normInfRightHandSide()
const
152 DMUMPS_REAL
norm = 0.;
153 for(std::size_t i = 0; i < _b.size(); i++) {
154 DMUMPS_REAL temp = fabs(_b[i]);
160 double linearSystemMUMPS<double>::normInfSolution()
const
162 DMUMPS_REAL
norm = 0.;
163 for(std::size_t i = 0; i < _x.size(); i++) {
164 DMUMPS_REAL temp = fabs(_x[i]);
170 void linearSystemMUMPS<double>::addToMatrix(
int row,
int col,
const double &val)
177 if((
int)_ij.size() <= row) {
182 _ij[row][col] = _a.size() - 1;
186 auto it = _ij[row].find(col);
187 if(it == _ij[row].end()) {
191 _ij[row][col] = _a.size() - 1;
195 _a[it->second] += val;
199 void linearSystemMUMPS<double>::getFromMatrix(
int row,
int col,
203 if((
int)_ij.size() <= row) {
207 auto it = _ij[row].find(col);
208 if(it == _ij[row].end())
211 val = _a[it->second];
214 void linearSystemMUMPS<double>::addToRightHandSide(
int row,
const double &val,
218 if((
int)_b.size() <= row) {
227 void linearSystemMUMPS<double>::getFromRightHandSide(
int row,
double &val)
const
229 if((
int)_b.size() <= row) val = 0.;
233 void linearSystemMUMPS<double>::getFromSolution(
int row,
double &val)
const
236 if((
int)_x.size() <= row)
242 void linearSystemMUMPS<double>::addToSolution(
int row,
const double &val)
244 if((
int)_x.size() <= row) {