Skip to content

Commit b26e81a

Browse files
Update to OrdinaryDiffEqOperatorSplitting v0.2.1 (#226)
* Update to OrdinaryDiffEqOperatorSplitting v0.2 * Refactor tests and test more stuff which failed before * Update OrdinaryDiffEqOperatorSplitting dep * Fix RTC * Fix tests shadowing the time integrators dt * Fix logging info * Use reinit from Ferrite
1 parent a18100c commit b26e81a

7 files changed

Lines changed: 131 additions & 102 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Logging = "1.10"
5555
ModelingToolkit = "9"
5656
OrdinaryDiffEqCore = "1"
5757
OrdinaryDiffEqLowOrderRK = "1.2.0"
58-
OrdinaryDiffEqOperatorSplitting = "0.1"
58+
OrdinaryDiffEqOperatorSplitting = "0.2.1"
5959
Preferences = "1"
6060
SciMLBase = "2"
6161
UnPack = "1"

src/solver/logging.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ end
1717

1818
function integration_step_monitor(integrator::SciMLBase.DEIntegrator, progress_monitor::DefaultProgressMonitor)
1919
# (; id) = progress_monitor
20-
(; t, dt, iter) = integrator
20+
(; tprev, t, dt, iter) = integrator
2121
# push!(msgs, id => "$id: integrating on [$t, $(t+dt)] with Δt=$dt.")
22-
@logmsg LogLevel(-100) "Integrating on [$t, $(t+dt)]." iter=iter Δt=dt _group=:timeintegration
22+
@logmsg LogLevel(-100) "Integrating on [$tprev, $t]." iter=iter Δt=dt _group=:timeintegration
2323
end
2424

2525
function integration_finalize_monitor(integrator, progress_monitor::DefaultProgressMonitor)
2626
# (; id) = progress_monitor
27-
(; t, iter) = integrator
27+
(; tprev, t, iter) = integrator
2828
# push!(msgs, id => "$id: done at $t.")
29-
@info "Finished integration at t=$t." iter=iter _group=:timeintegration
29+
@info "Finished integration at t=$t (tprev=$tprev)." iter=iter _group=:timeintegration
3030
end
3131

3232
#

src/solver/time/rtc.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,19 @@ end
7373
@unpack σ_s, σ_c, Δt_bounds = alg
7474

7575
if isinf(σ_s)
76-
integrator._dt = R > σ_c ? Δt_bounds[1] : Δt_bounds[2]
76+
integrator.dt = R > σ_c ? Δt_bounds[1] : Δt_bounds[2]
7777
else
78-
integrator._dt = (1 - 1/(1+exp((σ_c - R)*σ_s)))*(Δt_bounds[2] - Δt_bounds[1]) + Δt_bounds[1]
78+
integrator.dt = (1 - 1/(1+exp((σ_c - R)*σ_s)))*(Δt_bounds[2] - Δt_bounds[1]) + Δt_bounds[1]
7979
end
8080
return nothing
8181
end
8282

8383
@inline function OS.step_reject_controller!(integrator::OS.OperatorSplittingIntegrator, alg::ReactionTangentController, q)
84+
if integrator.dt Δt_bounds[1] # Check for "≤" to also handle the boundary cases
85+
error("RTC cannot recover from step rejection below Δt min") # Force failure
86+
else
87+
integrator.dt = Δt_bounds[1]
88+
end
8489
return nothing # Do nothing
8590
end
8691

test/test_coefficients.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
@testset "ConstantCoefficient($val" for val [1.0, one(Tensor{2,2})]
1414
cc = ConstantCoefficient(val)
1515
coeff_cache = Thunderbolt.setup_coefficient_cache(cc, qr, sdh)
16-
reinit!(cell_cache, 1)
16+
Ferrite.reinit!(cell_cache, 1)
1717
@test_opt evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0)
1818
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) val
1919
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 1.0) val
20-
reinit!(cell_cache, 2)
20+
Ferrite.reinit!(cell_cache, 2)
2121
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) val
2222
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 1.0) val
2323

@@ -31,12 +31,12 @@
3131
data_scalar[2,1] = -1.0
3232
fcs = FieldCoefficient(data_scalar, ip_collection)
3333
coeff_cache = Thunderbolt.setup_coefficient_cache(fcs, qr, sdh)
34-
reinit!(cell_cache, 1)
34+
Ferrite.reinit!(cell_cache, 1)
3535
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) 0.0
3636
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 1.0) 0.0
3737
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 0.0) -0.1
3838
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 1.0) -0.1
39-
reinit!(cell_cache, 2)
39+
Ferrite.reinit!(cell_cache, 2)
4040
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) -0.5
4141
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 1.0) -0.5
4242
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 0.0) (0.1+1.0)/2.0-1.0
@@ -48,10 +48,10 @@
4848
data_vector[2,1] = Vec((-1.0,-0.0))
4949
fcv = FieldCoefficient(data_vector, ip_collection^2)
5050
coeff_cache = Thunderbolt.setup_coefficient_cache(fcv, qr, sdh)
51-
reinit!(cell_cache, 1)
51+
Ferrite.reinit!(cell_cache, 1)
5252
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) Vec((0.0,0.0))
5353
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 1.0) Vec((-0.1,0.0))
54-
reinit!(cell_cache, 2)
54+
Ferrite.reinit!(cell_cache, 2)
5555
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) Vec((0.0,-0.5))
5656
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 1.0) Vec((0.0,(0.1+1.0)/2.0-1.0))
5757

@@ -61,12 +61,12 @@
6161
@testset "Cartesian Coordinate System" begin
6262
ccsc = CartesianCoordinateSystem(grid)
6363
coeff_cache = Thunderbolt.setup_coefficient_cache(ccsc, qr, sdh)
64-
reinit!(cell_cache, 1)
64+
Ferrite.reinit!(cell_cache, 1)
6565
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) Vec((-0.5,))
6666
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 1.0) Vec((-0.5,))
6767
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 0.0) Vec((-0.45,))
6868
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 1.0) Vec((-0.45,))
69-
reinit!(cell_cache, 2)
69+
Ferrite.reinit!(cell_cache, 2)
7070
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) Vec((0.5,))
7171
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 1.0) Vec((0.5,))
7272
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 0.0) Vec((0.55,))
@@ -81,12 +81,12 @@
8181
CartesianCoordinateSystem(grid),
8282
)
8383
coeff_cache = Thunderbolt.setup_coefficient_cache(ac, qr, sdh)
84-
reinit!(cell_cache, 1)
84+
Ferrite.reinit!(cell_cache, 1)
8585
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) 0.5
8686
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 0.0) 0.45
8787
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 1.0) 1.5
8888
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 1.0) 1.45
89-
reinit!(cell_cache, 2)
89+
Ferrite.reinit!(cell_cache, 2)
9090
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) 0.5
9191
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 0.0) 0.55
9292
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 1.0) 1.5
@@ -105,7 +105,7 @@
105105
st = Tensor{2,2}((-1.0,0.0,0.0,0.0))
106106
coeff_cache = Thunderbolt.setup_coefficient_cache(stc, qr, sdh)
107107
for i in 1:2
108-
reinit!(cell_cache, i)
108+
Ferrite.reinit!(cell_cache, i)
109109
@test_opt evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0)
110110
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) st
111111
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 0.0) st
@@ -138,7 +138,7 @@
138138
)
139139
coeff_cache = Thunderbolt.setup_coefficient_cache(shdc, qr, sdh)
140140
for i in 1:2
141-
reinit!(cell_cache, i)
141+
Ferrite.reinit!(cell_cache, i)
142142
@test_opt evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0)
143143
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) Vec((0.1,))
144144
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 0.0) Vec((0.1,))
@@ -170,7 +170,7 @@
170170
)
171171
coeff_cache = Thunderbolt.setup_coefficient_cache(ctdc, qr, sdh)
172172
for i in 1:2
173-
reinit!(cell_cache, i)
173+
Ferrite.reinit!(cell_cache, i)
174174
@test_opt evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0)
175175
@test evaluate_coefficient(coeff_cache, cell_cache, qp1, 0.0) st
176176
@test evaluate_coefficient(coeff_cache, cell_cache, qp2, 0.0) st

test/test_elements.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
close!(dhs)
1717
sdhs = first(dhs.subdofhandlers)
1818
cell_cache_s = Ferrite.CellCache(sdhs)
19-
reinit!(cell_cache_s, 1)
19+
Ferrite.reinit!(cell_cache_s, 1)
2020
uₑs = [
2121
-1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0
2222
].*1e-4
@@ -27,7 +27,7 @@
2727
close!(dhv)
2828
sdhv = first(dhv.subdofhandlers)
2929
cell_cache_v = Ferrite.CellCache(sdhv)
30-
reinit!(cell_cache_v, 1)
30+
Ferrite.reinit!(cell_cache_v, 1)
3131
uₑv = [
3232
-1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0,
3333
-1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0,

0 commit comments

Comments
 (0)