Skip to content
3 changes: 3 additions & 0 deletions .github/workflows/Downgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ jobs:
uses: "SciML/.github/.github/workflows/downgrade.yml@v1"
with:
julia-version: "lts"
# SciMLTesting resolves test/Plotting's sub-env to latest versions in the same
# process that already loaded Core's floor SciMLBase, so only Core is floor-tested.
group: "Core"
secrets: "inherit"
4 changes: 2 additions & 2 deletions src/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ end
jacobian_sparsity(prob::FVMProblem) = jacobian_sparsity(prob.geometry.mesh_points)
function jacobian_sparsity(pts)
num_nnz = 3(length(pts) - 2) + 4 # 3 neighbours for each interior node, 2 from each boundary node
I = zeros(Int64, num_nnz)
J = zeros(Int64, num_nnz)
I = zeros(Int, num_nnz)
J = zeros(Int, num_nnz)
V = ones(num_nnz)
# The left boundary node
I[1] = firstindex(pts)
Expand Down
32 changes: 32 additions & 0 deletions test/Plotting/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
FiniteVolumeMethod1D = "cfdabe9e-7cc8-40e3-9725-d80209c3e763"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
MethodOfLines = "94925ecb-adb7-4558-8ed8-f975c56a0bf4"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
OrdinaryDiffEqSDIRK = "2d112036-d095-4a1e-ab9a-08536f3ecdbf"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
CairoMakie = "0.15.12"
DomainSets = "0.8.1"
LinearSolve = "3.87, 4.2.0, 5.1"
MethodOfLines = "0.11.13"
ModelingToolkit = "11.31.0"
NonlinearSolve = "4.17.1, 4.20.2"
OrdinaryDiffEq = "6.56, 7.1.1"
OrdinaryDiffEqSDIRK = "1.14, 2.7.1"
ReferenceTests = "0.10.6"
SafeTestsets = "0.0.1, 0.1"
SciMLTesting = "2.4"
SpecialFunctions = "2.8.0"
Test = "1"
julia = "1.10"
13 changes: 13 additions & 0 deletions test/Plotting/dirichlet_source.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CairoMakie
using ReferenceTests
include(joinpath(@__DIR__, "..", "dirichlet_source.jl"))

let t_range = LinRange(0.0, final_time, 250)
fig = Figure(fontsize = 33)
ax = Axis3(fig[1, 1], xlabel = L"x", ylabel = L"t", zlabel = L"z", azimuth = 0.8)
sol_u = [sol(t) for t in t_range]
surface!(ax, mesh_points, t_range, reduce(hcat, sol_u), colormap = :viridis)
fig_path = normpath(@__DIR__, "..", "..", "docs", "src", "figures")
@test_reference joinpath(fig_path, "dirichlet_source_surface.png") fig
fig
end
13 changes: 13 additions & 0 deletions test/Plotting/heat.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CairoMakie
using ReferenceTests
include(joinpath(@__DIR__, "..", "heat.jl"))

let t_range = LinRange(0.0, final_time, 250)
fig = Figure(fontsize = 33)
ax = Axis(fig[1, 1], xlabel = L"x", ylabel = L"t")
sol_u = [sol(t) for t in t_range]
contourf!(ax, mesh_points, t_range, reduce(hcat, sol_u), colormap = :viridis)
fig_path = normpath(@__DIR__, "..", "..", "docs", "src", "figures")
@test_reference joinpath(fig_path, "heat_contour.png") fig
fig
end
46 changes: 46 additions & 0 deletions test/Plotting/porous_medium.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using CairoMakie
using ReferenceTests
include(joinpath(@__DIR__, "..", "porous_medium.jl"))

fig = Figure(size = (2150, 460), fontsize = 34)
ax = Axis(
fig[1, 1], xlabel = L"x", ylabel = L"u(x)", title = L"(a):$ $ Numerical solution",
titlealign = :left, width = 600, height = 300
)
colors = [:red, :black, :blue, :darkgreen, :magenta, :orange]
[lines!(ax, mesh_points, sol.u[i], color = colors[i]) for i in eachindex(sol.t)]
ylims!(ax, -1.0e-6, 5)
xlims!(ax, -1, 1)
ax = Axis(
fig[1, 2], xlabel = L"x", ylabel = L"u(x)", title = L"(b):$ $ Exact solution",
titlealign = :left, width = 600, height = 300
)
[lines!(ax, mesh_points, exact[i], color = colors[i]) for i in eachindex(sol.t)]
ylims!(ax, -1.0e-6, 5)
xlims!(ax, -1, 1)
ax = Axis(
fig[1, 3], xlabel = L"x", ylabel = L"u(x)", title = L"(c):$ $ Error",
titlealign = :left, width = 600, height = 300
)
[
lines!(ax, mesh_points, abs.(exact[i] .- sol.u[i]), color = colors[i])
for i in eachindex(sol.t)
]
ylims!(ax, -1.0e-6, 0.5)
xlims!(ax, -1, 1)
fig_path = normpath(@__DIR__, "..", "figures")
@test_reference joinpath(fig_path, "porous_comparison.png") fig

