Skip to content

Commit

Permalink
Added set_depth!
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Sep 4, 2024
1 parent d0914d9 commit 651f330
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/SolverInterfaces/ConvergenceLogs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ end
@inline get_tabulation(log::ConvergenceLog) = get_tabulation(log,2)
@inline get_tabulation(log::ConvergenceLog,n::Int) = repeat(' ', n + 2*log.depth)

"""
set_depth!(log::ConvergenceLog,depth::Int)
set_depth!(log::LinearSolver,depth::Int)
Sets the tabulation depth of the convergence log `log` to `depth`.
"""
function set_depth!(log::ConvergenceLog,depth::Int)
log.depth = depth
return log
end

function set_depth!(solver::Algebra.LinearSolver,depth::Int)
if hasproperty(solver,:log)
set_depth!(solver.log,depth)
end
map(children(solver)) do child
set_depth!(child,depth)
end
end

"""
reset!(log::ConvergenceLog{T})
Expand Down
2 changes: 1 addition & 1 deletion src/SolverInterfaces/SolverInterfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include("SolverInfos.jl")

export SolverVerboseLevel, SolverConvergenceFlag
export SolverTolerances, get_solver_tolerances, set_solver_tolerances!
export ConvergenceLog, init!, update!, finalize!, reset!, print_message
export ConvergenceLog, init!, update!, finalize!, reset!, print_message, set_depth!

export SolverInfo

Expand Down

0 comments on commit 651f330

Please sign in to comment.