From 651f33071890d2c53d50bfa90889b16ac85a96b5 Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Wed, 4 Sep 2024 16:19:06 +1000 Subject: [PATCH] Added set_depth! --- src/SolverInterfaces/ConvergenceLogs.jl | 20 ++++++++++++++++++++ src/SolverInterfaces/SolverInterfaces.jl | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/SolverInterfaces/ConvergenceLogs.jl b/src/SolverInterfaces/ConvergenceLogs.jl index 87603b5c..fdc86749 100644 --- a/src/SolverInterfaces/ConvergenceLogs.jl +++ b/src/SolverInterfaces/ConvergenceLogs.jl @@ -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}) diff --git a/src/SolverInterfaces/SolverInterfaces.jl b/src/SolverInterfaces/SolverInterfaces.jl index 24563838..8b9aa724 100644 --- a/src/SolverInterfaces/SolverInterfaces.jl +++ b/src/SolverInterfaces/SolverInterfaces.jl @@ -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