Skip to content

Commit

Permalink
remake for SemidiscretizationEulerGravity (trixi-framework#2087)
Browse files Browse the repository at this point in the history
* `Remake` for `SemidiscretizationEulerGravity`

* test + fmt

* correct dataypte retrieval
  • Loading branch information
DanielDoehring authored Sep 24, 2024
1 parent 827a738 commit 744e9a9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/semidiscretization/semidiscretization_euler_gravity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,26 @@ function SemidiscretizationEulerGravity(semi_euler::SemiEuler,
parameters, cache)
end

# TODO: AD, add appropriate method for remake
function remake(semi::SemidiscretizationEulerGravity;
uEltype = real(semi.semi_gravity.solver),
semi_euler = semi.semi_euler,
semi_gravity = semi.semi_gravity,
parameters = semi.parameters)
semi_euler = remake(semi_euler, uEltype = uEltype)
semi_gravity = remake(semi_gravity, uEltype = uEltype)

# Recreate cache, i.e., registers for u with e.g. AD datatype
u_ode = compute_coefficients(zero(real(semi_gravity)), semi_gravity)
du_ode = similar(u_ode)
u_tmp1_ode = similar(u_ode)
u_tmp2_ode = similar(u_ode)
cache = (; u_ode, du_ode, u_tmp1_ode, u_tmp2_ode)

SemidiscretizationEulerGravity{typeof(semi_euler), typeof(semi_gravity),
typeof(parameters), typeof(cache)}(semi_euler,
semi_gravity,
parameters, cache)
end

function Base.show(io::IO, semi::SemidiscretizationEulerGravity)
@nospecialize semi # reduce precompilation time
Expand Down
11 changes: 11 additions & 0 deletions test/test_special_elixirs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ end
tspan = (0.0, 0.0), initial_refinement_level = 0)
@test_nowarn jacobian_ad_forward(semi)
end

@timed_testset "EulerGravity" begin
trixi_include(@__MODULE__,
joinpath(EXAMPLES_DIR,
"paper_self_gravitating_gas_dynamics",
"elixir_eulergravity_convergence.jl"),
tspan = (0.0, 0.0), initial_refinement_level = 1)
J = jacobian_ad_forward(semi)
λ = eigvals(J)
@test maximum(real, λ) < 1.5
end
end

@timed_testset "Test linear structure (3D)" begin
Expand Down

0 comments on commit 744e9a9

Please sign in to comment.