-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix precomputed quantities for Rosenbrock timestepper
- Loading branch information
1 parent
9ae6551
commit f559f52
Showing
7 changed files
with
163 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
config/model_configs/plane_analytic_schar_mountain_float32_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
config: "plane" | ||
FLOAT_TYPE: "Float32" | ||
initial_condition: "ConstantBuoyancyFrequencyProfile" | ||
topography: "Schar" | ||
x_max: 100e3 | ||
z_max: 21e3 | ||
x_elem: 100 | ||
z_elem: 100 | ||
z_stretch: false | ||
dt: "0.5secs" | ||
t_end: "24hours" | ||
rayleigh_sponge: true | ||
toml: [toml/analytic_mountain_test.toml] | ||
analytic_check: true | ||
output_default_diagnostics: false | ||
diagnostics: | ||
- short_name: [orog, ua, wa, uapredicted, wapredicted, uaerror, waerror, c1error, c3error] | ||
period: 1hours |
19 changes: 19 additions & 0 deletions
19
config/model_configs/plane_analytic_schar_mountain_stretched_grid_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
config: "plane" | ||
FLOAT_TYPE: "Float32" | ||
initial_condition: "ConstantBuoyancyFrequencyProfile" | ||
topography: "Schar" | ||
x_max: 100e3 | ||
z_max: 21e3 | ||
x_elem: 100 | ||
z_elem: 100 | ||
dz_bottom: 50 | ||
dz_top: 1000 | ||
dt: "0.5secs" | ||
t_end: "24hours" | ||
rayleigh_sponge: true | ||
toml: [toml/analytic_mountain_test.toml] | ||
analytic_check: true | ||
output_default_diagnostics: false | ||
diagnostics: | ||
- short_name: [orog, ua, wa, uapredicted, wapredicted, uaerror, waerror, c1error, c3error] | ||
period: 1hours |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import ClimaTimeSteppers as CTS | ||
import LinearAlgebra: ldiv! | ||
|
||
function CTS.step_u!(int, cache::CTS.RosenbrockCache{Nstages}) where {Nstages} | ||
(; m, Γ, A, α, C) = int.alg.tableau | ||
(; u, p, t, dt) = int | ||
(; W, U, fU, fU_imp, fU_exp, fU_lim, k, ∂Y∂t) = cache | ||
T_imp! = int.sol.prob.f.T_imp! | ||
T_exp! = int.sol.prob.f.T_exp! | ||
T_exp_lim! = int.sol.prob.f.T_exp_T_lim! | ||
tgrad! = isnothing(T_imp!) ? nothing : T_imp!.tgrad | ||
|
||
(; post_explicit!, post_implicit!, dss!) = int.sol.prob.f | ||
|
||
# TODO: This is only valid when Γ[i, i] is constant, otherwise we have to | ||
# move this in the for loop | ||
dtγ = dt * Γ[1, 1] | ||
|
||
if !isnothing(T_imp!) | ||
Wfact! = int.sol.prob.f.T_imp!.Wfact | ||
Wfact!(W, u, p, dtγ, t) | ||
end | ||
|
||
if !isnothing(tgrad!) | ||
tgrad!(∂Y∂t, u, p, t) | ||
end | ||
|
||
for i in 1:Nstages | ||
# Reset tendency | ||
fill!(fU, 0) | ||
|
||
αi = sum(α[i, 1:(i - 1)]) | ||
γi = sum(Γ[i, 1:i]) | ||
|
||
U .= u | ||
for j in 1:(i - 1) | ||
U .+= A[i, j] .* k[j] | ||
end | ||
|
||
if !isnothing(post_implicit!) && i != 1 | ||
# NOTE: post_implicit! is a misnomer | ||
post_implicit!(U, p, t + αi * dt) | ||
end | ||
|
||
if !isnothing(T_imp!) | ||
T_imp!(fU_imp, U, p, t + αi * dt) | ||
fU .+= fU_imp | ||
end | ||
|
||
if !isnothing(T_exp!) | ||
T_exp!(fU_exp, U, p, t + αi * dt) | ||
fU .+= fU_exp | ||
end | ||
|
||
if !isnothing(T_exp_lim!) | ||
T_exp_lim!(fU_exp, fU_lim, U, p, t + αi * dt) | ||
fU .+= fU_exp | ||
fU .+= fU_lim | ||
end | ||
|
||
if !isnothing(tgrad!) | ||
fU .+= γi .* dt .* ∂Y∂t | ||
end | ||
|
||
# We dss the tendency at every stage but the last. At the last stage, we | ||
# dss the incremented state | ||
(i != Nstages) && dss!(fU, p, t + αi * dt) | ||
|
||
for j in 1:(i - 1) | ||
fU .+= (C[i, j] / dt) .* k[j] | ||
end | ||
|
||
fU .*= -dtγ | ||
|
||
if !isnothing(T_imp!) | ||
if W isa Matrix | ||
ldiv!(k[i], lu(W), fU) | ||
else | ||
ldiv!(k[i], W, fU) | ||
end | ||
else | ||
k[i] .= .-fU | ||
end | ||
end | ||
|
||
for i in 1:Nstages | ||
u .+= m[i] .* k[i] | ||
end | ||
|
||
dss!(u, p, t + dt) | ||
post_explicit!(u, p, t + dt) | ||
return nothing | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters