Skip to content

Commit 0ca92b3

Browse files
format
1 parent dc4ec92 commit 0ca92b3

File tree

49 files changed

+221
-178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+221
-178
lines changed

lib/OrdinaryDiffEqAdamsBashforthMoulton/src/adams_bashforth_moulton_caches.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
abstract type ABMMutableCache <: OrdinaryDiffEqMutableCache end
22
abstract type ABMVariableCoefficientMutableCache <: OrdinaryDiffEqMutableCache end
3-
get_fsalfirstlast(cache::ABMMutableCache,u) = (cache.fsalfirst, cache.k)
4-
get_fsalfirstlast(cache::ABMVariableCoefficientMutableCache,u) = (cache.fsalfirst, cache.k4)
3+
get_fsalfirstlast(cache::ABMMutableCache, u) = (cache.fsalfirst, cache.k)
4+
function get_fsalfirstlast(cache::ABMVariableCoefficientMutableCache, u)
5+
(cache.fsalfirst, cache.k4)
6+
end
57
@cache mutable struct AB3Cache{uType, rateType} <: ABMMutableCache
68
u::uType
79
uprev::uType

lib/OrdinaryDiffEqBDF/src/algorithms.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ end
150150
function QNDF1(; chunk_size = Val{0}(), autodiff = Val{true}(), standardtag = Val{true}(),
151151
concrete_jac = nothing, diff_type = Val{:forward},
152152
linsolve = nothing, precs = DEFAULT_PRECS, nlsolve = NLNewton(),
153-
extrapolant = :linear, kappa = -37//200,
153+
extrapolant = :linear, kappa = -37 // 200,
154154
controller = :Standard, step_limiter! = trivial_limiter!)
155155
QNDF1{
156156
_unwrap_val(chunk_size), _unwrap_val(autodiff), typeof(linsolve), typeof(nlsolve),
@@ -233,7 +233,8 @@ function QNDF(; max_order::Val{MO} = Val{5}(), chunk_size = Val{0}(),
233233
diff_type = Val{:forward},
234234
linsolve = nothing, precs = DEFAULT_PRECS, nlsolve = NLNewton(), κ = nothing,
235235
tol = nothing,
236-
extrapolant = :linear, kappa = (-37//200, -1//9, -823//10000, -83//2000, 0//1),
236+
extrapolant = :linear, kappa = (
237+
-37 // 200, -1 // 9, -823 // 10000, -83 // 2000, 0 // 1),
237238
controller = :Standard, step_limiter! = trivial_limiter!) where {MO}
238239
QNDF{MO, _unwrap_val(chunk_size), _unwrap_val(autodiff), typeof(linsolve),
239240
typeof(nlsolve), typeof(precs), diff_type, _unwrap_val(standardtag),

lib/OrdinaryDiffEqBDF/src/bdf_caches.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
abstract type BDFMutableCache <: OrdinaryDiffEqMutableCache end
2-
get_fsalfirstlast(cache::BDFMutableCache,u) = (cache.fsalfirst, du_alias_or_new(cache.nlsolver, cache.fsalfirst))
2+
function get_fsalfirstlast(cache::BDFMutableCache, u)
3+
(cache.fsalfirst, du_alias_or_new(cache.nlsolver, cache.fsalfirst))
4+
end
35

46
@cache mutable struct ABDF2ConstantCache{N, dtType, rate_prototype} <:
57
OrdinaryDiffEqConstantCache

lib/OrdinaryDiffEqBDF/src/controllers.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ function choose_order!(alg::FBDF, integrator,
206206
Val(max_order))
207207
local terk_tmp
208208
if u isa Number
209-
terk_tmp = fd_weights[k - 2, 1]*u
209+
terk_tmp = fd_weights[k - 2, 1] * u
210210
for i in 2:(k - 2)
211211
terk_tmp += fd_weights[i, k - 2] * u_history[i - 1]
212212
end
@@ -215,7 +215,7 @@ function choose_order!(alg::FBDF, integrator,
215215
# we need terk_tmp to be mutable.
216216
# so it can be updated
217217
terk_tmp = similar(u)
218-
@.. terk_tmp = fd_weights[k - 2, 1]*_vec(u)
218+
@.. terk_tmp = fd_weights[k - 2, 1] * _vec(u)
219219
for i in 2:(k - 2)
220220
@.. @views terk_tmp += fd_weights[i, k - 2] * u_history[:, i - 1]
221221
end

lib/OrdinaryDiffEqBDF/src/dae_caches.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
abstract type DAEBDFMutableCache <: OrdinaryDiffEqMutableCache end
2-
get_fsalfirstlast(cache::DAEBDFMutableCache,u) = (cache.fsalfirst, du_alias_or_new(cache.nlsolver, cache.fsalfirst))
2+
function get_fsalfirstlast(cache::DAEBDFMutableCache, u)
3+
(cache.fsalfirst, du_alias_or_new(cache.nlsolver, cache.fsalfirst))
4+
end
35

46
@cache mutable struct DImplicitEulerCache{uType, rateType, uNoUnitsType, N} <:
57
DAEBDFMutableCache
@@ -13,7 +15,7 @@ get_fsalfirstlast(cache::DAEBDFMutableCache,u) = (cache.fsalfirst, du_alias_or_n
1315
end
1416

1517
# Not FSAL
16-
get_fsalfirstlast(cache::DImplicitEulerCache,u) = (u,u)
18+
get_fsalfirstlast(cache::DImplicitEulerCache, u) = (u, u)
1719

1820
mutable struct DImplicitEulerConstantCache{N} <: OrdinaryDiffEqConstantCache
1921
nlsolver::N

lib/OrdinaryDiffEqBDF/src/dae_perform_step.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ end
160160
end
161161

162162
function initialize!(integrator, cache::DABDF2Cache)
163-
164-
165163
integrator.kshortsize = 2
166164
@unpack k₁, k₂ = cache.eulercache
167165
resize!(integrator.k, integrator.kshortsize)

lib/OrdinaryDiffEqCore/ext/OrdinaryDiffEqCoreEnzymeCoreExt.jl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ module OrdinaryDiffEqCoreEnzymeCoreExt
22
import OrdinaryDiffEqCore, EnzymeCore
33

44
EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.increment_nf!), args...) = true
5-
EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.fixed_t_for_floatingpoint_error!), args...) = true
6-
EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.increment_accept!), args...) = true
7-
EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.increment_reject!), args...) = true
8-
EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.increment_nf_perform_step!), args...) = true
5+
function EnzymeCore.EnzymeRules.inactive(
6+
::typeof(OrdinaryDiffEqCore.fixed_t_for_floatingpoint_error!), args...)
7+
true
8+
end
9+
function EnzymeCore.EnzymeRules.inactive(
10+
::typeof(OrdinaryDiffEqCore.increment_accept!), args...)
11+
true
12+
end
13+
function EnzymeCore.EnzymeRules.inactive(
14+
::typeof(OrdinaryDiffEqCore.increment_reject!), args...)
15+
true
16+
end
17+
function EnzymeCore.EnzymeRules.inactive(
18+
::typeof(OrdinaryDiffEqCore.increment_nf_perform_step!), args...)
19+
true
20+
end
921
EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.check_error!), args...) = true
1022
EnzymeCore.EnzymeRules.inactive(::typeof(OrdinaryDiffEqCore.log_step!), args...) = true
1123

