Skip to content

Commit

Permalink
Tests + less stringent types in WENO
Browse files Browse the repository at this point in the history
  • Loading branch information
moyner committed Nov 28, 2024
1 parent bf2b0f8 commit 4ee8b6c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Jutul"
uuid = "2b460a1a-8a2b-45b2-b125-b5c536396eb9"
authors = ["Olav Møyner <olav.moyner@gmail.com>"]
version = "0.3.1"
version = "0.3.2"

[deps]
AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c"
Expand Down
5 changes: 3 additions & 2 deletions src/WENO/WENO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ include("partitioning.jl")
include("units.jl")
include("sparsity.jl")
include("nfvm.jl")
include("weno.jl")
33 changes: 33 additions & 0 deletions test/weno.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4ee8b6c

Please sign in to comment.