Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Checkpointing for T8codeMesh #1980

Merged
merged 78 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
3f73fb8
Switching to t8_cmesh_new_brick_{2,3}d.
May 10, 2024
8120409
Backup.
Jun 13, 2024
3ad3515
Add save callback to elixir.
Jun 14, 2024
6e90adf
Merge branch 'main' into feature-t8codemesh-checkpointing
Jun 17, 2024
23714f1
Backup.
Jun 18, 2024
3f8ded2
Refined code. Make it work in parallel.
Jun 19, 2024
2f5d224
Added support for parallelt8codemesh save solution callback.
Jun 19, 2024
d3a1b49
Applied formatter.
Jun 19, 2024
9ef91c6
Updated examples and tests.
Jun 20, 2024
7c80560
Merge branch 'main' into feature-t8codemesh-checkpointing
Jun 20, 2024
2f96869
Applied formatter.
Jun 20, 2024
df2bdf4
Minor adjustments.
Jun 21, 2024
7ee23b6
Code refinement. Enabled partitioning after mesh loading.
Jun 24, 2024
0404f3b
Applied formatter and fixed typos.
Jun 24, 2024
03d0194
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Jun 24, 2024
99972cc
Removed commented out section.
Jun 24, 2024
f59322c
Added missing union type member.
Jun 24, 2024
be2fcdd
Switching from UInt64 to UInt128 in global interface/mortar id comput…
Jun 26, 2024
0283428
Switching from UInt64 to UInt128 in global interface/mortar id comput…
Jun 26, 2024
db9d4c6
Adding more tests.
Jun 26, 2024
b6e1333
Applied formatter.
Jun 26, 2024
36c7517
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Jun 26, 2024
1aea5cd
Removed Printf.
Jun 26, 2024
dae7aaa
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Jun 28, 2024
b603823
Incorporated review comments and code polish.
Jun 28, 2024
6ef17a4
Applied formatter.
Jun 28, 2024
69b7ac1
Fixed typos.
Jun 28, 2024
ad0fba1
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Jul 1, 2024
e03f57d
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Jul 1, 2024
9fc72c4
Merge branch 'main' into feature-t8codemesh-checkpointing
JoshuaLampert Jul 2, 2024
e65b1a5
Merge branch 'main' into feature-t8codemesh-checkpointing
ranocha Jul 2, 2024
3bbd3a1
Update examples/t8code_2d_dgsem/elixir_advection_restart.jl
jmark Jul 2, 2024
ab9c33f
Update examples/t8code_2d_dgsem/elixir_advection_restart_amr.jl
jmark Jul 2, 2024
9e49219
Update examples/t8code_3d_dgsem/elixir_advection_restart.jl
jmark Jul 2, 2024
677236f
Update src/meshes/mesh_io.jl
jmark Jul 2, 2024
6396931
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Jul 2, 2024
404fc85
Update examples/t8code_3d_dgsem/elixir_advection_restart.jl
jmark Jul 4, 2024
611a576
Update src/meshes/t8code_mesh.jl
jmark Jul 4, 2024
c8c5c20
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Jul 4, 2024
7161d1b
Update src/meshes/t8code_mesh.jl
jmark Jul 4, 2024
15cdc0b
Removing last test in t8code 2D MPI to investigate problems in Github…
Jul 5, 2024
de00b40
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Jul 8, 2024
971d2cf
Refactored a bit.
Jul 8, 2024
a3c169c
Applied formatter.
Jul 8, 2024
6383520
Removed commented code.
Jul 8, 2024
41ebc07
Added LOG_LEVEL variable.
Jul 9, 2024
e268b33
Added t8code interface simplfication and stitched memory leak.
Jul 9, 2024
0ef1d55
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Jul 9, 2024
1e00cb6
Applied formatter.
Jul 9, 2024
8493c8e
Simplifying finailze behavior for T8codeMesh.
Jul 22, 2024
2d4bfb3
Addeing finalize call to T8codeMesh examples.
Jul 22, 2024
a102101
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Jul 22, 2024
573133a
Applied formatter.
Jul 22, 2024
9c49fa1
Merge branch 'main' into t8code-switch-to-own-cmesh-brick-implementation
jmark Oct 10, 2024
438e232
Merge branch 'main' into feature-t8codemesh-checkpointing
benegee Oct 14, 2024
509884f
Merge branch 'main' into feature-t8codemesh-checkpointing
benegee Oct 29, 2024
ec19920
Merge branch 'main' into feature-t8codemesh-checkpointing
benegee Nov 4, 2024
577dc57
typo
benegee Nov 4, 2024
b8eb23f
Aktualisieren von Project.toml
benegee Nov 5, 2024
5fedb55
Set MPI.jl compat version to 0.20.6
benegee Nov 5, 2024
f6b07d5
bump MPI.jl compat version
benegee Nov 5, 2024
9dfefb4
Merge branch 'main' into feature-t8codemesh-checkpointing
jmark Nov 5, 2024
6cdee9a
Merge branch 'main' into t8code-switch-to-own-cmesh-brick-implementation
Nov 5, 2024
55ce488
Update T8code.
Nov 5, 2024
7405931
replace t8_geom_get_dimension by t8_cmesh_get_dimension
benegee Nov 5, 2024
aa2ed4b
temporarily set negative volume test to broken
benegee Nov 5, 2024
62e9e3b
Merge branch 'main' into t8code-switch-to-own-cmesh-brick-implementation
benegee Nov 5, 2024
7f06fb8
no broken for test_throws
benegee Nov 5, 2024
080edaa
Merge branch 't8code-switch-to-own-cmesh-brick-implementation' of git…
benegee Nov 5, 2024
bdedf8a
need a boolean return value
benegee Nov 5, 2024
82437ed
Merge branch 'main' into t8code-switch-to-own-cmesh-brick-implementation
benegee Nov 5, 2024
ac0930a
Merge branch 't8code-switch-to-own-cmesh-brick-implementation' into f…
benegee Nov 5, 2024
4ed4bbb
no dim in t8_geometry_linear_new anymore
benegee Nov 5, 2024
8662d97
Merge branch 'main' into feature-t8codemesh-checkpointing
benegee Nov 5, 2024
8100162
Merge branch 'main' into feature-t8codemesh-checkpointing
Nov 5, 2024
5066b21
Merge branch 'feature-t8codemesh-checkpointing' of github.com:trixi-f…
Nov 5, 2024
860ffba
Fixed typo.
Nov 5, 2024
aca9742
Ironing out minor issues.
Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ IfElse = "0.1"
LinearAlgebra = "1"
LinearMaps = "2.7, 3.0"
LoopVectorization = "0.12.151"
MPI = "0.20"
MPI = "0.20.6"
Makie = "0.19, 0.20"
MuladdMacro = "0.2.2"
NLsolve = "4.5.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval,

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