let t_range = LinRange(0.0, final_time, 250)
fig = Figure(fontsize = 33)
ax = Axis3(fig[1, 1], xlabel = L"x", ylabel = L"t", zlabel = L"z")
sol_u = [sol(t) for t in t_range]
in_int_range = findall(x -> abs(x) < 1, mesh_points) # Makie won't clip the plot to (-1, 1)
surface!(
ax, mesh_points[in_int_range], t_range,
reduce(hcat, sol_u)[in_int_range, :], colormap = :viridis
)
xlims!(ax, -1, 1)
fig_path = normpath(@__DIR__, "..", "..", "docs", "src", "figures")
@test_reference joinpath(fig_path, "porous_surface.png") fig
end
12 changes: 12 additions & 0 deletions test/Plotting/robin_diffusion.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using CairoMakie
using ReferenceTests
include(joinpath(@__DIR__, "..", "robin_diffusion.jl"))

let t_range = LinRange(0.0, final_time, 250)
fig = Figure(fontsize = 33)
ax = Axis3(fig[1, 1], xlabel = L"x", ylabel = L"t", zlabel = L"z", azimuth = 0.8)
sol_u = [sol(t) for t in t_range]
surface!(ax, mesh_points, t_range, reduce(hcat, sol_u), colormap = :viridis)
fig_path = normpath(@__DIR__, "..", "..", "docs", "src", "figures")
@test_reference joinpath(fig_path, "robin_diffusion_surface.png") fig
end
10 changes: 0 additions & 10 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
[deps]
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
MethodOfLines = "94925ecb-adb7-4558-8ed8-f975c56a0bf4"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
OrdinaryDiffEqSDIRK = "2d112036-d095-4a1e-ab9a-08536f3ecdbf"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Expand All @@ -17,15 +12,10 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
CairoMakie = "0.15.12"
DomainSets = "0.8.1"
LinearSolve = "3.87, 4.2.0, 5.1"
MethodOfLines = "0.11.13"
ModelingToolkit = "11.31.0"
NonlinearSolve = "4.17.1, 4.20.2"
OrdinaryDiffEq = "6.56, 7.1.1"
OrdinaryDiffEqSDIRK = "1.14, 2.7.1"
ReferenceTests = "0.10.6"
SafeTestsets = "0.0.1, 0.1"
SciMLBase = "3.18"
SciMLTesting = "2.4"
Expand Down
12 changes: 0 additions & 12 deletions test/dirichlet_source.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ using LinearAlgebra
using LinearSolve
using OrdinaryDiffEq
using OrdinaryDiffEqSDIRK
using CairoMakie
using ReferenceTests

# p. 145 Constanda
# uₜ = uₓₓ + π²exp[-24π²t]sin(5πx), 0 < x < 1
Expand Down Expand Up @@ -39,13 +37,3 @@ sol = solve(
)
exact_sol = [exact_u.(mesh_points, sol.t[i]) for i in eachindex(sol.t)]
@test reduce(hcat, sol.u) ≈ reduce(hcat, exact_sol) rtol = 1.0e-1

let t_range = LinRange(0.0, final_time, 250)
fig = Figure(fontsize = 33)
ax = Axis3(fig[1, 1], xlabel = L"x", ylabel = L"t", zlabel = L"z", azimuth = 0.8)
sol_u = [sol(t) for t in t_range]
surface!(ax, mesh_points, t_range, reduce(hcat, sol_u), colormap = :viridis)
fig_path = normpath(@__DIR__, "..", "docs", "src", "figures")
@test_reference joinpath(fig_path, "dirichlet_source_surface.png") fig
fig
end
12 changes: 0 additions & 12 deletions test/heat.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using FiniteVolumeMethod1D
using OrdinaryDiffEq
using OrdinaryDiffEqSDIRK
using ReferenceTests
using CairoMakie
using LinearSolve

