@@ -5,41 +5,35 @@ import Pardiso
5
5
6
6
export PardisoJL
7
7
8
- struct PardisoJL{A} <: SciMLLinearSolveAlgorithm
9
- nthreads:: Union{Int, Nothing}
10
- solver_type:: Union{Int, Pardiso.Solver, Nothing}
11
- matrix_type:: Union{Int, Pardiso.MatrixType, Nothing}
12
- solve_phase:: Union{Int, Pardiso.Phase, Nothing}
13
- release_phase:: Union{Int, Nothing}
14
- iparm:: Union{A, Nothing}
15
- dparm:: Union{A, Nothing}
16
- end
17
-
18
- function PardisoJL (solver_type= Pardiso. nothing ,)
19
-
20
- return PardisoJL (nthreads, solver_type, matrix_type, solve_phase,
21
- release_phase, iparm, dparm)
8
+ Base. @kwdef struct PardisoJL <: SciMLLinearSolveAlgorithm
9
+ nprocs:: Union{Int, Nothing} = nothing
10
+ solver_type:: Union{Int, Pardiso.Solver, Nothing} = nothing
11
+ matrix_type:: Union{Int, Pardiso.MatrixType, Nothing} = nothing
12
+ solve_phase:: Union{Int, Pardiso.Phase, Nothing} = nothing
13
+ release_phase:: Union{Int, Nothing} = nothing
14
+ iparm:: Union{Vector{Tuple{Int,Int}}, Nothing} = nothing
15
+ dparm:: Union{Vector{Tuple{Int,Int}}, Nothing} = nothing
22
16
end
23
17
24
18
function init_cacheval (alg:: PardisoJL , cache:: LinearCache )
25
- @unpack nthreads , solver_type, matrix_type, iparm, dparm = alg
19
+ @unpack nprocs , solver_type, matrix_type, iparm, dparm = alg
26
20
27
- solver = Pardiso. PARDISO_LOADED[] ? PardisoSolver () : MKLPardisoSolver ()
21
+ solver = Pardiso. PARDISO_LOADED[] ? Pardiso . PardisoSolver () : Pardiso . MKLPardisoSolver ()
28
22
29
23
Pardiso. pardisoinit (solver) # default initialization
30
24
31
- nthreads != = nothing && Pardiso. set_nprocs! (ps, nthreads )
25
+ nprocs != = nothing && Pardiso. set_nprocs! (ps, nprocs )
32
26
solver_type != = nothing && Pardiso. set_solver! (solver, key)
33
27
matrix_type != = nothing && Pardiso. set_matrixtype! (solver, matrix_type)
34
28
cache. verbose && Pardiso. set_msglvl! (solver, Pardiso. MESSAGE_LEVEL_ON)
35
29
36
- iparm != = nothing && begin # pass in vector of tuples like [(iparm, key)]
30
+ if iparm != = nothing # pass in vector of tuples like [(iparm, key)]
37
31
for i in length (iparm)
38
32
Pardiso. set_iparm! (solver, iparm[i]. .. )
39
33
end
40
34
end
41
35
42
- dparm != = nothing && begin
36
+ if dparm != = nothing
43
37
for i in length (dparm)
44
38
Pardiso. set_dparm! (solver, dparm[i]. .. )
45
39
end
@@ -49,7 +43,10 @@ function init_cacheval(alg::PardisoJL, cache::LinearCache)
49
43
end
50
44
51
45
function SciMLBase. solve (cache:: LinearCache , alg:: PardisoJL ; kwargs... )
52
- @unpack A, b, u, cacheval = cache
46
+ @unpack A, b, u = cache
47
+ if A isa DiffEqArrayOperator
48
+ A = A. A
49
+ end
53
50
54
51
if cache. isfresh
55
52
solver = init_cacheval (alg, cache)
@@ -58,15 +55,15 @@ function SciMLBase.solve(cache::LinearCache, alg::PardisoJL; kwargs...)
58
55
59
56
abstol = cache. abstol
60
57
reltol = cache. reltol
61
- kwargs = (abstol= abstol, reltol= reltol, alg . kwargs ... )
58
+ kwargs = (abstol= abstol, reltol= reltol)
62
59
63
60
"""
64
61
figure out whatever phase is. should set_phase call be in init_cacheval?
65
62
can we use phase to store factorization in cache?
66
63
"""
67
- Pardiso. set_phase! (cacheval, alg. solve_phase)
68
- Pardiso. solve! (cacheval, u, A, b)
69
- Pardiso. set_phase! (cacheval, alg. release_phase) # is this necessary?
64
+ alg . solve_phase != = nothing && Pardiso. set_phase! (cacheval, alg. solve_phase)
65
+ Pardiso. solve! (cache . cacheval, u, A, b)
66
+ alg . release_phase != = nothing && Pardiso. set_phase! (cacheval, alg. release_phase) # is this necessary?
70
67
71
68
return cache. u
72
69
end
0 commit comments