Skip to content

Commit

Permalink
format test
Browse files Browse the repository at this point in the history
  • Loading branch information
ranocha committed Oct 24, 2023
1 parent 9303956 commit 526611d
Show file tree
Hide file tree
Showing 66 changed files with 14,717 additions and 10,408 deletions.
48 changes: 24 additions & 24 deletions test/coverage/coverage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ const lcov_info_file = "lcov.info"

# Change path to root directory
cd(joinpath(@__DIR__, "..", "..")) do
# Process coverage files
processed = process_folder("src")

# Uncomment the following line once Codecov support is enabled
# Codecov.submit_local(processed)

# Calculate coverage
covered_lines, total_lines = get_summary(processed)
percentage = covered_lines / total_lines * 100

# Print coverage in a format that can be easily parsed
println("($(percentage)%) covered")

# Try to generate a coverage report
isdir(report_dir) || mkdir(report_dir)
tracefile = joinpath(report_dir, lcov_info_file)
Coverage.LCOV.writefile(tracefile, processed)
branch = strip(read(`git rev-parse --abbrev-ref HEAD`, String))
commit = strip(read(`git rev-parse --short HEAD`, String))
title = "commit $(commit) on branch $(branch)"
run(`genhtml -t $(title) -o $(report_dir) $(tracefile)`)

# Clean up .cov files
clean_folder("src")
# Process coverage files
processed = process_folder("src")

# Uncomment the following line once Codecov support is enabled
# Codecov.submit_local(processed)

# Calculate coverage
covered_lines, total_lines = get_summary(processed)
percentage = covered_lines / total_lines * 100

# Print coverage in a format that can be easily parsed
println("($(percentage)%) covered")

# Try to generate a coverage report
isdir(report_dir) || mkdir(report_dir)
tracefile = joinpath(report_dir, lcov_info_file)
Coverage.LCOV.writefile(tracefile, processed)
branch = strip(read(`git rev-parse --abbrev-ref HEAD`, String))
commit = strip(read(`git rev-parse --short HEAD`, String))
title = "commit $(commit) on branch $(branch)"
run(`genhtml -t $(title) -o $(report_dir) $(tracefile)`)

# Clean up .cov files
clean_folder("src")
end
2 changes: 1 addition & 1 deletion test/test_aqua.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ include("test_trixi.jl")
# exceptions necessary for adding a new method `StartUpDG.estimate_h`
# in src/solvers/dgmulti/sbp.jl
piracy = (treat_as_own = [Trixi.StartUpDG.RefElemData,
Trixi.StartUpDG.MeshData],))
Trixi.StartUpDG.MeshData],))
end

end #module
241 changes: 137 additions & 104 deletions test/test_dgmulti_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,126 +9,159 @@ EXAMPLES_DIR = joinpath(examples_dir(), "dgmulti_1d")

# Start with a clean environment: remove Trixi.jl output directory if it exists
outdir = "out"
isdir(outdir) && rm(outdir, recursive=true)
isdir(outdir) && rm(outdir, recursive = true)

@testset "DGMulti 1D" begin

@trixi_testset "elixir_advection_gauss_sbp.jl " begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_gauss_sbp.jl"),
cells_per_dimension = (8,),
l2 = [2.9953644500009865e-5],
linf = [4.467840577382365e-5]
)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
@trixi_testset "elixir_advection_gauss_sbp.jl " begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_gauss_sbp.jl"),
cells_per_dimension=(8,),
l2=[2.9953644500009865e-5],
linf=[4.467840577382365e-5])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
end

@trixi_testset "elixir_euler_flux_diff.jl " begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"),
cells_per_dimension = (16,),
# division by sqrt(2.0) corresponds to normalization by the square root of the size of the domain
l2 = [7.853842541289665e-7, 9.609905503440606e-7, 2.832322219966481e-6] ./ sqrt(2.0),
linf = [1.5003758788711963e-6, 1.802998748523521e-6, 4.83599270806323e-6]
)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
@trixi_testset "elixir_euler_flux_diff.jl " begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"),
cells_per_dimension=(16,),
# division by sqrt(2.0) corresponds to normalization by the square root of the size of the domain
l2=[
7.853842541289665e-7,
9.609905503440606e-7,
2.832322219966481e-6,
] ./ sqrt(2.0),
linf=[
1.5003758788711963e-6,
1.802998748523521e-6,
4.83599270806323e-6,
])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
end

@trixi_testset "elixir_euler_flux_diff.jl (convergence)" begin
mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), 3)
@test isapprox(mean_convergence[:l2], [4.1558759698638434, 3.977911306037128, 4.041421206468769], rtol=0.05)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
@trixi_testset "elixir_euler_flux_diff.jl (convergence)" begin
mean_convergence = convergence_test(@__MODULE__,
joinpath(EXAMPLES_DIR,
"elixir_euler_flux_diff.jl"), 3)
@test isapprox(mean_convergence[:l2],
[4.1558759698638434, 3.977911306037128, 4.041421206468769],
rtol = 0.05)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
end