lib/OrdinaryDiffEqCore/src/OrdinaryDiffEqCore.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ using SimpleUnPack, RecursiveArrayTools, DataStructures, ArrayInterface
4141
import TruncatedStacktraces
4242

4343
import StaticArraysCore: SArray, MVector, SVector, StaticArray, MMatrix,
44-
StaticMatrix
44+
StaticMatrix
4545

4646
# Integrator Interface
4747
import DiffEqBase: resize!, deleteat!, addat!, full_cache, user_cache, u_cache, du_cache,
@@ -54,7 +54,6 @@ import DiffEqBase: resize!, deleteat!, addat!, full_cache, user_cache, u_cache,
5454
isautodifferentiable,
5555
get_tstops, get_tstops_array, get_tstops_max
5656

57-
5857
using DiffEqBase: check_error!, @def, _vec, _reshape
5958

6059
using FastBroadcast: @.., True, False

lib/OrdinaryDiffEqCore/src/caches/basic_caches.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ struct ODEEmptyCache <: OrdinaryDiffEqConstantCache end
55
struct ODEChunkCache{CS} <: OrdinaryDiffEqConstantCache end
66

77
# Don't worry about the potential alloc on a constant cache
8-
get_fsalfirstlast(cache::OrdinaryDiffEqConstantCache,u) = (zero(u), zero(u))
8+
get_fsalfirstlast(cache::OrdinaryDiffEqConstantCache, u) = (zero(u), zero(u))
99

