Skip to content

Commit f9f48ce

Browse files
committed
imports, other preparations
1 parent cb88691 commit f9f48ce

File tree

21 files changed

+68
-55
lines changed

21 files changed

+68
-55
lines changed

lib/BracketingNonlinearSolve/src/bisection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function SciMLBase.__solve(
4747
if sign(fl) == sign(fr)
4848
@SciMLMessage("The interval is not an enclosing interval, opposite signs at the \
4949
boundaries are required.",
50-
nonlinear_verbose[], :non_enclosing_interval, :error_control)
50+
verbose, :non_enclosing_interval, :error_control)
5151
return SciMLBase.build_solution(
5252
prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right
5353
)

lib/BracketingNonlinearSolve/src/brent.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function SciMLBase.__solve(
3535
if sign(fl) == sign(fr)
3636
@SciMLMessage("The interval is not an enclosing interval, opposite signs at the \
3737
boundaries are required.",
38-
nonlinear_verbose[], :non_enclosing_interval, :error_control)
38+
verbose, :non_enclosing_interval, :error_control)
3939
return SciMLBase.build_solution(
4040
prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right
4141
)

lib/BracketingNonlinearSolve/src/falsi.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function SciMLBase.__solve(
3434
if sign(fl) == sign(fr)
3535
@SciMLMessage("The interval is not an enclosing interval, opposite signs at the \
3636
boundaries are required.",
37-
nonlinear_verbose[], :non_enclosing_interval, :error_control)
37+
verbose, :non_enclosing_interval, :error_control)
3838
return SciMLBase.build_solution(
3939
prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right
4040
)

lib/BracketingNonlinearSolve/src/itp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function SciMLBase.__solve(
8585
if sign(fl) == sign(fr)
8686
@SciMLMessage("The interval is not an enclosing interval, opposite signs at the \
8787
boundaries are required.",
88-
nonlinear_verbose[], :non_enclosing_interval, :error_control)
88+
verbose, :non_enclosing_interval, :error_control)
8989
return SciMLBase.build_solution(
9090
prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right
9191
)

lib/BracketingNonlinearSolve/src/ridder.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function SciMLBase.__solve(
3434
if sign(fl) == sign(fr)
3535
@SciMLMessage("The interval is not an enclosing interval, opposite signs at the \
3636
boundaries are required.",
37-
nonlinear_verbose[], :non_enclosing_interval, :error_control)
37+
verbose, :non_enclosing_interval, :error_control)
3838
return SciMLBase.build_solution(
3939
prob, alg, left, fl; retcode = ReturnCode.InitialFailure, left, right
4040
)

lib/NonlinearSolveBase/ext/NonlinearSolveBaseLinearSolveExt.jl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using ArrayInterface: ArrayInterface
55
using CommonSolve: CommonSolve, init, solve!
66
using LinearSolve: LinearSolve, QRFactorization, SciMLLinearSolveAlgorithm
77
using SciMLBase: ReturnCode, LinearProblem, LinearAliasSpecifier
8+
using SciMLVerbosity: @SciMLMessage
89

910
using LinearAlgebra: ColumnNorm
1011

