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

Add more zeros to solution file name #1996

Merged
merged 8 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ for human readability.

- The specification of boundary names on which `AnalysisSurfaceIntegral`s are computed (such as drag and lift coefficients) has changed from `Symbol` and `Vector{Symbol}` to `NTuple{Symbol}`.
Thus, for one boundary the syntax changes from `:boundary` to `(:boundary,)` and for `Vector`s `[:boundary1, :boundary2]` to `(:boundary1, :boundary2)` ([1959]).
- The names of output files like the one created from the `SaveSolutionCallback` have changed from `%06d` to `%09d` to allow longer-running simulations ([1996]).

#### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ Measurements = "2.5"
OrdinaryDiffEq = "6.49.1"
Plots = "1.9"
Test = "1"
Trixi2Vtk = "0.3"
Trixi2Vtk = "0.3.16"
TrixiBase = "0.1.1"
14 changes: 7 additions & 7 deletions docs/literate/src/files/first_steps/create_first_setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,28 +260,28 @@ plot!(getmesh(pd))
# import Pkg
# Pkg.add(["Trixi2Vtk"])
# ```
# Now we load the Trixi2Vtk.jl package and convert the file `out/solution_000032.h5` with
# Now we load the Trixi2Vtk.jl package and convert the file `out/solution_000000032.h5` with
# the final solution using the [`trixi2vtk`](@ref) function saving the resulting file in the
# `out` folder.

using Trixi2Vtk
trixi2vtk(joinpath("out", "solution_000032.h5"), output_directory="out")
trixi2vtk(joinpath("out", "solution_000000032.h5"), output_directory="out")

# Now two files `solution_000032.vtu` and `solution_000032_celldata.vtu` have been generated in the
# Now two files `solution_000000032.vtu` and `solution_000000032_celldata.vtu` have been generated in the
# `out` folder. The first one contains all the information for visualizing the solution, the
# second one contains all the cell-based or discretization-based information.

# Now let's visualize the solution from the generated files in ParaView. Follow this short
# instruction to get the visualization.
# - Download, install and open [ParaView](https://www.paraview.org/download/).
# - Press `Ctrl+O` and select the generated files `solution_000032.vtu` and
# `solution_000032_celldata.vtu` from the `out` folder.
# - Press `Ctrl+O` and select the generated files `solution_000000032.vtu` and
# `solution_000000032_celldata.vtu` from the `out` folder.
# - In the upper-left corner in the Pipeline Browser window, left-click on the eye-icon near
# `solution_000032.vtu`.
# `solution_000000032.vtu`.
# - In the lower-left corner in the Properties window, change the Coloring from Solid Color to
# scalar. This already generates the visualization of the final solution.
# - Now let's add the mesh to the visualization. In the upper-left corner in the
# Pipeline Browser window, left-click on the eye-icon near `solution_000032_celldata.vtu`.
# Pipeline Browser window, left-click on the eye-icon near `solution_000000032_celldata.vtu`.
# - In the lower-left corner in the Properties window, change the Representation from Surface
# to Wireframe. Then a white grid should appear on the visualization.
# Now, if you followed the instructions exactly, you should get a similar image as shown in the
Expand Down
4 changes: 2 additions & 2 deletions docs/literate/src/files/hohqmesh_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ end #hide #md

using Trixi2Vtk
redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md
trixi2vtk("out/solution_000180.h5", output_directory="out")
trixi2vtk("out/solution_000000180.h5", output_directory="out")
end #hide #md

# Note this step takes about 15-30 seconds as the package `Trixi2Vtk` must be precompiled and executed for the first time
Expand All @@ -64,7 +64,7 @@ end #hide #md
# visualization nodes. For instance, if we want to use 12 uniformly spaced nodes for visualization we can execute

redirect_stdio(stdout=devnull, stderr=devnull) do # code that prints annoying stuff we don't want to see here #hide #md
trixi2vtk("out/solution_000180.h5", output_directory="out", nvisnodes=12)
trixi2vtk("out/solution_000000180.h5", output_directory="out", nvisnodes=12)
end #hide #md