amr_controller = ControllerThreeLevel(semi,
TrixiExtension.IndicatorSolutionIndependent(semi),
base_level = 4,
Expand All @@ -124,12 +129,20 @@ amr_controller = ControllerThreeLevel(semi,
amr_callback = AMRCallback(semi, amr_controller,
interval = 5,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)
adapt_initial_condition_only_refine = true,
dynamic_load_balancing = false)
# We disable `dynamic_load_balancing` for now, since t8code does not support
# partitioning for coarsening yet. That is, a complete family of elements always
# stays on rank and is not split up due to partitioning. Without this feature
# dynamic AMR simulations are not perfectly deterministic regarding to
# convergent tests. Once this feature is available in t8code load balancing is
# enabled again.

stepsize_callback = StepsizeCallback(cfl = 1.6)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_solution,
amr_callback, stepsize_callback);

###############################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval,

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_restart = SaveRestartCallback(interval = 100,
save_final_restart = true)

save_solution = SaveSolutionCallback(interval = 100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first),
base_level = 1,
med_level = 2, med_threshold = 0.1,
Expand All @@ -62,12 +70,19 @@ amr_callback = AMRCallback(semi, amr_controller,
interval = 5,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true,
dynamic_load_balancing = true)
dynamic_load_balancing = false)
jmark marked this conversation as resolved.
Show resolved Hide resolved
# We disable `dynamic_load_balancing` for now, since t8code does not support
# partitioning for coarsening yet. That is, a complete family of elements always
# stays on rank and is not split up due to partitioning. Without this feature
# dynamic AMR simulations are not perfectly deterministic regarding to
# convergent tests. Once this feature is available in t8code load balancing is
# enabled again.

