Skip to content

Commit 730059c

Browse files
committed
format
1 parent 188b496 commit 730059c

File tree

30 files changed

+176
-297
lines changed

30 files changed

+176
-297
lines changed

ext/BoundaryValueDiffEqODEInterfaceExt.jl

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,13 @@ function SciMLBase.__solve(prob::BVProblem, alg::BVPM2; dt = 0.0, reltol = 1e-3,
6161
@closure (t, u, du) -> du .= vec(prob.f(reshape(u, u0_size), prob.p, t))
6262
end
6363
bvp2m_bc = if SciMLBase.isinplace(prob)
64-
@closure (ya,
65-
yb,
66-
bca,
67-
bcb) -> begin
64+
@closure (ya, yb, bca, bcb) -> begin
6865
prob.f.bc[1](reshape(bca, left_bc_size), reshape(ya, u0_size), prob.p)
6966
prob.f.bc[2](reshape(bcb, right_bc_size), reshape(yb, u0_size), prob.p)
7067
return nothing
7168
end
7269
else
73-
@closure (
74-
ya, yb, bca, bcb) -> begin
70+
@closure (ya, yb, bca, bcb) -> begin
7571
bca .= vec(prob.f.bc[1](reshape(ya, u0_size), prob.p))
7672
bcb .= vec(prob.f.bc[2](reshape(yb, u0_size), prob.p))
7773
return nothing
@@ -144,18 +140,15 @@ function SciMLBase.__solve(prob::BVProblem, alg::BVPSOL; maxiters = 1000,
144140
end
145141

146142
bvpsol_bc = if SciMLBase.isinplace(prob)
147-
@closure (ya, yb,
148-
r) -> begin
143+
@closure (ya, yb, r) -> begin
149144
left_bc = reshape(@view(r[1:no_left_bc]), left_bc_size)
150145
right_bc = reshape(@view(r[(no_left_bc + 1):end]), right_bc_size)
151146
prob.f.bc[1](left_bc, reshape(ya, u0_size), prob.p)
152147
prob.f.bc[2](right_bc, reshape(yb, u0_size), prob.p)
153148
return nothing
154149
end
155150
else
156-
@closure (ya,
157-
yb,
158-
r) -> begin
151+
@closure (ya, yb, r) -> begin
159152
r[1:no_left_bc] .= vec(prob.f.bc[1](reshape(ya, u0_size), prob.p))
160153
r[(no_left_bc + 1):end] .= vec(prob.f.bc[2](reshape(yb, u0_size), prob.p))
161154
return nothing

lib/BoundaryValueDiffEqAscher/src/adaptivity.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,15 @@ function error_estimate!(cache::AscherCache)
188188
# in valstr in case they prove to be needed later for an error estimate.
189189
x = mesh[i] + (mesh_dt[i]) * 2.0 / 3.0
190190
@views approx(cache, x, valstr[i][3])
191-
error[i] .= wgterr .* abs.(valstr[i][3] .-
191+
error[i] .= wgterr .*
192+
abs.(valstr[i][3] .-
192193
(isodd(i) ? valstr[Int((i + 1) / 2)][2] : valstr[Int(i / 2)][4]))
193194

194195
x = mesh[i] + (mesh_dt[i]) / 3.0
195196
@views approx(cache, x, valstr[i][2])
196197
error[i] .= error[i] .+
197-
wgterr .* abs.(valstr[i][2] .-
198+
wgterr .*
199+
abs.(valstr[i][2] .-
198200
(isodd(i) ? valstr[Int((i + 1) / 2)][1] : valstr[Int(i / 2)][3]))
199201
end
200202
return maximum(reduce(hcat, error), dims = 2)

lib/BoundaryValueDiffEqAscher/src/ascher.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ function SciMLBase.__init(prob::BVProblem, alg::AbstractAscher; dt = 0.0,
100100

101101
iip = isinplace(prob)
102102

103-
f,
104-
bc = if prob.u0 isa AbstractVector
103+
f, bc = if prob.u0 isa AbstractVector
105104
prob.f, prob.f.bc
106105
elseif iip
107106
vecf! = @closure (du, u, p, t) -> __vec_f!(du, u, p, t, prob.f, size(u0))
@@ -161,9 +160,8 @@ function SciMLBase.solve!(cache::AscherCache{iip, T}) where {iip, T}
161160

162161
if adaptive
163162
while SciMLBase.successful_retcode(info) && norm(error_norm) > abstol
164-
z, y,
165-
info,
166-
error_norm = __perform_ascher_iteration(cache, abstol, adaptive; kwargs...)
163+
z, y, info, error_norm = __perform_ascher_iteration(
164+
cache, abstol, adaptive; kwargs...)
167165
end
168166
end
169167
u = [vcat(zᵢ, yᵢ) for (zᵢ, yᵢ) in zip(z, y)]
@@ -340,11 +338,10 @@ function __construct_nlproblem(cache::AscherCache{iip, T}) where {iip, T}
340338
end
341339

342340
jac = if iip
343-
@closure (J, u,
344-
p) -> __ascher_mpoint_jacobian!(J, u, diffmode, jac_cache, loss, lz, cache.p)
341+
@closure (J, u, p) -> __ascher_mpoint_jacobian!(
342+
J, u, diffmode, jac_cache, loss, lz, cache.p)
345343
else
346-
@closure (u,
347-
p) -> __ascher_mpoint_jacobian(
344+
@closure (u, p) -> __ascher_mpoint_jacobian(
348345
jac_prototype, u, diffmode, jac_cache, loss, cache.p)
349346
end
350347

lib/BoundaryValueDiffEqAscher/src/collocation.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
function Φ!(cache::AscherCache{iip, T}, z, res, pt::StandardBVProblem) where {iip, T}
2-
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval,
3-
yval, gval, delz, dmz, deldmz, g, w, v, ipvtg, ipvtw, TU) = cache
2+
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval, yval, gval, delz, dmz, deldmz, g, w, v, ipvtg, ipvtw, TU) = cache
43
(; acol, rho) = TU
54
ncy = ncomp + ny
65
n = length(mesh) - 1
@@ -157,8 +156,7 @@ function Φ!(cache::AscherCache{iip, T}, z, res, pt::StandardBVProblem) where {i
157156
end
158157

159158
function Φ!(cache::AscherCache{iip, T}, z, res, pt::TwoPointBVProblem) where {iip, T}
160-
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, bcresid_prototype, residual,
161-
zval, yval, gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
159+
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, bcresid_prototype, residual, zval, yval, gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
162160
(; acol, rho) = TU
163161
ncy = ncomp + ny
164162
n = length(mesh) - 1
@@ -321,8 +319,7 @@ end
321319
@inline __get_value(z) = isa(z, ForwardDiff.Dual) ? z.value : z
322320

323321
function Φ(cache::AscherCache{iip, T}, z, pt::StandardBVProblem) where {iip, T}
324-
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval, yval,
325-
gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
322+
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval, yval, gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
326323
(; acol, rho) = TU
327324
ncy = ncomp + ny
328325
n = length(mesh) - 1
@@ -479,8 +476,7 @@ function Φ(cache::AscherCache{iip, T}, z, pt::StandardBVProblem) where {iip, T}
479476
end
480477

481478
function Φ(cache::AscherCache{iip, T}, z, pt::TwoPointBVProblem) where {iip, T}
482-
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval, yval,
483-
gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
479+
(; f, mesh, mesh_dt, ncomp, ny, bc, k, p, zeta, residual, zval, yval, gval, delz, dmz, deldmz, g, w, v, dmzo, ipvtg, ipvtw, TU) = cache
484480
(; acol, rho) = TU
485481
ncy = ncomp + ny
486482
n = length(mesh) - 1

lib/BoundaryValueDiffEqCore/src/types.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
end
77

88
@inline __materialize_jacobian_algorithm(_, alg::BVPJacobianAlgorithm) = alg
9-
@inline __materialize_jacobian_algorithm(
10-
_, alg::ADTypes.AbstractADType) = BVPJacobianAlgorithm(alg)
9+
@inline __materialize_jacobian_algorithm(_, alg::ADTypes.AbstractADType) = BVPJacobianAlgorithm(alg)
1110
@inline __materialize_jacobian_algorithm(::Nothing, ::Nothing) = BVPJacobianAlgorithm()
1211
@inline function __materialize_jacobian_algorithm(nlsolve::N, ::Nothing) where {N}
1312
ad = hasfield(N, :jacobian_ad) ? nlsolve.jacobian_ad : missing

lib/BoundaryValueDiffEqFIRK/src/BoundaryValueDiffEqFIRK.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ include("sparse_jacobians.jl")
9696

9797
@compile_workload begin
9898
@sync for prob in probs, alg in algs
99-
10099
Threads.@spawn solve(prob, alg; dt = 0.2)
101100
end
102101
end
@@ -109,7 +108,6 @@ include("sparse_jacobians.jl")
109108

110109
@compile_workload begin
111110
@sync for prob in probs, alg in algs
112-
113111
Threads.@spawn solve(prob, alg; dt = 0.2)
114112
end
115113
end
@@ -122,7 +120,6 @@ include("sparse_jacobians.jl")
122120

123121
@compile_workload begin
124122
@sync for prob in probs, alg in algs
125-
126123
Threads.@spawn solve(prob, alg; dt = 0.2)
127124
end
128125
end
@@ -135,7 +132,6 @@ include("sparse_jacobians.jl")
135132

136133
@compile_workload begin
137134
@sync for prob in probs, alg in algs
138-
139135
Threads.@spawn solve(prob, alg; dt = 0.2)
140136
end
141137
end
@@ -194,7 +190,6 @@ include("sparse_jacobians.jl")
194190

195191
@compile_workload begin
196192
@sync for prob in probs, alg in algs
197-
198193
Threads.@spawn solve(prob, alg; dt = 0.2, abstol = 1e-2)
199194
end
200195
end
@@ -211,7 +206,6 @@ include("sparse_jacobians.jl")
211206

212207
@compile_workload begin
213208
@sync for prob in probs, alg in algs
214-
215209
Threads.@spawn solve(prob, alg; dt = 0.2, abstol = 1e-2)
216210
end
217211
end
@@ -228,7 +222,6 @@ include("sparse_jacobians.jl")
228222

229223
@compile_workload begin
230224
@sync for prob in probs, alg in algs
231-
232225
Threads.@spawn solve(prob, alg; dt = 0.2, abstol = 1e-2)
233226
end
234227
end
@@ -245,7 +238,6 @@ include("sparse_jacobians.jl")
245238

246239
@compile_workload begin
247240
@sync for prob in probs, alg in algs
248-
249241
Threads.@spawn solve(prob, alg; dt = 0.2, abstol = 1e-2)
250242
end
251243
end
@@ -262,7 +254,6 @@ include("sparse_jacobians.jl")
262254

263255
@compile_workload begin
264256
@sync for prob in probs, alg in algs
265-
266257
Threads.@spawn solve(prob, alg; dt = 0.2, abstol = 1e-2)
267258
end
268259
end

lib/BoundaryValueDiffEqFIRK/src/adaptivity.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ function s_constraints(M, h)
134134
row_start = (i - 1) * M + 1
135135
for k in 0:(M - 1)
136136
for j in 1:6
137-
A[row_start + k,
138-
j + k * 6] = j == 1.0 ? 0.0 : (j - 1) * t[i + k * 6]^(j - 2)
137+
A[row_start + k, j + k * 6] = j == 1.0 ? 0.0 :
138+
(j - 1) * t[i + k * 6]^(j - 2)
139139
end
140140
end
141141
end

lib/BoundaryValueDiffEqFIRK/src/algorithms.jl

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,8 @@ for stage in (1, 2, 3, 5, 7)
9595
defect_threshold::T = 0.1
9696
max_num_subintervals::Int = 3000
9797
end
98-
$(alg)(nlsolve::N,
99-
jac_alg::J;
100-
nested = false,
101-
nested_nlsolve_kwargs::NamedTuple = (;),
102-
defect_threshold::T = 0.1,
103-
max_num_subintervals::Int = 3000) where {N,
104-
J,
105-
T} = $(alg){N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
98+
$(alg)(nlsolve::N, jac_alg::J; nested = false, nested_nlsolve_kwargs::NamedTuple = (;), defect_threshold::T = 0.1, max_num_subintervals::Int = 3000) where {N, J, T} = $(alg){
99+
N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
106100
defect_threshold, max_num_subintervals)
107101
end
108102
end
@@ -200,14 +194,8 @@ for stage in (2, 3, 4, 5)
200194
defect_threshold::T = 0.1
201195
max_num_subintervals::Int = 3000
202196
end
203-
$(alg)(nlsolve::N,
204-
jac_alg::J;
205-
nested = false,
206-
nested_nlsolve_kwargs::NamedTuple = (;),
207-
defect_threshold::T = 0.1,
208-
max_num_subintervals::Int = 3000) where {N,
209-
J,
210-
T} = $(alg){N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
197+
$(alg)(nlsolve::N, jac_alg::J; nested = false, nested_nlsolve_kwargs::NamedTuple = (;), defect_threshold::T = 0.1, max_num_subintervals::Int = 3000) where {N, J, T} = $(alg){
198+
N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
211199
defect_threshold, max_num_subintervals)
212200
end
213201
end
@@ -307,14 +295,8 @@ for stage in (2, 3, 4, 5)
307295
defect_threshold::T = 0.1
308296
max_num_subintervals::Int = 3000
309297
end
310-
$(alg)(nlsolve::N,
311-
jac_alg::J;
312-
nested = false,
313-
nested_nlsolve_kwargs::NamedTuple = (;),
314-
defect_threshold::T = 0.1,
315-
max_num_subintervals::Int = 3000) where {N,
316-
J,
317-
T} = $(alg){N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
298+
$(alg)(nlsolve::N, jac_alg::J; nested = false, nested_nlsolve_kwargs::NamedTuple = (;), defect_threshold::T = 0.1, max_num_subintervals::Int = 3000) where {N, J, T} = $(alg){
299+
N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
318300
defect_threshold, max_num_subintervals)
319301
end
320302
end
@@ -414,14 +396,8 @@ for stage in (2, 3, 4, 5)
414396
defect_threshold::T = 0.1
415397
max_num_subintervals::Int = 3000
416398
end
417-
$(alg)(nlsolve::N,
418-
jac_alg::J;
419-
nested = false,
420-
nested_nlsolve_kwargs::NamedTuple = (;),
421-
defect_threshold::T = 0.1,
422-
max_num_subintervals::Int = 3000) where {N,
423-
J,
424-
T} = $(alg){N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
399+
$(alg)(nlsolve::N, jac_alg::J; nested = false, nested_nlsolve_kwargs::NamedTuple = (;), defect_threshold::T = 0.1, max_num_subintervals::Int = 3000) where {N, J, T} = $(alg){
400+
N, J, T}(nlsolve, jac_alg, nested, nested_nlsolve_kwargs,
425401
defect_threshold, max_num_subintervals)
426402
end
427403
end

0 commit comments

Comments
 (0)