@@ -28,10 +29,8 @@ function (cache::LinearSolveJLCache)(;
2829
is_gpuarray = ArrayInterface.device(cache.lincache.A) isa ArrayInterface.GPU
2930
if !(cache.linsolve isa QRFactorization{ColumnNorm}) && !is_gpuarray &&
3031
!structured_mat
31-
if verbose
32-
@warn "Potential Rank Deficient Matrix Detected. Attempting to solve using \
33-
Pivoted QR Factorization."
34-
end
32+
@SciMLMessage("Potential Rank Deficient Matrix Detected. Attempting to solve using \
33+
Pivoted QR Factorization.", cache.verbose, :default_lu_fallback, :error_control)
3534
@assert (A !== nothing)&&(b !== nothing) "This case is not yet supported. \
3635
Please open an issue at \
3736
https://github.com/SciML/NonlinearSolve.jl"
@@ -53,14 +52,12 @@ function (cache::LinearSolveJLCache)(;
5352
return LinearSolveResult(; linres.u, success = false)
5453
return LinearSolveResult(; linres.u)
5554
elseif !(cache.linsolve isa QRFactorization{ColumnNorm})
56-
if verbose
57-
if structured_mat || is_gpuarray
58-
mat_desc = structured_mat ? "Structured" : "GPU"
59-
@warn "Potential Rank Deficient Matrix Detected. But Matrix is \
55+
if structured_mat || is_gpuarray
56+
mat_desc = structured_mat ? "Structured" : "GPU"
57+
@SciMLMessage("Potential Rank Deficient Matrix Detected. But Matrix is \
6058
$(mat_desc). Currently, we don't attempt to solve Rank Deficient \
6159
$(mat_desc) Matrices. Please open an issue at \
62-
https://github.com/SciML/NonlinearSolve.jl"
63-
end
60+
https://github.com/SciML/NonlinearSolve.jl", cache.verbose, :lu_fallback, :error_control)
6461
end
6562
end
6663
return LinearSolveResult(; linres.u, success = false)

lib/NonlinearSolveBase/src/abstract_types.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ the cache:
280280
- `maxtime`: the maximum time limit for the solver. (Optional)
281281
- `timer`: the timer for the solver. (Optional)
282282
- `total_time`: the total time taken by the solver. (Optional)
283+
- `verbose`: a verbosity object that contains options determining what log messages are emitted.
283284
"""
284285
abstract type AbstractNonlinearSolveCache <: AbstractNonlinearSolveBaseAPI end
285286

lib/NonlinearSolveBase/src/descent/newton.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ function InternalAPI.init(
3939
if Utils.unwrap_val(pre_inverted)
4040
lincache = nothing
4141
else
42+
if haskey(kwargs, :verbose)
43+
linsolve_kwargs = merge((verbose = kwargs[:verbose].linear_verbosity,), linsolve_kwargs)
44+
end
45+
4246
lincache = construct_linear_solver(
4347
alg, alg.linsolve, J, Utils.safe_vec(fu), Utils.safe_vec(u);
4448
stats, abstol, reltol, linsolve_kwargs...
@@ -72,6 +76,11 @@ function InternalAPI.init(
7276
A, b = J, Utils.safe_vec(fu)
7377
end
7478

79+
if haskey(kwargs, :verbose)
80+
linsolve_kwargs = merge(
81+
(verbose = kwargs[:verbose].linear_verbosity,), linsolve_kwargs)
82+
end
83+
7584
lincache = construct_linear_solver(
7685
alg, alg.linsolve, A, b, Utils.safe_vec(u);
7786
stats, abstol, reltol, linsolve_kwargs...

lib/NonlinearSolveBase/src/descent/steepest.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ function InternalAPI.init(
3737
@bb δu_ = similar(u)
3838
end
3939
if Utils.unwrap_val(pre_inverted)
40+
41+
if haskey(kwargs, :verbose)
42+
linsolve_kwargs = merge(
43+
(verbose = kwargs[:verbose].linear_verbosity,), linsolve_kwargs)
44+
end
45+
4046
lincache = construct_linear_solver(
4147
alg, alg.linsolve, transpose(J), Utils.safe_vec(fu), Utils.safe_vec(u);
4248
stats, abstol, reltol, linsolve_kwargs...

lib/NonlinearSolveBase/src/jacobian.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ function construct_concrete_adtype(f::NonlinearFunction, ad::AbstractADType)
180180
if f.sparsity === nothing
181181
if f.jac_prototype === nothing
182182
if SciMLBase.has_colorvec(f)
183-
@SciMLMessage("`colorvec` is provided but `sparsity` and `jac_prototype` is not \
184-
specified. `colorvec` will be ignored.", nonlinear_verbose[], :colorvec_no_prototype, :performance )
183+
@warn "`colorvec` is provided but `sparsity` and `jac_prototype` is not \
184+
specified. `colorvec` will be ignored."
185185
end
186186
return ad # No sparse AD
187187
else
188188
if !sparse_or_structured_prototype(f.jac_prototype)
189189
if SciMLBase.has_colorvec(f)
190-
@SciMLMessage("`colorvec` is provided but `jac_prototype` is not a sparse \
191-
or structured matrix. `colorvec` will be ignored.", nonlinear_verbose[], :colorvec_non_sparse, :performance)
190+
@warn "`colorvec` is provided but `jac_prototype` is not a sparse \
191+
or structured matrix. `colorvec` will be ignored."
192192
end
193193
return ad
194194
end

0 commit comments

Comments
 (0)