Skip to content

Commit

Permalink
fmt + comments
Browse files Browse the repository at this point in the history
  • Loading branch information
warisa-r committed Mar 26, 2024
1 parent 8946833 commit aabb8cc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
1 change: 0 additions & 1 deletion examples/tree_1d_dgsem/elixir_advection_PERK2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ sol = Trixi.solve(ode, ode_algorithm,

# Print the timer summary
summary_callback()
analysis_callback(sol)
12 changes: 7 additions & 5 deletions src/callbacks_step/stepsize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Base.show(io::IO, ::MIME"text/plain",
stepsize_callback = cb.affect!

setup = [
"CFL number" => stepsize_callback.cfl_number,
"CFL number" => stepsize_callback.cfl_number
]
summary_box(io, "StepsizeCallback", setup)
end
Expand Down Expand Up @@ -64,7 +64,7 @@ end
t = integrator.t
u_ode = integrator.u
semi = integrator.p

# If the integrator is an optimized integrator, calculate cfl number instead of using the input cfl number
if isa(integrator.alg, PERK2) || isa(integrator.alg, PERK3)
cfl_number = calculate_cfl_number(u_ode, t, integrator.alg.dt_opt, semi)
Expand Down Expand Up @@ -92,11 +92,13 @@ end
function calculate_cfl_number(u_ode, t, dt_opt, semi::AbstractSemidiscretization)
mesh, equations, solver, cache = mesh_equations_solver_cache(semi)
u = wrap_array(u_ode, mesh, equations, solver, cache)
max_dt_variable = max_dt(u, t, mesh,have_constant_speed(equations), equations, solver, cache)
max_dt_variable = max_dt(u, t, mesh, have_constant_speed(equations), equations,
solver, cache)
# For debugging purpose, especially for PERK3
println("max_dt $max_dt_variable")
cfl_number = dt_opt / max_dt(u, t, mesh,
have_constant_speed(equations), equations,
solver, cache)
have_constant_speed(equations), equations,
solver, cache)

return cfl_number
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ mutable struct PERK2 <: PERKSingle
newPERK2 = new(num_stages)

newPERK2.a_matrix, newPERK2.c, newPERK2.dt_opt = compute_PERK2_butcher_tableau(num_stages,
eig_vals, tspan,
bS, c_end)
eig_vals,
tspan,
bS,
c_end)

newPERK2.b1 = one(bS) - bS
newPERK2.bS = bS
Expand All @@ -153,8 +155,10 @@ mutable struct PERK2 <: PERKSingle
newPERK2 = new(num_stages)

newPERK2.a_matrix, newPERK2.c, newPERK2.dt_opt = compute_PERK2_butcher_tableau(num_stages,
eig_vals, tspan,
bS, c_end)
eig_vals,
tspan,
bS,
c_end)

newPERK2.b1 = one(bS) - bS
newPERK2.bS = bS
Expand Down Expand Up @@ -288,7 +292,7 @@ function solve!(integrator::PERK2Integrator)
end

# Higher stages
for stage in 3:alg.num_stages
for stage in 3:(alg.num_stages)
# Construct current state
@threaded for i in eachindex(integrator.du)
integrator.u_tmp[i] = integrator.u[i] +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ mutable struct PERK3 <: PERKSingle
eig_vals = eigvals(jacobian_ad_forward(semi))
newPERK3 = new(num_stages)

newPERK3.a_matrix, newPERK3.c, newPERK3.dt_opt = compute_PERK3_Butcher_tableau(num_stages, tspan,
eig_vals,
c_s2)
newPERK3.a_matrix, newPERK3.c, newPERK3.dt_opt = compute_PERK3_Butcher_tableau(num_stages,
tspan,
eig_vals,
c_s2)

return newPERK3
end
Expand All @@ -208,9 +209,10 @@ mutable struct PERK3 <: PERKSingle
c_s2 = 1.0)
newPERK3 = new(num_stages)

newPERK3.a_matrix, newPERK3.c, newPERK3.dt_opt = compute_PERK3_Butcher_tableau(num_stages, tspan,
eig_vals,
c_s2)
newPERK3.a_matrix, newPERK3.c, newPERK3.dt_opt = compute_PERK3_Butcher_tableau(num_stages,
tspan,
eig_vals,
c_s2)
return newPERK3
end
end # struct PERK3
Expand Down

0 comments on commit aabb8cc

Please sign in to comment.