function exact2(x, t)
Expand Down Expand Up @@ -30,13 +28,3 @@ prob = FVMProblem(
sol = solve(prob, TRBDF2(linsolve = KLUFactorization()))
exact_sol = [exact2.(mesh_points, sol.t[i]) for i in eachindex(sol.t)]
@test reduce(hcat, sol.u) ≈ reduce(hcat, exact_sol) rtol = 1.0e-2

let t_range = LinRange(0.0, final_time, 250)
fig = Figure(fontsize = 33)
ax = Axis(fig[1, 1], xlabel = L"x", ylabel = L"t")
sol_u = [sol(t) for t in t_range]
contourf!(ax, mesh_points, t_range, reduce(hcat, sol_u), colormap = :viridis)
fig_path = normpath(@__DIR__, "..", "docs", "src", "figures")
@test_reference joinpath(fig_path, "heat_contour.png") fig
fig
end
1 change: 1 addition & 0 deletions test/ode_problem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ prob = FVMProblem(;
)
J = FVM.jacobian_sparsity(prob)
@test J == FVM.jacobian_sparsity(mesh_points)
@test J isa SparseMatrixCSC{Float64, Int}
_J = zeros(length(mesh_points), length(mesh_points))
for i in eachindex(mesh_points)
if i == 1
Expand Down
45 changes: 0 additions & 45 deletions test/porous_medium.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using FiniteVolumeMethod1D
using OrdinaryDiffEq
using OrdinaryDiffEqSDIRK
using CairoMakie
using ReferenceTests
using SpecialFunctions
FVM = FiniteVolumeMethod1D

Expand Down Expand Up @@ -45,46 +43,3 @@ prob = FVMProblem(
sol = solve(prob, TRBDF2(); saveat = saveat)
exact = [exact_solution.(mesh_points, sol.t[i]) for i in eachindex(sol.t)]
@test exact ≈ sol.u rtol = 1.0e-1

fig = Figure(size = (2150, 460), fontsize = 34)
ax = Axis(
fig[1, 1], xlabel = L"x", ylabel = L"u(x)", title = L"(a):$ $ Numerical solution",
titlealign = :left, width = 600, height = 300
)
colors = [:red, :black, :blue, :darkgreen, :magenta, :orange]
[lines!(ax, mesh_points, sol.u[i], color = colors[i]) for i in eachindex(sol.t)]
ylims!(ax, -1.0e-6, 5)
xlims!(ax, -1, 1)
ax = Axis(
fig[1, 2], xlabel = L"x", ylabel = L"u(x)", title = L"(b):$ $ Exact solution",
titlealign = :left, width = 600, height = 300
)
[lines!(ax, mesh_points, exact[i], color = colors[i]) for i in eachindex(sol.t)]
ylims!(ax, -1.0e-6, 5)
xlims!(ax, -1, 1)
ax = Axis(
fig[1, 3], xlabel = L"x", ylabel = L"u(x)", title = L"(c):$ $ Error",
titlealign = :left, width = 600, height = 300
)
[
lines!(ax, mesh_points, abs.(exact[i] .- sol.u[i]), color = colors[i])
for i in eachindex(sol.t)
]
ylims!(ax, -1.0e-6, 0.5)
xlims!(ax, -1, 1)
fig_path = normpath(@__DIR__, "..", "test", "figures")
@test_reference joinpath(fig_path, "porous_comparison.png") fig

let t_range = LinRange(0.0, final_time, 250)
fig = Figure(fontsize = 33)
ax = Axis3(fig[1, 1], xlabel = L"x", ylabel = L"t", zlabel = L"z")
sol_u = [sol(t) for t in t_range]
in_int_range = findall(x -> abs(x) < 1, mesh_points) # Makie won't clip the plot to (-1, 1)
surface!(
ax, mesh_points[in_int_range], t_range,
reduce(hcat, sol_u)[in_int_range, :], colormap = :viridis
)
xlims!(ax, -1, 1)
fig_path = normpath(@__DIR__, "..", "docs", "src", "figures")
@test_reference joinpath(fig_path, "porous_surface.png") fig
end
11 changes: 0 additions & 11 deletions test/robin_diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ using LinearSolve
using OrdinaryDiffEq
using OrdinaryDiffEqSDIRK
using NonlinearSolve
using CairoMakie
using ReferenceTests

# uₜ = (1/25)uₓₓ
# u(0, t) = 0
Expand Down Expand Up @@ -52,12 +50,3 @@ sol = solve(prob, TRBDF2(linsolve = KLUFactorization()), saveat = 0.01)
μ = compute_μₙ.(1:100)
exact_sol = [exact_u.(mesh_points, sol.t[i], Ref(μ)) for i in eachindex(sol.t)]
@test reduce(hcat, sol.u) ≈ reduce(hcat, exact_sol) rtol = 1.0e-2

let t_range = LinRange(0.0, final_time, 250)
fig = Figure(fontsize = 33)
ax = Axis3(fig[1, 1], xlabel = L"x", ylabel = L"t", zlabel = L"z", azimuth = 0.8)
sol_u = [sol(t) for t in t_range]
surface!(ax, mesh_points, t_range, reduce(hcat, sol_u), colormap = :viridis)
fig_path = normpath(@__DIR__, "..", "docs", "src", "figures")
@test_reference joinpath(fig_path, "robin_diffusion_surface.png") fig
end
3 changes: 3 additions & 0 deletions test/test_groups.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ versions = ["1"]
os = ["ubuntu-latest"]
arch = "x86"

[Plotting]
versions = ["lts", "1", "pre"]

[QA]
versions = ["lts", "1"]
Loading