BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_SolverMUMPS.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_CL_SOLVERMUMPS_HPP
13#define BELFEM_CL_SOLVERMUMPS_HPP
14
15#include "cl_Cell.hpp"
16#include "cl_SolverWrapper.hpp"
18
19namespace belfem
20{
21 namespace solver
22 {
23
24 class MUMPS : public Wrapper
25 {
26 // parameter object
27 const SolverParameters * mParams ;
28
29 // Rank of HOST
30 const proc_t mMasterRank ;
31
32 // id of solver
33 int_t mSolverID = 0 ;
34
35 // vector containing user parameters
36 Vector< int_t > mIParameters ;
37 Vector< real > mRParameters ;
38
39 // vector containing debug information ( rank-local INFO: a
40 // failing rank holds the true code, the others the propagated -1;
41 // still read by check_warnings(), which is rank-local by design )
42 Vector< int_t > mInfo ;
43
44 // rank-uniform INFOG: same code and supplementary value on every
45 // rank, so the -9 retry ladder and the error arms key on it --
46 // a branch taken from mInfo would strand ranks outside the
47 // collective call. Vector< int_t > to match its sibling mInfo,
48 // not a linear-algebra object
49 Vector< int_t > mInfoG ;
50
51 Vector< real > mRInfoG ;
52
53 // pointer to matrix
54 SpMatrix * mMatrix = nullptr ;
55
68 struct FrozenFactorization
69 {
70 bool mArmed = false ;
71
73 bool mHaveIdentity = false ;
74
75 const SpMatrix * mSource = nullptr ;
76 index_t mNumRows = 0 ;
77 index_t mNumCols = 0 ;
78 index_t mNumNonZeros = 0 ;
79 const real * mValues = nullptr ;
80 const int_t * mPointers = nullptr ;
81 };
82
83 FrozenFactorization mFrozen ;
84
91 int_t mMeasuredBudgetMB = 0 ;
92
99 bool mInitialized = false ;
100
105
106//------------------------------------------------------------------------------
107 public:
108//------------------------------------------------------------------------------
109
110 MUMPS( const SolverParameters * aParams, const proc_t aMasterRank = 0 );
111
112//------------------------------------------------------------------------------
113
114 ~MUMPS() override ;
115
116//------------------------------------------------------------------------------
117
120 bool
121 supports_factorization_reuse() const override ;
122
123 void
124 freeze_factorization( const SpMatrix & aMatrix ) override ;
125
126 void
127 unfreeze_factorization() override ;
128
129 bool
130 factorization_is_frozen() const override ;
131
132//------------------------------------------------------------------------------
133 private:
134//------------------------------------------------------------------------------
135
142 int_t
143 select_job( SpMatrix & aMatrix );
144
149 void
150 invalidate_factorization();
151
152//------------------------------------------------------------------------------
153
166 bool
167 escalate_workspace( int_t & aJob );
168
178 int_t
179 memory_budget_mb();
180
181//------------------------------------------------------------------------------
182 public:
183//------------------------------------------------------------------------------
184
185//------------------------------------------------------------------------------
186
187 void
188 solve(
189 SpMatrix & aMatrix,
190 Vector< real > & aLHS,
191 Vector< real > & aRHS ) override ;
192
193//------------------------------------------------------------------------------
194
195 void
196 solve(
197 SpMatrix & aMatrix,
198 Matrix< real > & aLHS,
199 Matrix< real > & aRHS ) override ;
200
201//------------------------------------------------------------------------------
202
203 void
204 free() override ;
205
206//------------------------------------------------------------------------------
207
208 void
210 const MumpsSerialReodrdering aSerial,
211 const MumpsParallelReodrdering aParallel
212 );
213
214//------------------------------------------------------------------------------
215
216 void
218 const MumpsBlockLowRanking aBLK,
219 const real aEpsilon
220 );
221
222//------------------------------------------------------------------------------
223
224 void
226 const MumpsErrorAnalysis aSetting
227 );
228
229//------------------------------------------------------------------------------
230
235 real
236 get_determinant() const override ;
237
238//------------------------------------------------------------------------------
239
244 real
245 get_cond1() const override ;
246
247//------------------------------------------------------------------------------
248
253 real
254 get_cond2() const override ;
255
256//------------------------------------------------------------------------------
257
261 real
262 get_forward_error() const override ;
263
264//------------------------------------------------------------------------------
265
271 real
272 get_backward_error() const override ;
273
274//------------------------------------------------------------------------------
275
281 real
282 get_omega2() const override ;
283
284//------------------------------------------------------------------------------
285 protected :
286//------------------------------------------------------------------------------
287
288 void
290 SpMatrix & aMatrix,
291 const SymmetryMode aSymmetryMode = SymmetryMode::Unsymmetric,
292 const int_t aNumRhsColumns=1 ) override ;
293
294
295//------------------------------------------------------------------------------
296
297 string
299 const int_t * aInfo,
300 const int_t & aN,
301 const int_t & aNNZ ) ;
302
303//------------------------------------------------------------------------------
304
305 // decodes a positive INFO(1) warning ( a usable solution is still
306 // returned ) into one human-readable line per active warning bit
307 void
309 const int_t * aInfo,
310 Cell< string > & aWarnings ) ;
311
312//------------------------------------------------------------------------------
313 private :
314//------------------------------------------------------------------------------
315
316 void
317 init_defaults();
318
319//------------------------------------------------------------------------------
320
321 // handles a positive INFO(1) after a solve: raises a hard error on
322 // the out-of-range-index bit ( +1 ) and reports the remaining
323 // warnings per rank. NOT used by free(), which is teardown
324 void
325 check_warnings();
326
327//------------------------------------------------------------------------------
328
329 // rank-0 log line for the soft-fail path, box-styled to match the
330 // controller's timestep box, with a compact INFO decode ( the full
331 // decode lives in error_message() on the hard path )
332 void
333 print_soft_fail();
334
335//------------------------------------------------------------------------------
336 };
337 }
338}
339#endif //BELFEM_CL_SOLVERMUMPS_HPP
Configuration for a Solver.
Definition cl_SolverParameters.hpp:27
Sparse matrix in CSR or CSC format.
Definition cl_SpMatrix.hpp:52
real get_determinant() const override
returns the determinant, if supported by the solver and computation was requested
Definition cl_SolverMUMPS.cpp:2084
void set_reordering(const MumpsSerialReodrdering aSerial, const MumpsParallelReodrdering aParallel)
Definition cl_SolverMUMPS.cpp:2048
real get_omega2() const override
RINFOG( 8 ) alone: omega2.
Definition cl_SolverMUMPS.cpp:2152
void warning_message(const int_t *aInfo, Cell< string > &aWarnings)
Definition cl_SolverMUMPS.cpp:1789
real get_cond1() const override
returns the conditioning number, if supported by the solver and computation was requested
Definition cl_SolverMUMPS.cpp:2094
real get_forward_error() const override
RINFOG( 9 ): estimated forward error of the last solve.
Definition cl_SolverMUMPS.cpp:2114
void set_error_analysis(const MumpsErrorAnalysis aSetting)
Definition cl_SolverMUMPS.cpp:2074
bool supports_factorization_reuse() const override
Definition cl_SolverMUMPS.cpp:516
void solve(SpMatrix &aMatrix, Vector< real > &aLHS, Vector< real > &aRHS) override
Definition cl_SolverMUMPS.cpp:824
real get_backward_error() const override
RINFOG( 7 ) + RINFOG( 8 ): the componentwise backward error.
Definition cl_SolverMUMPS.cpp:2127
void free() override
Definition cl_SolverMUMPS.cpp:404
bool factorization_is_frozen() const override
true while the frozen scope is armed
Definition cl_SolverMUMPS.cpp:573
MUMPS(const SolverParameters *aParams, const proc_t aMasterRank=0)
Definition cl_SolverMUMPS.cpp:70
void initialize(SpMatrix &aMatrix, const SymmetryMode aSymmetryMode=SymmetryMode::Unsymmetric, const int_t aNumRhsColumns=1) override
Definition cl_SolverMUMPS.cpp:204
real get_cond2() const override
returns the conditioning number, if supported by the solver and computation was requested
Definition cl_SolverMUMPS.cpp:2104
void set_block_low_ranking(const MumpsBlockLowRanking aBLK, const real aEpsilon)
Definition cl_SolverMUMPS.cpp:2062
void unfreeze_factorization() override
drop the frozen state and return to ordinary re-factorizing solves.
Definition cl_SolverMUMPS.cpp:565
void freeze_factorization(const SpMatrix &aMatrix) override
arm the frozen state: subsequent solves reuse the factorization that the LAST SUCCESSFUL solve built,...
Definition cl_SolverMUMPS.cpp:524
string error_message(const int_t *aInfo, const int_t &aN, const int_t &aNNZ)
Definition cl_SolverMUMPS.cpp:1244
Wrapper(const string &aLabel, const bool aUsesMPI)
Definition cl_SolverWrapper.cpp:44
Definition cl_SolverMUMPS.cpp:26
USER GUIDES:
Definition cl_Capacitor.cpp:16
MumpsSerialReodrdering
MUMPS only.
Definition en_SolverEnums.hpp:142
MumpsErrorAnalysis
MUMPS only.
Definition en_SolverEnums.hpp:187
int proc_t
Definition commtypes.hpp:29
SymmetryMode
Definition en_SolverEnums.hpp:36
@ Unsymmetric
Definition en_SolverEnums.hpp:37
uint32_t index_t
Definition typedefs.hpp:52
double real
Definition typedefs.hpp:36
MumpsBlockLowRanking
MUMPS only.
Definition en_SolverEnums.hpp:173
int32_t int_t
Definition typedefs.hpp:51
MumpsParallelReodrdering
MUMPS only.
Definition en_SolverEnums.hpp:160