Julia interface to hypre linear solvers (https://github.com/hypre-space/hypre)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
1.4 KiB

using HYPRE.LibHYPRE
function generate_options(io, structname, prefix)
println(io, "")
println(io, "function Internals.set_options(s::$(structname), kwargs)")
println(io, " solver = s.solver")
println(io, " for (k, v) in kwargs")
r = Regex("^" * prefix * "([A-Z].*)\$")
ns = sort!(filter!(x -> occursin(r, string(x)), names(LibHYPRE)))
first = true
for n in ns
m = get(methods(getfield(LibHYPRE, n)), 1, nothing)
m === nothing && continue
nargs = m.nargs - 1
k = String(match(r, string(n))[1])
print(io, " $(first ? "" : "else")if k === :$(k)")
println(io)
if nargs == 1
println(io, " @check ", n, "(solver)")
elseif nargs == 2
println(io, " @check ", n, "(solver, v)")
else # nargs >= 3
println(io, " @check ", n, "(solver, v...)")
end
first = false
end
println(io, " end")
println(io, " end")
println(io, "end")
end
open(joinpath(@__DIR__, "..", "src", "solver_options.jl"), "w") do io
println(io, "# SPDX-License-Identifier: MIT")
println(io, "")
println(io, "# This file is automatically generated by gen/solver_options.jl")
println(io, "")
println(io, "Internals.set_options(::HYPRESolver, kwargs) = nothing")
generate_options(io, "BoomerAMG", "HYPRE_BoomerAMGSet")
end