Skip to content

Commit

Permalink
Add some tests and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Dec 11, 2024
1 parent f52cbfd commit e1770ae
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
14 changes: 8 additions & 6 deletions examples/t8code_2d_fv/elixir_advection_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mesh = T8codeMesh(trees_per_dimension, element_class,

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)

tspan = (0.0, 1.0)
tspan = (0.0, 0.0)
ode = semidiscretize(semi, tspan);

summary_callback = SummaryCallback()
Expand All @@ -87,10 +87,12 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback,

###############################################################################
# run the simulation

# sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
# dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
# save_everystep = false, callback = callbacks);
# summary_callback()
println("Directly before solve")
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks, maxiters = 0);
println("Directly after solve")
summary_callback()
println("Directly after summary_callback")

GC.enable(true)
6 changes: 3 additions & 3 deletions examples/t8code_2d_fv/elixir_advection_gauss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ode = semidiscretize(semi, (0.0, 0.0));
summary_callback = SummaryCallback()

analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
# analysis_callback = AnalysisCallback(semi, interval = analysis_interval)

alive_callback = AliveCallback(analysis_interval = analysis_interval)

Expand All @@ -33,7 +33,7 @@ save_solution = SaveSolutionCallback(interval = 10,

stepsize_callback = StepsizeCallback(cfl = 0.5)

callbacks = CallbackSet(summary_callback, save_solution, analysis_callback, alive_callback,
callbacks = CallbackSet(#=summary_callback,=# save_solution, #=analysis_callback,=# alive_callback,
stepsize_callback)

###############################################################################
Expand All @@ -42,4 +42,4 @@ callbacks = CallbackSet(summary_callback, save_solution, analysis_callback, aliv
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false),#Euler(),
dt = 5.0e-2, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks);
summary_callback()
# summary_callback()
1 change: 1 addition & 0 deletions src/callbacks_step/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ end
# This method gets called internally as the main entry point to the AnalysiCallback
# TODO: Taal refactor, allow passing an IO object (which could be devnull to avoid cluttering the console)
function (analysis_callback::AnalysisCallback)(u_ode, du_ode, integrator, semi)
println("Start of analysis_callback")
mesh, equations, solver, cache = mesh_equations_solver_cache(semi)
@unpack dt, t = integrator
iter = integrator.stats.naccept
Expand Down
19 changes: 10 additions & 9 deletions src/solvers/fv_t8code/fv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,43 +162,44 @@ end
function rhs!(du, u, t, mesh::T8codeMesh, equations,
boundary_conditions, source_terms::Source,
solver::FV, cache) where {Source}
println("1. Start of actual rhs!")
# Reset du
@trixi_timeit timer() "reset ∂u/∂t" du.=zero(eltype(du))

println("2. actual rhs!")
# Exchange solution between MPI ranks
@trixi_timeit timer() "exchange_solution_data!" exchange_solution_data!(u, mesh,
equations,
solver,
cache)

println("3. of actual rhs!")
@trixi_timeit timer() "gradient reconstruction" calc_gradient_reconstruction!(u,
mesh,
equations,
solver,
cache)

println("4. of actual rhs!")
# Prolong solution to interfaces
@trixi_timeit timer() "prolong2interfaces" begin
prolong2interfaces!(cache, mesh, equations, solver)
end

println("5. of actual rhs!")
# Calculate interface fluxes
@trixi_timeit timer() "interface flux" begin
calc_interface_flux!(du, mesh, have_nonconservative_terms(equations), equations,
solver, cache)
end

println("6. of actual rhs!")
# Prolong solution to boundaries
@trixi_timeit timer() "prolong2boundaries!" begin
prolong2boundaries!(cache, mesh, equations, solver)
end

println("7. of actual rhs!")
# Calculate boundary fluxes
@trixi_timeit timer() "calc boundary flux" begin
calc_boundary_flux!(du, cache, t, boundary_conditions, mesh,
equations, solver)
end

println("8. of actual rhs!")
@trixi_timeit timer() "volume" begin
for element in eachelement(mesh, solver, cache)
volume = cache.elements.volume[element]
Expand All @@ -207,12 +208,12 @@ function rhs!(du, u, t, mesh::T8codeMesh, equations,
end
end
end

println("9. of actual rhs!")
# Calculate source terms
@trixi_timeit timer() "source terms" begin
calc_sources!(du, u, t, source_terms, mesh, equations, solver, cache)
end

println("10. End of actual rhs!")
return nothing
end

Expand Down

0 comments on commit e1770ae

Please sign in to comment.