stepsize_callback = StepsizeCallback(cfl = 0.7)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_restart, save_solution,
amr_callback, stepsize_callback)

###############################################################################
Expand Down
89 changes: 89 additions & 0 deletions examples/t8code_2d_dgsem/elixir_advection_extended.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# semidiscretization of the linear advection equation

advection_velocity = (0.2, -0.7)
equations = LinearScalarAdvectionEquation2D(advection_velocity)

initial_condition = initial_condition_convergence_test

# BCs must be passed as Dict
boundary_condition = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = Dict(:x_neg => boundary_condition,
:x_pos => boundary_condition,
:y_neg => boundary_condition,
:y_pos => boundary_condition)

# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)

# The initial condition is 2-periodic
coordinates_min = (-1.5, 1.3) # minimum coordinates (min(x), min(y))
coordinates_max = (0.5, 5.3) # maximum coordinates (max(x), max(y))

trees_per_dimension = (19, 37)

# Create curved mesh with 19 x 37 elements
mesh = T8codeMesh(trees_per_dimension, polydeg = 3,
coordinates_min = coordinates_min, coordinates_max = coordinates_max,
periodicity = false)

# A semidiscretization collects data structures and functions for the spatial discretization
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
boundary_conditions = boundary_conditions)

###############################################################################
# ODE solvers, callbacks etc.

# Create ODE problem with time span from 0.0 to 1.0
tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan);

# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation setup
# and resets the timers
summary_callback = SummaryCallback()

# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval,
extra_analysis_integrals = (entropy, energy_total))

# The AliveCallback prints short status information in regular intervals
alive_callback = AliveCallback(analysis_interval = analysis_interval)

# The SaveRestartCallback allows to save a file from which a Trixi.jl simulation can be restarted
save_restart = SaveRestartCallback(interval = 100,
save_final_restart = true)

# The SaveSolutionCallback allows to save the solution to a file in regular intervals
save_solution = SaveSolutionCallback(interval = 100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step
stepsize_callback = StepsizeCallback(cfl = 1.6)

# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_restart, save_solution,
stepsize_callback)

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

# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed callbacks
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);

# Print the timer summary
summary_callback()

# Finalize `T8codeMesh` to make sure MPI related objects in t8code are
# released before `MPI` finalizes.
!isinteractive() && finalize(mesh)
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,16 @@ summary_callback = SummaryCallback()
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
analysis_callback = AnalysisCallback(semi, interval = 100)

# The SaveSolutionCallback allows to save the solution to a file in regular intervals
save_solution = SaveSolutionCallback(interval = 100,
solution_variables = cons2prim)

# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step
stepsize_callback = StepsizeCallback(cfl = 1.6)

# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
callbacks = CallbackSet(summary_callback, analysis_callback, stepsize_callback)
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution,
stepsize_callback)

###############################################################################
# run the simulation
Expand Down
47 changes: 47 additions & 0 deletions examples/t8code_2d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# create a restart file

elixir_file = "elixir_advection_extended.jl"
restart_file = "restart_000000021.h5"

trixi_include(@__MODULE__, joinpath(@__DIR__, elixir_file))

###############################################################################
# adapt the parameters that have changed compared to "elixir_advection_extended.jl"

# Note: If you get a restart file from somewhere else, you need to provide
# appropriate setups in the elixir loading a restart file

restart_filename = joinpath("out", restart_file)
mesh = load_mesh(restart_filename)

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

tspan = (load_time(restart_filename), 2.0)
dt = load_dt(restart_filename)
ode = semidiscretize(semi, tspan, restart_filename);

# Do not overwrite the initial snapshot written by elixir_advection_extended.jl.
save_solution.condition.save_initial_solution = false

integrator = init(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = dt, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks, maxiters = 100_000);

# Get the last time index and work with that.
load_timestep!(integrator, restart_filename)

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

sol = solve!(integrator)
summary_callback() # print the timer summary