@trixi_testset "elixir_euler_flux_diff.jl (SBP) " begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"),
cells_per_dimension = (16,),
approximation_type = SBP(),
l2 = [6.437827414849647e-6, 2.1840558851820947e-6, 1.3245669629438228e-5],
linf = [2.0715843751295537e-5, 8.519520630301258e-6, 4.2642194098885255e-5]
)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
@trixi_testset "elixir_euler_flux_diff.jl (SBP) " begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"),
cells_per_dimension=(16,),
approximation_type=SBP(),
l2=[
6.437827414849647e-6,
2.1840558851820947e-6,
1.3245669629438228e-5,
],
linf=[
2.0715843751295537e-5,
8.519520630301258e-6,
4.2642194098885255e-5,
])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
end

@trixi_testset "elixir_euler_flux_diff.jl (FD SBP)" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"),
cells_per_dimension = (4,),
approximation_type = derivative_operator(
SummationByPartsOperators.MattssonNordström2004(),
derivative_order=1, accuracy_order=4,
xmin=0.0, xmax=1.0, N=16),
l2 = [1.8684509287853788e-5, 1.0641411823379635e-5, 5.178010291876143e-5],
linf = [6.933493585936645e-5, 3.0277366229292113e-5, 0.0002220020568932668]
)
show(stdout, semi.solver.basis)
show(stdout, MIME"text/plain"(), semi.solver.basis)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
@trixi_testset "elixir_euler_flux_diff.jl (FD SBP)" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"),
cells_per_dimension=(4,),
approximation_type=derivative_operator(SummationByPartsOperators.MattssonNordström2004(),
derivative_order = 1,
accuracy_order = 4,
xmin = 0.0, xmax = 1.0,
N = 16),
l2=[
1.8684509287853788e-5,
1.0641411823379635e-5,
5.178010291876143e-5,
],
linf=[
6.933493585936645e-5,
3.0277366229292113e-5,
0.0002220020568932668,
])
show(stdout, semi.solver.basis)
show(stdout, MIME"text/plain"(), semi.solver.basis)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
end

@trixi_testset "elixir_euler_fdsbp_periodic.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"),
l2 = [9.146929180585711e-7, 1.8997616878017292e-6, 3.991417702211889e-6],
linf = [1.7321089884614338e-6, 3.3252888855805907e-6, 6.5252787737613005e-6]
)
show(stdout, semi.solver.basis)
show(stdout, MIME"text/plain"(), semi.solver.basis)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
@trixi_testset "elixir_euler_fdsbp_periodic.jl" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"),
l2=[
9.146929180585711e-7,
1.8997616878017292e-6,
3.991417702211889e-6,
],
linf=[
1.7321089884614338e-6,
3.3252888855805907e-6,
6.5252787737613005e-6,
])
show(stdout, semi.solver.basis)
show(stdout, MIME"text/plain"(), semi.solver.basis)
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
end

@trixi_testset "DGMulti with periodic SBP unit test" begin
# see https://github.com/trixi-framework/Trixi.jl/pull/1013
dg = DGMulti(element_type = Line(),
approximation_type = periodic_derivative_operator(
derivative_order=1, accuracy_order=4, xmin=-5.0, xmax=10.0, N=50))
mesh = DGMultiMesh(dg)
@test mapreduce(isapprox, &, mesh.md.xyz, dg.basis.rst)
# check to make sure nodes are rescaled to [-1, 1]
@test minimum(dg.basis.rst[1]) -1
@test maximum(dg.basis.rst[1]) 1 atol=0.35
end
@trixi_testset "DGMulti with periodic SBP unit test" begin
# see https://github.com/trixi-framework/Trixi.jl/pull/1013
dg = DGMulti(element_type = Line(),
approximation_type = periodic_derivative_operator(derivative_order = 1,
accuracy_order = 4,
xmin = -5.0,
xmax = 10.0, N = 50))
mesh = DGMultiMesh(dg)
@test mapreduce(isapprox, &, mesh.md.xyz, dg.basis.rst)
# check to make sure nodes are rescaled to [-1, 1]
@test minimum(dg.basis.rst[1]) -1
@test maximum(dg.basis.rst[1])1 atol=0.35
end
end

# Clean up afterwards: delete Trixi.jl output directory
@test_nowarn isdir(outdir) && rm(outdir, recursive=true)
@test_nowarn isdir(outdir) && rm(outdir, recursive = true)

end # module
Loading

0 comments on commit 526611d

Please sign in to comment.