|
1 | 1 | import LinearAlgebra: axpy!, axpby! |
2 | | -import Krylov.CgSolver |
| 2 | +import Krylov.CgWorkspace |
3 | 3 | import Base.setproperty! |
4 | 4 |
|
5 | 5 | function axpy!( |
@@ -124,30 +124,32 @@ function axpby!( |
124 | 124 | return y |
125 | 125 | end |
126 | 126 |
|
127 | | -function CgSolver(pv::PartitionedVector{T}) where {T} |
| 127 | +function CgWorkspace(pv::PartitionedVector{T}) where {T} |
128 | 128 | n = length(pv) |
129 | 129 | Δx = similar(pv; simulate_vector = true) |
130 | 130 | Δx .= (T)(0) # by setting Δx .= 0, we ensure that at each iterate the initial point `r` is 0. |
131 | 131 | x = similar(pv; simulate_vector = true) |
132 | 132 | x .= (T)(0) |
133 | 133 | r = similar(pv; simulate_vector = true) |
134 | 134 | r .= (T)(0) # will be reset at each cg! call to 0 because of mul!(r,A,Δx) |
| 135 | + npc_dir = similar(pv; simulate_vector = true) |
| 136 | + npc_dir .= (T)(0) |
135 | 137 | p = similar(pv; simulate_vector = true) |
136 | 138 | p .= (T)(0) |
137 | 139 | Ap = similar(pv; simulate_vector = false) # result of the partitioned matrix vector product |
138 | 140 | Ap .= (T)(0) |
139 | 141 | z = similar(pv; simulate_vector = true) |
140 | 142 | z .= (T)(0) |
141 | | - stats = Krylov.SimpleStats(0, false, false, T[], T[], T[], 0.0, "unknown") |
142 | | - solver = Krylov.CgSolver{T, T, PartitionedVector{T}}(n, n, Δx, x, r, p, Ap, z, true, stats) |
| 143 | + stats = Krylov.SimpleStats(0, false, false, false, 0, T[], T[], T[], 0.0, "unknown") |
| 144 | + solver = Krylov.CgWorkspace{T, T, PartitionedVector{T}}(n, n, Δx, x, r, npc_dir, p, Ap, z, true, stats) |
143 | 145 | return solver |
144 | 146 | end |
145 | 147 |
|
146 | 148 | # This way, solver.warm_start stays true at all time. |
147 | 149 | # It prevents the else case where r .= b at the beginning of cg!. |
148 | 150 | # r is supposed to simulate a vector while b is not supposed to. |
149 | 151 | function setproperty!( |
150 | | - solver::CgSolver{T, T, PartitionedVector{T}}, |
| 152 | + solver::CgWorkspace{T, T, PartitionedVector{T}}, |
151 | 153 | sym::Symbol, |
152 | 154 | val::Bool, |
153 | 155 | ) where {T} |
|
0 commit comments