From e475d430c3d491fd384cb207d5089a074e15bc67 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Mon, 1 Jul 2024 15:42:53 +0200 Subject: [PATCH] allow new nine-digit file name format of Trixi.jl v0.8 --- Project.toml | 2 +- test/Project.toml | 2 ++ test/test_2d.jl | 40 ++++++++++++++++++++-------------------- test/test_3d.jl | 26 +++++++++++++------------- test/test_manual.jl | 6 +++--- test/test_trixi2vtk.jl | 15 +++++++++++++++ 6 files changed, 54 insertions(+), 37 deletions(-) diff --git a/Project.toml b/Project.toml index f4a6db2..5548107 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/test/Project.toml b/test/Project.toml index 5d5e50e..94567f6 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -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" diff --git a/test/test_2d.jl b/test/test_2d.jl index d752644..93bf176 100644 --- a/test/test_2d.jl +++ b/test/test_2d.jl @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 @@ -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) @@ -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) @@ -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) @@ -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 @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/test/test_3d.jl b/test/test_3d.jl index e7217a8..99e65a0 100644 --- a/test/test_3d.jl +++ b/test/test_3d.jl @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/test/test_manual.jl b/test/test_manual.jl index a051ee4..79f1d03 100644 --- a/test/test_manual.jl +++ b/test/test_manual.jl @@ -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 @@ -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 diff --git a/test/test_trixi2vtk.jl b/test/test_trixi2vtk.jl index 15e59ad..79958bb 100644 --- a/test/test_trixi2vtk.jl +++ b/test/test_trixi2vtk.jl @@ -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...)