Skip to content

Commit

Permalink
test upwind operators by creating a new ode explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaLampert committed May 19, 2024
1 parent 7558b4e commit 05d607f
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions test/test_bbm_bbm_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,34 @@ EXAMPLES_DIR = joinpath(examples_dir(), "bbm_bbm_1d")
change_velocity=-5.684341886080801e-13,
change_entropy=0.00019552914864107152,
atol_ints=1e-10) # in order to make CI pass

# test upwind operators
using SummationByPartsOperators: upwind_operators, periodic_derivative_operator
using SparseArrays: sparse
using OrdinaryDiffEq: solve
D1 = upwind_operators(periodic_derivative_operator; derivative_order = 1,
accuracy_order = accuracy_order, xmin = mesh.xmin, xmax = mesh.xmax,
N = mesh.N)
D2 = sparse(D1.plus) * sparse(D1.minus)
solver = Solver(D1, D2)
semi = Semidiscretization(mesh, equations, initial_condition, solver,
boundary_conditions = boundary_conditions)
ode = semidiscretize(semi, (0.0, 1.0))
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7,
save_everystep = false, callback = callbacks, saveat = saveat)
atol = 1e-12
rtol = 1e-12
errs = errors(analysis_callback)
l2 = [0.0024468371799030923 0.004954294234265212]
l2_measured = errs.l2_error[:, end]
for (l2_expected, l2_actual) in zip(l2, l2_measured)
@test isapprox(l2_expected, l2_actual, atol = atol, rtol = rtol)
end
linf = [0.002095653257311536 0.002611037468199129]
linf_measured = errs.linf_error[:, end]
for (linf_expected, linf_actual) in zip(linf, linf_measured)
@test isapprox(linf_expected, linf_actual, atol = atol, rtol = rtol)
end
end

@trixi_testset "bbm_bbm_1d_dg" begin
Expand All @@ -31,33 +59,6 @@ EXAMPLES_DIR = joinpath(examples_dir(), "bbm_bbm_1d")
change_entropy=-0.021843627302246205)
end

@trixi_testset "bbm_bbm_1d_dg (central upwind)" begin
using SummationByPartsOperators: upwind_operators, periodic_derivative_operator
@test_trixi_include(joinpath(EXAMPLES_DIR, "bbm_bbm_1d_dg.jl"),
tspan=(0.0, 1.0),
D1=upwind_operators(periodic_derivative_operator;
derivative_order = 1,
accuracy_order = 4, xmin = -35.0,
xmax = 35.0,
N = 512),
D_pl=upwind_operators(periodic_derivative_operator;
derivative_order = 1,
accuracy_order = 4, xmin = -35.0,
xmax = 35.0,
N = 512).plus,
D_min=upwind_operators(periodic_derivative_operator;
derivative_order = 1,
accuracy_order = 4, xmin = -35.0,
xmax = 35.0,
N = 512).minus,
l2=[0.007085629990523023 0.0051028439138702366],
linf=[0.009028336927360048 0.003957954184665269],
cons_error=[1.803286289420118e-15 7.105427357601002e-15],
change_waterheight=-1.803286289420118e-15,
change_velocity=-7.105427357601002e-15,
change_entropy=1.8964752364070137e-6)
end

@trixi_testset "bbm_bbm_1d_relaxation" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "bbm_bbm_1d_relaxation.jl"),
tspan=(0.0, 1.0),
Expand Down

0 comments on commit 05d607f

Please sign in to comment.