BELFEM 0.9.3
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
111 MUMPS( const SolverParameters * aParams, const proc_t aMasterRank = 0 );
112
113//------------------------------------------------------------------------------
114
115 ~MUMPS() override ;
116
117//------------------------------------------------------------------------------
118
121 bool
122 supports_factorization_reuse() const override ;
123
124 void
125 freeze_factorization( const SpMatrix & aMatrix ) override ;
126
127 void
128 unfreeze_factorization() override ;
129
130 bool
131 factorization_is_frozen() const override ;
132
133//------------------------------------------------------------------------------
134 private:
135//------------------------------------------------------------------------------
136
143 int_t
144 select_job( SpMatrix & aMatrix );
145
150 void
151 invalidate_factorization();
152
153//------------------------------------------------------------------------------
154
167 bool
168 escalate_workspace( int_t & aJob );
169
179 int_t
180 memory_budget_mb();
181
182//------------------------------------------------------------------------------
183 public:
184//------------------------------------------------------------------------------
185
186//------------------------------------------------------------------------------
187
193 void
194 solve(
195 SpMatrix & aMatrix,
196 Vector< real > & aLHS,
197 Vector< real > & aRHS ) override ;
198
199//------------------------------------------------------------------------------
200
201 void
202 solve(
203 SpMatrix & aMatrix,
204 Matrix< real > & aLHS,
205 Matrix< real > & aRHS ) override ;
206
207//------------------------------------------------------------------------------
208
209 void
210 free() override ;
211
212//------------------------------------------------------------------------------
213
214 void
216 const MumpsSerialReodrdering aSerial,
217 const MumpsParallelReodrdering aParallel
218 );
219
220//------------------------------------------------------------------------------
221
222 void
224 const MumpsBlockLowRanking aBLK,
225 const real aEpsilon
226 );
227
228//------------------------------------------------------------------------------
229
230 void
232 const MumpsErrorAnalysis aSetting
233 );
234
235//------------------------------------------------------------------------------
236
241 real
242 get_determinant() const override ;
243
244//------------------------------------------------------------------------------
245
250 real
251 get_cond1() const override ;
252
253//------------------------------------------------------------------------------
254
259 real
260 get_cond2() const override ;
261
262//------------------------------------------------------------------------------
263
267 real
268 get_forward_error() const override ;
269
270//------------------------------------------------------------------------------
271
277 real
278 get_backward_error() const override ;
279
280//------------------------------------------------------------------------------
281
287 real
288 get_omega2() const override ;
289
290//------------------------------------------------------------------------------
291 protected :
292//------------------------------------------------------------------------------
293
294 void
296 SpMatrix & aMatrix,
297 const SymmetryMode aSymmetryMode = SymmetryMode::Unsymmetric,
298 const int_t aNumRhsColumns=1 ) override ;
299
300
301//------------------------------------------------------------------------------
302
303 string
305 const int_t * aInfo,
306 const int_t & aN,
307 const int_t & aNNZ ) ;
308
309//------------------------------------------------------------------------------
310
311 // decodes a positive INFO(1) warning ( a usable solution is still
312 // returned ) into one human-readable line per active warning bit
313 void
315 const int_t * aInfo,
316 Cell< string > & aWarnings ) ;
317
318//------------------------------------------------------------------------------
319 private :
320//------------------------------------------------------------------------------
321
322 void
323 init_defaults();
324
325//------------------------------------------------------------------------------
326
327 // handles a positive INFO(1) after a solve: raises a hard error on
328 // the out-of-range-index bit ( +1 ) and reports the remaining
329 // warnings per rank. NOT used by free(), which is teardown
330 void
331 check_warnings();
332
333//------------------------------------------------------------------------------
334
335 // rank-0 log line for the soft-fail path, box-styled to match the
336 // controller's timestep box, with a compact INFO decode ( the full
337 // decode lives in error_message() on the hard path )
338 void
339 print_soft_fail();
340
341//------------------------------------------------------------------------------
342 };
343 }
344}
345#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:2062
void set_reordering(const MumpsSerialReodrdering aSerial, const MumpsParallelReodrdering aParallel)
Definition cl_SolverMUMPS.cpp:2026
real get_omega2() const override
RINFOG( 8 ) alone: omega2.
Definition cl_SolverMUMPS.cpp:2130
void warning_message(const int_t *aInfo, Cell< string > &aWarnings)
Definition cl_SolverMUMPS.cpp:1763
real get_cond1() const override
returns the conditioning number, if supported by the solver and computation was requested
Definition cl_SolverMUMPS.cpp:2072
real get_forward_error() const override
RINFOG( 9 ): estimated forward error of the last solve.
Definition cl_SolverMUMPS.cpp:2092
void set_error_analysis(const MumpsErrorAnalysis aSetting)
Definition cl_SolverMUMPS.cpp:2052
bool supports_factorization_reuse() const override
Definition cl_SolverMUMPS.cpp:490
void solve(SpMatrix &aMatrix, Vector< real > &aLHS, Vector< real > &aRHS) override
Collective.
Definition cl_SolverMUMPS.cpp:798
real get_backward_error() const override
RINFOG( 7 ) + RINFOG( 8 ): the componentwise backward error.
Definition cl_SolverMUMPS.cpp:2105
void free() override
Definition cl_SolverMUMPS.cpp:379
bool factorization_is_frozen() const override
true while the frozen scope is armed
Definition cl_SolverMUMPS.cpp:547
MUMPS(const SolverParameters *aParams, const proc_t aMasterRank=0)
aParams is borrowed and must outlive the wrapper.
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:2082
void set_block_low_ranking(const MumpsBlockLowRanking aBLK, const real aEpsilon)
Definition cl_SolverMUMPS.cpp:2040
void unfreeze_factorization() override
drop the frozen state and return to ordinary re-factorizing solves.
Definition cl_SolverMUMPS.cpp:539
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:498
string error_message(const int_t *aInfo, const int_t &aN, const int_t &aNNZ)
Definition cl_SolverMUMPS.cpp:1218
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