1010
mutable struct CompositeCache{T, F} <: OrdinaryDiffEqCache
1111
caches::T
1212
choice_function::F
1313
current::Int
1414
end
1515

16-
get_fsalfirstlast(cache::CompositeCache,u) = get_fsalfirstlast(cache.caches[1],u)
16+
get_fsalfirstlast(cache::CompositeCache, u) = get_fsalfirstlast(cache.caches[1], u)
1717

1818
mutable struct DefaultCache{T1, T2, T3, T4, T5, T6, A, F, uType} <: OrdinaryDiffEqCache
1919
args::A
@@ -28,12 +28,13 @@ mutable struct DefaultCache{T1, T2, T3, T4, T5, T6, A, F, uType} <: OrdinaryDiff
2828
cache6::T6
2929
function DefaultCache{T1, T2, T3, T4, T5, T6, F, uType}(
3030
args, choice_function, current, u) where {T1, T2, T3, T4, T5, T6, F, uType}
31-
new{T1, T2, T3, T4, T5, T6, typeof(args), F, uType}(args, choice_function, current, u)
31+
new{T1, T2, T3, T4, T5, T6, typeof(args), F, uType}(
32+
args, choice_function, current, u)
3233
end
3334
end
3435

35-
function get_fsalfirstlast(cache::DefaultCache,u)
36-
(cache.u,cache.u) # will be overwritten by the cache choice
36+
function get_fsalfirstlast(cache::DefaultCache, u)
37+
(cache.u, cache.u) # will be overwritten by the cache choice
3738
end
3839

3940
function alg_cache(alg::CompositeAlgorithm, u, rate_prototype, ::Type{uEltypeNoUnits},

lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ function _loopfooter!(integrator)
255255
end
256256
if integrator.opts.progress && integrator.iter % integrator.opts.progress_steps == 0
257257
log_step!(integrator.opts.progress_name, integrator.opts.progress_id,
258-
integrator.opts.progress_message, integrator.dt, integrator.u,
259-
integrator.p, integrator.t, integrator.sol.prob.tspan)
258+
integrator.opts.progress_message, integrator.dt, integrator.u,
259+
integrator.p, integrator.t, integrator.sol.prob.tspan)
260260
end
261261

262262
# Take value because if t is dual then maxeig can be dual
@@ -280,18 +280,18 @@ end
280280

281281
function log_step!(progress_name, progress_id, progress_message, dt, u, p, t, tspan)
282282
t1, t2 = tspan
283-
@logmsg(LogLevel(-1),progress_name,
284-
_id=progress_id,
285-
message=progress_message(dt, u, p, t),
286-
progress=(t - t1) / (t2 - t1))
283+
@logmsg(LogLevel(-1), progress_name,
284+
_id=progress_id,
285+
message=progress_message(dt, u, p, t),
286+
progress=(t - t1) / (t2 - t1))
287287
end
288288

289289
function fixed_t_for_floatingpoint_error!(integrator, ttmp)
290290
if has_tstop(integrator)
291291
tstop = integrator.tdir * first_tstop(integrator)
292292
if abs(ttmp - tstop) <
293-
100eps(float(max(integrator.t, tstop) / oneunit(integrator.t))) *
294-
oneunit(integrator.t)
293+
100eps(float(max(integrator.t, tstop) / oneunit(integrator.t))) *
294+
oneunit(integrator.t)
295295
tstop
296296
else
297297
ttmp

0 commit comments

Comments
 (0)