From 4ee8b6c0b9392177d770e68bd2ca586b400d0ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olav=20M=C3=B8yner?= Date: Thu, 28 Nov 2024 11:02:02 +0100 Subject: [PATCH] Tests + less stringent types in WENO --- Project.toml | 2 +- src/WENO/WENO.jl | 5 +++-- test/runtests.jl | 1 + test/weno.jl | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 test/weno.jl diff --git a/Project.toml b/Project.toml index 27974b77..a2970e48 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Jutul" uuid = "2b460a1a-8a2b-45b2-b125-b5c536396eb9" authors = ["Olav Møyner "] -version = "0.3.1" +version = "0.3.2" [deps] AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c" diff --git a/src/WENO/WENO.jl b/src/WENO/WENO.jl index 63e87807..44d5564b 100644 --- a/src/WENO/WENO.jl +++ b/src/WENO/WENO.jl @@ -103,7 +103,7 @@ module WENO new_grad += grad[i]*V[i] end if all(isfinite, new_grad) - area = area_from_points(points) + area = area_from_points(points, D) else area = Inf end @@ -141,7 +141,8 @@ module WENO return WENOHalfFaceDiscretization(cell, V, vec(grad_disc)) end - function area_from_points(points::NTuple{N, SVector{D, Float64}}) where {N, D} + function area_from_points(points, D) + N = length(points) if D == 2 @assert N == 3 u, v, w = points diff --git a/test/runtests.jl b/test/runtests.jl index d02ac912..29654866 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,3 +9,4 @@ include("partitioning.jl") include("units.jl") include("sparsity.jl") include("nfvm.jl") +include("weno.jl") diff --git a/test/weno.jl b/test/weno.jl new file mode 100644 index 00000000..e585554a --- /dev/null +++ b/test/weno.jl @@ -0,0 +1,33 @@ +using Jutul, Test +@testset "WENO setup" begin + mesh_2d = UnstructuredMesh(CartesianMesh((3, 3))) + @testset "2D" begin + call = Jutul.WENO.weno_discretize_cells(DataDomain(mesh_2d)) + ix = 5 + c = call[ix] + pset = c.planar_set + cells = map(x -> x.cell, c.stencil) + + @test length(pset) == 4 + for quad in pset + @test length(quad) == 3 + i, j, k = quad + @test cells[i] == ix + # Neighbor set in 2D should TPFA pairs of 2, 4, 6, 8 + c1 = cells[j] + c2 = cells[k] + if c1 > c2 + c2, c1 = c1, c2 + end + @test (c1, c2) in [(2, 4), (4, 8), (6, 8), (2, 6)] + end + end + mesh_3d = UnstructuredMesh(CartesianMesh((3, 3, 3))) + + w2d = Jutul.WENO.weno_discretize(DataDomain(mesh_2d)) + @test length(w2d) == number_of_faces(mesh_2d) + @test eltype(w2d) == Jutul.WENO.WENOFaceDiscretization{2, 3, Float64} + w3d = Jutul.WENO.weno_discretize(DataDomain(mesh_3d)) + @test length(w3d) == number_of_faces(mesh_3d) + @test eltype(w3d) == Jutul.WENO.WENOFaceDiscretization{3, 4, Float64} +end