Skip to content

Commit

Permalink
allow new nine-digit file name format of Trixi.jl v0.8 (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha authored Jul 1, 2024
1 parent 179fca6 commit 7d3a761
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ HDF5 = "0.14, 0.15, 0.16, 0.17"
ProgressMeter = "1.3"
StaticArrays = "0.12, 1.0"
TimerOutputs = "0.5"
Trixi = "0.5, 0.6, 0.7"
Trixi = "0.5, 0.6, 0.7, 0.8"
WriteVTK = "1.7"
julia = "1.7"
2 changes: 2 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
ReadVTK = "dc215faf-f008-4882-a9f7-a79a826fadc3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Trixi = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Documenter = "0.27, 1"
Expand Down
40 changes: 20 additions & 20 deletions test/test_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end

@timed_testset "mesh data" begin
# create the output file to be tested
@test_nowarn trixi2vtk(joinpath(outdir, "mesh_000010.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "mesh_" * LEADING_ZEROS * "000010.h5"), output_directory=outdir)
outfilename = "mesh_000010_celldata.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -38,7 +38,7 @@ end

@timed_testset "solution celldata" begin
# create the output file to be tested
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000010.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000010.h5"), output_directory=outdir)
outfilename = "solution_000010_celldata.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -54,7 +54,7 @@ end

@timed_testset "reinterpolate with nonuniform data with VTU format" begin
# Create and test output with reinterpolation (default options: `reinterpolate=true, data_is_uniform=false`)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000010.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000010.h5"), output_directory=outdir)
outfilename = "solution_000010.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -70,7 +70,7 @@ end

@timed_testset "reinterpolate with nonuniform data with VTI format" begin
# Create and test output with reinterpolation (default options: `reinterpolate=true, data_is_uniform=false`)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000010.h5"), output_directory=outdir, format=:vti)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000010.h5"), output_directory=outdir, format=:vti)
outfilename = "solution_000010.vti"
out_file = joinpath(outdir, outfilename)

Expand All @@ -86,7 +86,7 @@ end

@timed_testset "do not reinterpolate with nonuniform data" begin
# Create and test output without reinterpolation on LGL nodes
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000010.h5"), output_directory=outdir, reinterpolate=false)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000010.h5"), output_directory=outdir, reinterpolate=false)
outfilename = "solution_000010.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -103,7 +103,7 @@ end
@timed_testset "do not reinterpolate with uniform data" begin
# Create and test output without reinterpolation on uniform nodes
# OBS! This is a dummy test just to exercise code. The resulting plot will look weird.
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000010.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000010.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
outfilename = "solution_000010.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -120,7 +120,7 @@ end
@timed_testset "attempt reinterpolate with uniform data" begin
# Purposely request a bad configuration and check that an error message gets thrown
# OBS! Only needs tested once across all mesh types and dimensions
@test_throws ArgumentError trixi2vtk(joinpath(outdir, "solution_000010.h5"), output_directory=outdir, data_is_uniform=true)
@test_throws ArgumentError trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000010.h5"), output_directory=outdir, data_is_uniform=true)
end
end

Expand Down Expand Up @@ -169,7 +169,7 @@ end

@timed_testset "reinterpolate with nonuniform data" begin
# Create and test output with reinterpolation (default options: `reinterpolate=true, data_is_uniform=false`)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir)
outfilename = "solution_000001.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -185,7 +185,7 @@ end

@timed_testset "do not reinterpolate with nonuniform data" begin
# Create and test output without reinterpolation on LGL nodes
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir, reinterpolate=false)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir, reinterpolate=false)
outfilename = "solution_000001.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -202,7 +202,7 @@ end
@timed_testset "do not reinterpolate with uniform data" begin
# Create and test output without reinterpolation on uniform nodes
# OBS! This is a dummy test just to exercise code. The resulting plot will look weird.
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
outfilename = "solution_000001.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -219,7 +219,7 @@ end
@timed_testset "attempt VTI format on unsupported mesh type" begin
# Purposely request a bad configuration and check that an error message gets thrown
# OBS! Only needs tested once across all mesh types and dimensions
@test_throws ArgumentError trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir, format=:vti)
@test_throws ArgumentError trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir, format=:vti)
end
end

