@@ -60,7 +60,30 @@ function init_cacheval(alg::PardisoJL, A, b, u, Pl, Pr, maxiters, abstol, reltol
60
60
# Make sure to say it's transposed because its CSC not CSR
61
61
Pardiso. set_iparm! (solver,12 , 1 )
62
62
63
+ #=
64
+ Note: It is recommended to use IPARM(11)=1 (scaling) and IPARM(13)=1 (matchings) for
65
+ highly indefinite symmetric matrices e.g. from interior point optimizations or saddle point problems.
66
+ It is also very important to note that the user must provide in the analysis phase (PHASE=11)
67
+ the numerical values of the matrix A if IPARM(11)=1 (scaling) or PARM(13)=1 or 2 (matchings).
68
+
69
+ The numerical values will be incorrect since the analysis is ran once and
70
+ cached. If these two are not set, then Pardiso.NUM_FACT in the solve must
71
+ be changed to Pardiso.ANALYSIS_NUM_FACT in the solver loop otherwise instabilities
72
+ occur in the example https://github.com/SciML/OrdinaryDiffEq.jl/issues/1569
73
+ =#
74
+ Pardiso. set_iparm! (solver,11 , 0 )
75
+ Pardiso. set_iparm! (solver,13 , 0 )
76
+
63
77
Pardiso. set_phase! (solver, Pardiso. ANALYSIS)
78
+
79
+ if alg. solver_type == 1
80
+ # PARDISO uses a numerical factorization A = LU for the first system and
81
+ # applies these exact factors L and U for the next steps in a
82
+ # preconditioned Krylov-Subspace iteration. If the iteration does not
83
+ # converge, the solver will automatically switch back to the numerical factorization.
84
+ Pardiso. set_iparm! (solver,3 ,round (Int,abs (log10 (reltol)),RoundDown) * 10 + 1 )
85
+ end
86
+
64
87
Pardiso. pardiso (solver, u, A, b)
65
88
66
89
return solver
@@ -72,11 +95,11 @@ function SciMLBase.solve(cache::LinearCache, alg::PardisoJL; kwargs...)
72
95
73
96
if cache. isfresh
74
97
Pardiso. set_phase! (cache. cacheval, Pardiso. NUM_FACT)
75
- Pardiso. pardiso (cache. cacheval, u, A, b )
98
+ Pardiso. pardiso (cache. cacheval, A, eltype (A)[] )
76
99
end
100
+
77
101
Pardiso. set_phase! (cache. cacheval, Pardiso. SOLVE_ITERATIVE_REFINE)
78
102
Pardiso. pardiso (cache. cacheval, u, A, b)
79
-
80
103
return SciMLBase. build_linear_solution (alg,cache. u,nothing ,cache)
81
104
end
82
105
0 commit comments