# By default `trixi2vtk` sets `nvisnodes` to be the same as the number of nodes specified in
Expand Down
2 changes: 1 addition & 1 deletion docs/src/restart.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ conditionals like `if restart` with a boolean variable `restart` that is user de

First we need to define from which file we want to restart, e.g.
```julia
restart_file = "restart_000021.h5"
restart_file = "restart_000000021.h5"
restart_filename = joinpath("out", restart_file)
```

Expand Down
12 changes: 6 additions & 6 deletions docs/src/visualization.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,15 @@ julia> using Trixi2Vtk
```
To process an HDF5 file generated by Trixi.jl, execute
```julia
julia> trixi2vtk(joinpath("out", "solution_000000.h5"), output_directory="out")
julia> trixi2vtk(joinpath("out", "solution_000000000.h5"), output_directory="out")
```
This will create two unstructured VTK files in the `out` subdirectory that can
be opened with ParaView or VisIt: `solution_000000.vtu` contains the
discontinuous Galerkin solution data while `solution_000000_celldata.vtu` holds
be opened with ParaView or VisIt: `solution_000000000.vtu` contains the
discontinuous Galerkin solution data while `solution_000000000_celldata.vtu` holds
any cell-based values such as the current AMR indicator or the cell refinement
level.

!["solution_000000_scalar_mesh"](https://github.com/trixi-framework/Trixi2Vtk.jl/raw/main/docs/src/assets/solution_000000_scalar_mesh.png)
!["solution_000000000_scalar_mesh"](https://github.com/trixi-framework/Trixi2Vtk.jl/raw/main/docs/src/assets/solution_000000_scalar_mesh.png)

This allows you to generate VTK files for solution, restart and mesh files. By
default, Trixi2Vtk generates `.vtu` (unstructured VTK) files for both
Expand All @@ -440,7 +440,7 @@ publication-quality images, but increases the file size.
If you want to convert multiple solution/restart files at once, you can just supply
multiple input files as the positional arguments to `trixi2vtk`, e.g.,
```julia
julia> trixi2vtk("out/solution_000000.h5", "out/solution_000040.h5")
julia> trixi2vtk("out/solution_000000000.h5", "out/solution_000000040.h5")
```
You may also use file globbing to select a range of files based on filename patterns, e.g.,
```julia
Expand All @@ -450,7 +450,7 @@ to convert all solution files in the `out/` directory or
```julia
julia> trixi2vtk("out/restart_00[0-9]000.h5")
```
to convert every one-thousandth restart file (`out/restart_000000.h5`,
to convert every one-thousandth restart file (`out/restart_000000000.h5`,
`out/restart_001000.h5` etc.).

When multiple solution/restart files are provided, Trixi2Vtk will also generate a
Expand Down
2 changes: 1 addition & 1 deletion examples/p4est_2d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Trixi
# create a restart file

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

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

Expand Down
2 changes: 1 addition & 1 deletion examples/p4est_2d_dgsem/elixir_advection_restart_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Trixi
# create a restart file

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

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

Expand Down
2 changes: 1 addition & 1 deletion examples/p4est_3d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.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_000010.h5")
restart_filename = joinpath("out", "restart_000000010.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
Expand Down
2 changes: 1 addition & 1 deletion examples/structured_2d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Trixi
# create a restart file

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

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

Expand Down
2 changes: 1 addition & 1 deletion examples/structured_3d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_basic.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_000010.h5")
restart_filename = joinpath("out", "restart_000000010.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_convergence_test,
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_2d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), a
# 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_000040.h5")
restart_filename = joinpath("out", "restart_000000040.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_2d_dgsem/elixir_advection_restart_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_advection_extended.jl"), a
# 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_000040.h5")
restart_filename = joinpath("out", "restart_000000040.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_3d_dgsem/elixir_advection_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "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_000019.h5")
restart_filename = joinpath("out", "restart_000000019.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
Expand Down
2 changes: 1 addition & 1 deletion examples/unstructured_2d_dgsem/elixir_euler_restart.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ trixi_include(@__MODULE__, joinpath(@__DIR__, "elixir_euler_basic.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_000050.h5")
restart_filename = joinpath("out", "restart_000000050.h5")
mesh = load_mesh(restart_filename)

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver,
Expand Down
6 changes: 3 additions & 3 deletions src/callbacks_step/save_restart_dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function save_restart_file(u, time, dt, timestep,
@unpack output_directory = restart_callback

# Filename based on current time step
filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep))
filename = joinpath(output_directory, @sprintf("restart_%09d.h5", timestep))

# Restart files always store conservative variables
data = u
Expand Down Expand Up @@ -93,7 +93,7 @@ function save_restart_file(u, time, dt, timestep,
restart_callback)
@unpack output_directory = restart_callback
# Filename based on current time step
filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep))
filename = joinpath(output_directory, @sprintf("restart_%09d.h5", timestep))

if HDF5.has_parallel()
save_restart_file_parallel(u, time, dt, timestep, mesh, equations, dg, cache,
Expand Down Expand Up @@ -337,7 +337,7 @@ function save_adaptive_time_integrator(integrator,
timestep = integrator.stats.naccept

# Filename based on current time step
filename = joinpath(output_directory, @sprintf("restart_%06d.h5", timestep))
filename = joinpath(output_directory, @sprintf("restart_%09d.h5", timestep))

# Open file (preserve existing content)
h5open(filename, "r+") do file
Expand Down
8 changes: 4 additions & 4 deletions src/callbacks_step/save_solution_dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ function save_solution_file(u, time, dt, timestep,

# Filename based on current time step
if isempty(system)
filename = joinpath(output_directory, @sprintf("solution_%06d.h5", timestep))
filename = joinpath(output_directory, @sprintf("solution_%09d.h5", timestep))
else
filename = joinpath(output_directory,
@sprintf("solution_%s_%06d.h5", system, timestep))
@sprintf("solution_%s_%09d.h5", system, timestep))
end

# Convert to different set of variables if requested
Expand Down Expand Up @@ -101,10 +101,10 @@ function save_solution_file(u, time, dt, timestep,

# Filename based on current time step
if isempty(system)
filename = joinpath(output_directory, @sprintf("solution_%06d.h5", timestep))
filename = joinpath(output_directory, @sprintf("solution_%09d.h5", timestep))
else
filename = joinpath(output_directory,
@sprintf("solution_%s_%06d.h5", system, timestep))
@sprintf("solution_%s_%09d.h5", system, timestep))
end

# Convert to different set of variables if requested
Expand Down
2 changes: 1 addition & 1 deletion src/callbacks_step/visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ function save_plot(plot_data, variable_names;
Plots.plot(plots..., layout = layout)

# Determine filename and save plot
filename = joinpath("out", @sprintf("solution_%06d.png", timestep))
filename = joinpath("out", @sprintf("solution_%09d.png", timestep))
Plots.savefig(filename)
end
end # @muladd
12 changes: 6 additions & 6 deletions src/meshes/mesh_io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function save_mesh_file(mesh::TreeMesh, output_directory, timestep,

# Determine file name based on existence of meaningful time step
if timestep > 0
filename = joinpath(output_directory, @sprintf("mesh_%06d.h5", timestep))
filename = joinpath(output_directory, @sprintf("mesh_%09d.h5", timestep))
else
filename = joinpath(output_directory, "mesh.h5")
end
Expand Down Expand Up @@ -57,7 +57,7 @@ function save_mesh_file(mesh::TreeMesh, output_directory, timestep,

# Determine file name based on existence of meaningful time step
if timestep >= 0
filename = joinpath(output_directory, @sprintf("mesh_%06d.h5", timestep))
filename = joinpath(output_directory, @sprintf("mesh_%09d.h5", timestep))
else
filename = joinpath(output_directory, "mesh.h5")
end
Expand Down Expand Up @@ -156,8 +156,8 @@ function save_mesh_file(mesh::P4estMesh, output_directory, timestep,

# Determine file name based on existence of meaningful time step
if timestep > 0
filename = joinpath(output_directory, @sprintf("mesh_%06d.h5", timestep))
p4est_filename = @sprintf("p4est_data_%06d", timestep)
filename = joinpath(output_directory, @sprintf("mesh_%09d.h5", timestep))
p4est_filename = @sprintf("p4est_data_%09d", timestep)
else
filename = joinpath(output_directory, "mesh.h5")
p4est_filename = "p4est_data"
Expand Down Expand Up @@ -191,8 +191,8 @@ function save_mesh_file(mesh::P4estMesh, output_directory, timestep, mpi_paralle

# Determine file name based on existence of meaningful time step
if timestep > 0
filename = joinpath(output_directory, @sprintf("mesh_%06d.h5", timestep))
p4est_filename = @sprintf("p4est_data_%06d", timestep)
filename = joinpath(output_directory, @sprintf("mesh_%09d.h5", timestep))
p4est_filename = @sprintf("p4est_data_%09d", timestep)
else
filename = joinpath(output_directory, "mesh.h5")
p4est_filename = "p4est_data"
Expand Down
2 changes: 1 addition & 1 deletion src/meshes/structured_mesh_view.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function save_mesh_file(mesh::StructuredMeshView, output_directory; system = "",
# Create output directory (if it does not exist)
mkpath(output_directory)

filename = joinpath(output_directory, @sprintf("mesh_%s_%06d.h5", system, timestep))
filename = joinpath(output_directory, @sprintf("mesh_%s_%09d.h5", system, timestep))

# Open file (clobber existing content)
h5open(filename, "w") do file
Expand Down
4 changes: 2 additions & 2 deletions test/test_structured_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ end
linf=[0.0015194252169410394],
rtol=5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS)
elixir_file="elixir_advection_waving_flag.jl",
restart_file="restart_000021.h5",
restart_file="restart_000000021.h5",
# With the default `maxiters = 1` in coverage tests,
# there would be no time steps after the restart.
coverage_override=(maxiters = 100_000,))
Expand All @@ -275,7 +275,7 @@ end
l2=[7.841217436552029e-15],
linf=[1.0857981180834031e-13],
elixir_file="elixir_advection_free_stream.jl",
restart_file="restart_000036.h5",
restart_file="restart_000000036.h5",
# With the default `maxiters = 1` in coverage tests,
# there would be no time steps after the restart.
coverage_override=(maxiters = 100_000,))
Expand Down
2 changes: 1 addition & 1 deletion test/test_threaded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ end
linf=[0.0015194252169410394],
rtol=5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS)
elixir_file="elixir_advection_waving_flag.jl",
restart_file="restart_000021.h5",
restart_file="restart_000000021.h5",
# With the default `maxiters = 1` in coverage tests,
# there would be no time steps after the restart.
coverage_override=(maxiters = 100_000,))
Expand Down
6 changes: 3 additions & 3 deletions test/test_visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ end
tspan = (0.0, 3.0))

@testset "elixir_advection_amr_visualization.jl with save_plot" begin
@test isfile(joinpath(outdir, "solution_000000.png"))
@test isfile(joinpath(outdir, "solution_000020.png"))
@test isfile(joinpath(outdir, "solution_000022.png"))
@test isfile(joinpath(outdir, "solution_000000000.png"))
@test isfile(joinpath(outdir, "solution_000000020.png"))
@test isfile(joinpath(outdir, "solution_000000022.png"))
end

@testset "show" begin
Expand Down
2 changes: 1 addition & 1 deletion utils/plot.gp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set term pdfcairo color enhanced font ",8" fontscale 1.0 lw 0.5 size 14cm,10cm

# Set defaults
if (!exists("infile")) infile="solution_000000.txt"
if (!exists("infile")) infile="solution_000000000.txt"
if (!exists("eqn")) eqn="linear_scalar_advection"
ext = ".pdf"

Expand Down
Loading