Expand All @@ -245,7 +245,7 @@ end

@timed_testset "solution celldata" begin
# create the output file to be tested
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir)
outfilename = "solution_000001_celldata.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -261,7 +261,7 @@ end

@timed_testset "reinterpolate with nonuniform data" begin
# Create and test output with reinterpolation (default options: `reinterpolate=true, data_is_uniform=false`)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir)
outfilename = "solution_000001.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -277,7 +277,7 @@ end

@timed_testset "do not reinterpolate with nonuniform data" begin
# Create and test output without reinterpolation on LGL nodes
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir, reinterpolate=false)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir, reinterpolate=false)
outfilename = "solution_000001.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -294,7 +294,7 @@ end
@timed_testset "do not reinterpolate with uniform data" begin
# Create and test output without reinterpolation on uniform nodes
# OBS! This is a dummy test just to exercise code. The resulting plot will look weird.
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
outfilename = "solution_000001.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -315,7 +315,7 @@ end

@timed_testset "mesh data" begin
# create the output file to be tested
@test_nowarn trixi2vtk(joinpath(outdir, "mesh_000005.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "mesh_" * LEADING_ZEROS * "000005.h5"), output_directory=outdir)
outfilename = "mesh_000005_celldata.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -331,7 +331,7 @@ end

@timed_testset "solution celldata" begin
# create the output file to be tested
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000005.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000005.h5"), output_directory=outdir)
outfilename = "solution_000005_celldata.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -347,7 +347,7 @@ end

@timed_testset "reinterpolate with nonuniform data" begin
# Create and test output with reinterpolation (default options: `reinterpolate=true, data_is_uniform=false`)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000005.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000005.h5"), output_directory=outdir)
outfilename = "solution_000005.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -363,7 +363,7 @@ end

@timed_testset "do not reinterpolate with nonuniform data" begin
# Create and test output without reinterpolation on LGL nodes
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000005.h5"), output_directory=outdir, reinterpolate=false)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000005.h5"), output_directory=outdir, reinterpolate=false)
outfilename = "solution_000005.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -380,7 +380,7 @@ end
@timed_testset "do not reinterpolate with uniform data" begin
# Create and test output without reinterpolation on uniform nodes
# OBS! This is a dummy test just to exercise code. The resulting plot will look weird.
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000005.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000005.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
outfilename = "solution_000005.vtu"
out_file = joinpath(outdir, outfilename)

Expand Down
26 changes: 13 additions & 13 deletions test/test_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end

@timed_testset "mesh data" begin
# create the output file to be tested
@test_nowarn trixi2vtk(joinpath(outdir, "mesh_000004.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "mesh_" * LEADING_ZEROS * "000004.h5"), output_directory=outdir)
outfilename = "mesh_000004_celldata.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -38,7 +38,7 @@ end

@timed_testset "solution celldata" begin
# create the output file to be tested
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000004.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000004.h5"), output_directory=outdir)
outfilename = "solution_000004_celldata.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -54,7 +54,7 @@ end

@timed_testset "reinterpolate with nonuniform data" begin
# Create and test output with reinterpolation (default options: `reinterpolate=true, data_is_uniform=false`)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000004.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000004.h5"), output_directory=outdir)
outfilename = "solution_000004.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -70,7 +70,7 @@ end

@timed_testset "do not reinterpolate with nonuniform data" begin
# Create and test output without reinterpolation on LGL nodes
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000004.h5"), output_directory=outdir, reinterpolate=false)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000004.h5"), output_directory=outdir, reinterpolate=false)
outfilename = "solution_000004.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -87,7 +87,7 @@ end
@timed_testset "do not reinterpolate with uniform data" begin
# Create and test output without reinterpolation on uniform nodes
# OBS! This is a dummy test just to exercise code. The resulting plot will look weird.
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000004.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000004.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
outfilename = "solution_000004.vtu"
out_file = joinpath(outdir, outfilename)

Expand Down Expand Up @@ -127,7 +127,7 @@ end

