@@ -126,7 +126,7 @@ struct F <: Cycle
126126end
127127
128128"""
129- solve (ml::MultiLevel, b::AbstractArray, cycle, kwargs...)
129+ _solve (ml::MultiLevel, b::AbstractArray, cycle, kwargs...)
130130
131131Execute multigrid cycling.
132132
@@ -145,13 +145,13 @@ Keyword Arguments
145145* log::Bool - return vector of residuals along with solution
146146
147147"""
148- function solve (ml:: MultiLevel , b:: AbstractArray , args... ; kwargs... )
148+ function _solve (ml:: MultiLevel , b:: AbstractArray , args... ; kwargs... )
149149 n = length (ml) == 1 ? size (ml. final_A, 1 ) : size (ml. levels[1 ]. A, 1 )
150150 V = promote_type (eltype (ml. workspace), eltype (b))
151151 x = zeros (V, size (b))
152- return solve ! (x, ml, b, args... ; kwargs... )
152+ return _solve ! (x, ml, b, args... ; kwargs... )
153153end
154- function solve ! (x, ml:: MultiLevel , b:: AbstractArray{T} ,
154+ function _solve ! (x, ml:: MultiLevel , b:: AbstractArray{T} ,
155155 cycle:: Cycle = V ();
156156 maxiter:: Int = 100 ,
157157 abstol:: Real = zero (real (eltype (b))),
@@ -233,3 +233,29 @@ function __solve!(x, ml, cycle::Cycle, b, lvl)
233233
234234 x
235235end
236+
237+
238+ # ## CommonSolve.jl spec
239+ struct AMGSolver{T}
240+ ml:: MultiLevel
241+ b:: Vector{T}
242+ end
243+
244+ abstract type AMGAlg end
245+
246+ struct RugeStubenAMG <: AMGAlg end
247+ struct SmoothedAggregationAMG <: AMGAlg end
248+
249+ function solve (A:: AbstractMatrix , b:: Vector , s:: AMGAlg , args... ; kwargs... )
250+ solt = init (s, A, b, args... ; kwargs... )
251+ solve! (solt, args... ; kwargs... )
252+ end
253+ function init (:: RugeStubenAMG , A, b, args... ; kwargs... )
254+ AMGSolver (ruge_stuben (A; kwargs... ), b)
255+ end
256+ function init (:: SmoothedAggregationAMG , A, b; kwargs... )
257+ AMGSolver (smoothed_aggregation (A; kwargs... ), b)
258+ end
259+ function solve! (solt:: AMGSolver , args... ; kwargs... )
260+ _solve (solt. ml, solt. b, args... ; kwargs... )
261+ end
0 commit comments