@@ -15,24 +15,34 @@ Base.@kwdef struct PardisoJL <: SciMLLinearSolveAlgorithm
1515 dparm:: Union{Vector{Tuple{Int,Int}}, Nothing} = nothing
1616end
1717
18- PardisoJLFactorize (;kwargs... ) = PardisoJL (;solver_type= 0 , kwargs... )
19- PardisoJLIterate (;kwargs... ) = PardisoJL (;solver_type= 1 , kwargs... )
18+ PardisoJLFactorize (;kwargs... ) = PardisoJL (;solver_type= 0 ,
19+ solve_phase= Pardiso. NUM_FACT,
20+ kwargs... )
21+ PardisoJLIterate (;kwargs... ) = PardisoJL (;solver_type= 1 ,
22+ solve_phase= Pardiso. SOLVE_ITERATIVE_REFINE,
23+ kwargs... )
2024
2125# TODO schur complement functionality
2226
2327function init_cacheval (alg:: PardisoJL , cache:: LinearCache )
2428 @unpack nprocs, solver_type, matrix_type, iparm, dparm = alg
2529
26- solver = Pardiso. PARDISO_LOADED[] ? Pardiso. PardisoSolver () : Pardiso. MKLPardisoSolver ()
30+ solver =
31+ if Pardiso. PARDISO_LOADED[]
32+ Pardiso. PardisoSolver ()
33+ solver_type != = nothing && Pardiso. set_solver! (solver, solver_type)
34+ else
35+ Pardiso. MKLPardisoSolver ()
36+ nprocs != = nothing && Pardiso. set_nprocs! (solver, nprocs)
37+ end
2738
2839 Pardiso. pardisoinit (solver) # default initialization
2940
30- nprocs != = nothing && Pardiso. set_nprocs! (ps, nprocs)
31- solver_type != = nothing && Pardiso. set_solver! (solver, key)
41+ @show solver
3242 matrix_type != = nothing && Pardiso. set_matrixtype! (solver, matrix_type)
3343 cache. verbose && Pardiso. set_msglvl! (solver, Pardiso. MESSAGE_LEVEL_ON)
3444
35- if iparm != = nothing # pass in vector of tuples like [(iparm, key)]
45+ if iparm != = nothing # pass in vector of tuples like [(iparm, key) ... ]
3646 for i in length (iparm)
3747 Pardiso. set_iparm! (solver, iparm[i]. .. )
3848 end
@@ -44,6 +54,8 @@ function init_cacheval(alg::PardisoJL, cache::LinearCache)
4454 end
4555 end
4656
57+ Pardiso. set_phase! (cacheval, Pardiso. ANALYSIS)
58+
4759 return solver
4860end
4961
@@ -62,13 +74,9 @@ function SciMLBase.solve(cache::LinearCache, alg::PardisoJL; kwargs...)
6274 reltol = cache. reltol
6375 kwargs = (abstol= abstol, reltol= reltol)
6476
65- """
66- figure out whatever phase is. should set_phase call be in init_cacheval?
67- can we use phase to store factorization in cache?
68- """
6977 alg. solve_phase != = nothing && Pardiso. set_phase! (cacheval, alg. solve_phase)
7078 Pardiso. pardiso (cache. cacheval, u, A, b)
71- alg. release_phase != = nothing && Pardiso. set_phase! (cacheval, alg. release_phase) # is this necessary?
79+ alg. release_phase != = nothing && Pardiso. set_phase! (cacheval, alg. release_phase)
7280
7381 return cache. u
7482end
0 commit comments