@@ -4,8 +4,8 @@ using LinearAlgebra
44using HYPRE. LibHYPRE: HYPRE_Complex
55using HYPRE: HYPRE, HYPREMatrix, HYPRESolver, HYPREVector
66using LinearSolve: HYPREAlgorithm, LinearCache, LinearProblem, LinearSolve,
7- OperatorAssumptions, default_tol, init_cacheval, __issquare,
8- __conditioning
7+ OperatorAssumptions, default_tol, init_cacheval, __issquare,
8+ __conditioning
99using SciMLBase: LinearProblem, SciMLBase
1010using UnPack: @unpack
1111using Setfield: @set!
@@ -21,8 +21,8 @@ mutable struct HYPRECache
2121end
2222
2323function LinearSolve. init_cacheval (alg:: HYPREAlgorithm , A, b, u, Pl, Pr, maxiters:: Int ,
24- abstol, reltol,
25- verbose:: Bool , assumptions:: OperatorAssumptions )
24+ abstol, reltol,
25+ verbose:: Bool , assumptions:: OperatorAssumptions )
2626 return HYPRECache (nothing , nothing , nothing , nothing , true , true , true )
2727end
2828
5454# fill!(similar(b, size(A, 2)), false) since HYPREArrays are not AbstractArrays.
5555
5656function SciMLBase. init (prob:: LinearProblem , alg:: HYPREAlgorithm ,
57- args... ;
58- alias_A = false , alias_b = false ,
59- # TODO : Implement eltype for HYPREMatrix in HYPRE.jl? Looks useful
60- # even if it is not AbstractArray.
61- abstol = default_tol (prob. A isa HYPREMatrix ? HYPRE_Complex :
62- eltype (prob. A)),
63- reltol = default_tol (prob. A isa HYPREMatrix ? HYPRE_Complex :
64- eltype (prob. A)),
65- # TODO : Implement length() for HYPREVector in HYPRE.jl?
66- maxiters:: Int = prob. b isa HYPREVector ? 1000 : length (prob. b),
67- verbose:: Bool = false ,
68- Pl = LinearAlgebra. I,
69- Pr = LinearAlgebra. I,
70- assumptions = OperatorAssumptions (),
71- kwargs... )
57+ args... ;
58+ alias_A = false , alias_b = false ,
59+ # TODO : Implement eltype for HYPREMatrix in HYPRE.jl? Looks useful
60+ # even if it is not AbstractArray.
61+ abstol = default_tol (prob. A isa HYPREMatrix ? HYPRE_Complex :
62+ eltype (prob. A)),
63+ reltol = default_tol (prob. A isa HYPREMatrix ? HYPRE_Complex :
64+ eltype (prob. A)),
65+ # TODO : Implement length() for HYPREVector in HYPRE.jl?
66+ maxiters:: Int = prob. b isa HYPREVector ? 1000 : length (prob. b),
67+ verbose:: Bool = false ,
68+ Pl = LinearAlgebra. I,
69+ Pr = LinearAlgebra. I,
70+ assumptions = OperatorAssumptions (),
71+ kwargs... )
7272 @unpack A, b, u0, p = prob
7373
7474 A = A isa HYPREMatrix ? A : HYPREMatrix (A)
@@ -82,23 +82,23 @@ function SciMLBase.init(prob::LinearProblem, alg::HYPREAlgorithm,
8282
8383 # Initialize internal alg cache
8484 cacheval = init_cacheval (alg, A, b, u0, Pl, Pr, maxiters, abstol, reltol, verbose,
85- assumptions)
85+ assumptions)
8686 Tc = typeof (cacheval)
8787 isfresh = true
8888
8989 cache = LinearCache{
90- typeof (A), typeof (b), typeof (u0), typeof (p), typeof (alg), Tc,
91- typeof (Pl), typeof (Pr), typeof (reltol),
92- typeof (__issquare (assumptions))
93- }(A, b, u0, p, alg, cacheval, isfresh, Pl, Pr, abstol, reltol,
94- maxiters,
95- verbose, assumptions)
90+ typeof (A), typeof (b), typeof (u0), typeof (p), typeof (alg), Tc,
91+ typeof (Pl), typeof (Pr), typeof (reltol),
92+ typeof (__issquare (assumptions)),
93+ }(A, b, u0, p, alg, cacheval, isfresh, Pl, Pr, abstol, reltol,
94+ maxiters,
95+ verbose, assumptions)
9696 return cache
9797end
9898
9999# Solvers whose constructor requires passing the MPI communicator
100100const COMM_SOLVERS = Union{HYPRE. BiCGSTAB, HYPRE. FlexGMRES, HYPRE. GMRES, HYPRE. ParaSails,
101- HYPRE. PCG}
101+ HYPRE. PCG}
102102create_solver (:: Type{S} , comm) where {S <: COMM_SOLVERS } = S (comm)
103103
104104# Solvers whose constructor should not be passed the MPI communicator
@@ -120,10 +120,10 @@ function create_solver(alg::HYPREAlgorithm, cache::LinearCache)
120120
121121 # Construct solver options
122122 solver_options = (;
123- AbsoluteTol = cache. abstol,
124- MaxIter = cache. maxiters,
125- PrintLevel = Int (cache. verbose),
126- Tol = cache. reltol)
123+ AbsoluteTol = cache. abstol,
124+ MaxIter = cache. maxiters,
125+ PrintLevel = Int (cache. verbose),
126+ Tol = cache. reltol)
127127
128128 # Preconditioner (uses Pl even though it might not be a *left* preconditioner just *a*
129129 # preconditioner)
@@ -211,16 +211,16 @@ function SciMLBase.solve!(cache::LinearCache, alg::HYPREAlgorithm, args...; kwar
211211 stats = nothing
212212
213213 ret = SciMLBase. LinearSolution{T, N, typeof (cache. u), typeof (resid), typeof (alg),
214- typeof (cache), typeof (stats)}(cache. u, resid, alg, retc,
215- iters, cache, stats)
214+ typeof (cache), typeof (stats)}(cache. u, resid, alg, retc,
215+ iters, cache, stats)
216216
217217 return ret
218218end
219219
220220# HYPREArrays are not AbstractArrays so perform some type-piracy
221221function SciMLBase. LinearProblem (A:: HYPREMatrix , b:: HYPREVector ,
222- p = SciMLBase. NullParameters ();
223- u0:: Union{HYPREVector, Nothing} = nothing , kwargs... )
222+ p = SciMLBase. NullParameters ();
223+ u0:: Union{HYPREVector, Nothing} = nothing , kwargs... )
224224 return LinearProblem {true} (A, b, p; u0 = u0, kwargs)
225225end
226226
0 commit comments