Skip to content

Commit

Permalink
Timestep stamp in mesh file (#1580)
Browse files Browse the repository at this point in the history
* Timestep stamp in mesh file

* Update src/callbacks_step/save_solution.jl

Fixes other mesh type issue

Co-authored-by: Hendrik Ranocha <[email protected]>

* Add test for multiple mesh files

* Keep within pre-existing tests

---------

Co-authored-by: Hendrik Ranocha <[email protected]>
  • Loading branch information
Arpit-Babbar and ranocha authored Jul 26, 2023
1 parent d7ea40b commit 53a826b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/callbacks_step/save_solution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,14 @@ function save_mesh(semi::AbstractSemidiscretization, output_directory, timestep
mesh, _, _, _ = mesh_equations_solver_cache(semi)

if mesh.unsaved_changes
mesh.current_filename = save_mesh_file(mesh, output_directory)
# We only append the time step number to the mesh file name if it has
# changed during the simulation due to AMR. We do not append it for
# the first time step.
if timestep == 0
mesh.current_filename = save_mesh_file(mesh, output_directory)
else
mesh.current_filename = save_mesh_file(mesh, output_directory, timestep)
end
mesh.unsaved_changes = false
end
end
Expand Down
6 changes: 6 additions & 0 deletions test/test_mpi_tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows()
# Linear scalar advection with AMR
# These example files are only for testing purposes and have no practical use
@trixi_testset "elixir_advection_amr_refine_twice.jl" begin
# Here, we also test that SaveSolutionCallback prints multiple mesh files with AMR
# Start with a clean environment: remove Trixi.jl output directory if it exists
outdir = "out"
isdir(outdir) && rm(outdir, recursive=true)
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_refine_twice.jl"),
l2 = [0.00020547512522578292],
linf = [0.007831753383083506],
coverage_override = (maxiters=6,))
meshfiles = filter(file -> endswith(file,".h5") && startswith(file,"mesh"), readdir(outdir))
@test length(meshfiles) > 1
end

@trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin
Expand Down

0 comments on commit 53a826b

Please sign in to comment.