@timed_testset "solution celldata" begin
# create the output file to be tested
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir)
outfilename = "solution_000001_celldata.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -143,7 +143,7 @@ end

@timed_testset "reinterpolate with nonuniform data" begin
# Create and test output with reinterpolation (default options: `reinterpolate=true, data_is_uniform=false`)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir)
outfilename = "solution_000001.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -159,7 +159,7 @@ end

@timed_testset "do not reinterpolate with nonuniform data" begin
# Create and test output without reinterpolation on LGL nodes
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir, reinterpolate=false)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir, reinterpolate=false)
outfilename = "solution_000001.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -176,7 +176,7 @@ end
@timed_testset "do not reinterpolate with uniform data" begin
# Create and test output without reinterpolation on uniform nodes
# OBS! This is a dummy test just to exercise code. The resulting plot will look weird.
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000001.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000001.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
outfilename = "solution_000001.vtu"
out_file = joinpath(outdir, outfilename)

Expand Down Expand Up @@ -213,7 +213,7 @@ end

@timed_testset "solution celldata" begin
# create the output file to be tested
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000002.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000002.h5"), output_directory=outdir)
outfilename = "solution_000002_celldata.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -229,7 +229,7 @@ end

@timed_testset "reinterpolate with nonuniform data" begin
# Create and test output with reinterpolation (default options: `reinterpolate=true, data_is_uniform=false`)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000002.h5"), output_directory=outdir)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000002.h5"), output_directory=outdir)
outfilename = "solution_000002.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -245,7 +245,7 @@ end

@timed_testset "do not reinterpolate with nonuniform data" begin
# Create and test output without reinterpolation on LGL nodes
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000002.h5"), output_directory=outdir, reinterpolate=false)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000002.h5"), output_directory=outdir, reinterpolate=false)
outfilename = "solution_000002.vtu"
out_file = joinpath(outdir, outfilename)

Expand All @@ -262,7 +262,7 @@ end
@timed_testset "do not reinterpolate with uniform data" begin
# Create and test output without reinterpolation on uniform nodes
# OBS! This is a dummy test just to exercise code. The resulting plot will look weird.
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000002.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000002.h5"), output_directory=outdir, reinterpolate=false, data_is_uniform=true)
outfilename = "solution_000002.vtu"
out_file = joinpath(outdir, outfilename)

Expand Down
6 changes: 3 additions & 3 deletions test/test_manual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ isdir(outdir) && rm(outdir, recursive=true)
end

@testset "unsupported file format" begin
@test_throws ErrorException trixi2vtk(joinpath(outdir, "solution_000000.h5");
@test_throws ErrorException trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000000.h5");
output_directory=outdir,
format=:does_not_exist)
end
Expand All @@ -40,9 +40,9 @@ isdir(outdir) && rm(outdir, recursive=true)
end

@testset "trixi2vtk set number of output nodes" begin
@test_nowarn trixi2vtk(joinpath(outdir, "solution_000000.h5"); nvisnodes=0)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000000.h5"); nvisnodes=0)

@test_nowarn trixi2vtk(joinpath(outdir, "solution_000000.h5"); nvisnodes=5)
@test_nowarn trixi2vtk(joinpath(outdir, "solution_" * LEADING_ZEROS * "000000.h5"); nvisnodes=5)
end

@timed_testset "pvd_filenames" begin
Expand Down
15 changes: 15 additions & 0 deletions test/test_trixi2vtk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ using Trixi2Vtk
using ReadVTK


# Get the version of Trixi.jl we are testing since the output file name
# format changed in v0.8.0
import Pkg
using UUIDs: UUID
const LEADING_ZEROS = let
trixi_uuid = UUID("a7f1ee26-1774-49b1-8366-f1abc58fbfcb")
trixi_version = Pkg.dependencies()[trixi_uuid].version
if trixi_version > v"0.7.999999999"
"000"
else
""
end
end


function run_trixi(elixir; kwargs...)
# evaluate examples in the scope of the module they're called from
trixi_include(@__MODULE__, elixir; kwargs...)
Expand Down

0 comments on commit 7d3a761

Please sign in to comment.