# Finalize `T8codeMesh` to make sure MPI related objects in t8code are
# released before `MPI` finalizes.
!isinteractive() && finalize(mesh)
66 changes: 66 additions & 0 deletions examples/t8code_2d_dgsem/elixir_advection_restart_amr.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# create a restart file

elixir_file = "elixir_advection_extended.jl"
restart_file = "restart_000000021.h5"

trixi_include(@__MODULE__, joinpath(@__DIR__, elixir_file))

###############################################################################
# adapt the parameters that have changed compared to "elixir_advection_extended.jl"

# Note: If you get a restart file from somewhere else, you need to provide
# appropriate setups in the elixir loading a restart file

restart_filename = joinpath("out", restart_file)
mesh = load_mesh(restart_filename)

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

tspan = (load_time(restart_filename), 2.0)
dt = load_dt(restart_filename)
ode = semidiscretize(semi, tspan, restart_filename);

# Do not overwrite the initial snapshot written by elixir_advection_extended.jl.
save_solution.condition.save_initial_solution = false

# Add AMR callback
amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first),
base_level = 0,
med_level = 0, med_threshold = 0.8,
max_level = 1, max_threshold = 1.2)
amr_callback = AMRCallback(semi, amr_controller,
interval = 5,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true,
dynamic_load_balancing = false)
# We disable `dynamic_load_balancing` for now, since t8code does not support
# partitioning for coarsening yet. That is, a complete family of elements always
# stays on rank and is not split up due to partitioning. Without this feature
# dynamic AMR simulations are not perfectly deterministic regarding to
# convergent tests. Once this feature is available in t8code load balancing is
# enabled again.

callbacks_ext = CallbackSet(amr_callback, callbacks.discrete_callbacks...)

integrator = init(ode, CarpenterKennedy2N54(williamson_condition = false),
dt = dt, # solve needs some value here but it will be overwritten by the stepsize_callback
save_everystep = false, callback = callbacks_ext, maxiters = 100_000);

# Get the last time index and work with that.
load_timestep!(integrator, restart_filename)

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

sol = solve!(integrator)
summary_callback() # print the timer summary

# Finalize `T8codeMesh` to make sure MPI related objects in t8code are
# released before `MPI` finalizes.
!isinteractive() && finalize(mesh)
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@ summary_callback = SummaryCallback()
# prints the results.
analysis_callback = AnalysisCallback(semi, interval = 100)

# The SaveSolutionCallback allows to save the solution to a file in regular intervals
save_solution = SaveSolutionCallback(interval = 100,
solution_variables = cons2prim)

# The StepsizeCallback handles the re-calculation of the maximum Δt after each
# time step.
stepsize_callback = StepsizeCallback(cfl = 1.4)

# Create a CallbackSet to collect all callbacks such that they can be passed to
# the ODE solver.
callbacks = CallbackSet(summary_callback, analysis_callback, stepsize_callback)
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution,
stepsize_callback)

###############################################################################
# Run the simulation.
Expand Down
6 changes: 6 additions & 0 deletions examples/t8code_2d_dgsem/elixir_euler_free_stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,16 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval)

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

stepsize_callback = StepsizeCallback(cfl = 2.0)

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

###############################################################################
Expand Down
5 changes: 5 additions & 0 deletions examples/t8code_2d_dgsem/elixir_euler_sedov.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,16 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval)

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 300,
save_initial_solution = true,
save_final_solution = true)

stepsize_callback = StepsizeCallback(cfl = 0.5)

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

###############################################################################
Expand Down
6 changes: 6 additions & 0 deletions examples/t8code_2d_dgsem/elixir_euler_shockcapturing_ec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval)

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

stepsize_callback = StepsizeCallback(cfl = 1.0)

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

###############################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,19 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval)

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_restart = SaveRestartCallback(interval = 100,
save_final_restart = true)

save_solution = SaveSolutionCallback(interval = 100,
save_initial_solution = true,
save_final_solution = true,
solution_variables = cons2prim)

stepsize_callback = StepsizeCallback(cfl = 0.8)

callbacks = CallbackSet(summary_callback,
analysis_callback, alive_callback,
save_restart, save_solution,
stepsize_callback)
###############################################################################
# run the simulation
Expand Down
Loading
Loading