Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
- '.github/workflows/Format-check.yml'
- '.github/workflows/TagBot.yml'
- '.github/workflows/SpellCheck.yml'
- '.github/workflows/JET.yml'
- 'benchmark/**'
- 'docs/**'
pull_request:
Expand All @@ -29,6 +30,7 @@ on:
- '.github/workflows/Format-check.yml'
- '.github/workflows/TagBot.yml'
- '.github/workflows/SpellCheck.yml'
- '.github/workflows/JET.yml'
- 'benchmark/**'
- 'docs/**'
workflow_dispatch:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/Documenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- '.github/workflows/CI.yml'
- '.github/workflows/CompatHelper.yml'
- '.github/workflows/TagBot.yml'
- '.github/workflows/JET.yml'
- 'benchmark/**'
pull_request:
paths-ignore:
Expand All @@ -19,6 +20,7 @@ on:
- '.github/workflows/CI.yml'
- '.github/workflows/CompatHelper.yml'
- '.github/workflows/TagBot.yml'
- '.github/workflows/JET.yml'
- 'benchmark/**'
workflow_dispatch:

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/Downgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
- '.github/workflows/Format-check.yml'
- '.github/workflows/TagBot.yml'
- '.github/workflows/SpellCheck.yml'
- '.github/workflows/JET.yml'
- 'benchmark/**'
- 'docs/**'
workflow_dispatch:
Expand Down
21 changes: 5 additions & 16 deletions .github/workflows/JET.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,13 @@ jobs:
run: |
using Pkg
Pkg.add("JET")
# We need to add Plots.jl to make the definition of `is_attr_supported` available
# Otherwise, JET.jl fails since it is not defined for the keyword arguments in the plot recipes.
Pkg.add("Plots")
Pkg.instantiate()
using JET
import Plots
using DispersiveShallowWater

# JET.jl
# With the default settings as of 2025-05-08, JET.jl
# reports issues originating from RecipesBase.jl.
# The only way to ignore them seems to be something like the
# following hack inspired by the discussion in
# https://github.com/aviatesk/JET.jl/issues/570
struct IgnoreRecipesBase end
function JET.match_module(::IgnoreRecipesBase,
@nospecialize(report::JET.InferenceErrorReport))
s = "MethodInstance for RecipesBase.apply_recipe"
any(report.vst) do vst
occursin(s, string(vst))
end
end
test_package(DispersiveShallowWater;
target_defined_modules = true,
ignored_modules = (IgnoreRecipesBase(),))
target_modules = (DispersiveShallowWater,))
1 change: 1 addition & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- '.github/workflows/Format-check.yml'
- '.github/workflows/TagBot.yml'
- '.github/workflows/SpellCheck.yml'
- '.github/workflows/JET.yml'
- 'docs/**'
permissions:
pull-requests: write # action needs to post a comment
Expand Down
3 changes: 2 additions & 1 deletion src/callbacks_step/relaxation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ end
val2 = relaxation_functional(tmp1, tmp_partitioned, semi) - energy_old

if (val1 * val2) > 0
terminate_integration = true
# terminate if there is no root in [gamma_lo, gamma_hi]
gamma = zero(typeof(tnew))
else
gamma = find_zero(root_closure, (gamma_lo, gamma_hi), AlefeldPotraShi())
end
Expand Down
4 changes: 1 addition & 3 deletions src/equations/bbm_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ end
function rhs!(dq, q, t, mesh, equations::BBMEquation1D, initial_condition,
::BoundaryConditionPeriodic, source_terms, solver, cache)
(; invImD2, eta2, eta2_x, eta_x, etaeta_x, c_0, c_1) = cache
if solver.D1 isa PeriodicUpwindOperators
(; eta_x_upwind) = cache
end

eta, = q.x
deta, = dq.x
Expand All @@ -173,6 +170,7 @@ function rhs!(dq, q, t, mesh, equations::BBMEquation1D, initial_condition,
@.. deta = -(0.75 * c_1 * eta2_x + c_0 * eta_x)
end
elseif solver.D1 isa PeriodicUpwindOperators
(; eta_x_upwind) = cache
mul!(eta2_x, solver.D1.central, eta2)
mul!(eta_x_upwind, solver.D1.minus, eta)
mul!(eta_x, solver.D1.central, eta)
Expand Down
9 changes: 4 additions & 5 deletions src/equations/bbm_bbm_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,6 @@ end
function rhs!(dq, q, t, mesh, equations::BBMBBMEquations1D, initial_condition,
::BoundaryConditionPeriodic, source_terms, solver, cache)
(; etav, Dv, v2, tmp1, tmp2) = cache
if equations.bathymetry_type isa BathymetryFlat
(; invImD2) = cache
else # equations.bathymetry_type isa BathymetryVariable
(; invImDKD, invImD2K) = cache
end

g = gravity(equations)
eta, v, D = q.x
Expand Down Expand Up @@ -466,15 +461,19 @@ function rhs!(dq, q, t, mesh, equations::BBMBBMEquations1D, initial_condition,

@trixi_timeit timer() "solving elliptic system deta" begin
if equations.bathymetry_type isa BathymetryFlat
(; invImD2) = cache
solve_system_matrix!(deta, invImD2, equations)
else # equations.bathymetry_type isa BathymetryVariable
(; invImDKD, invImD2K) = cache
solve_system_matrix!(deta, invImDKD, equations)
end
end
@trixi_timeit timer() "solving elliptic system dv" begin
if equations.bathymetry_type isa BathymetryFlat
(; invImD2) = cache
solve_system_matrix!(dv, invImD2, equations)
else # equations.bathymetry_type isa BathymetryVariable
(; invImDKD, invImD2K) = cache
solve_system_matrix!(dv, invImD2K, equations)
end
end
Expand Down
18 changes: 10 additions & 8 deletions src/equations/serre_green_naghdi_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ function assemble_system_matrix!(cache, h, b_x, D1, D1mat,

if equations.bathymetry_type isa BathymetryMildSlope
factor = 0.75
elseif equations.bathymetry_type isa BathymetryVariable
else # equations.bathymetry_type isa BathymetryVariable
factor = 1.0
end
@.. M_h_p_h_bx2 = h + factor * h * b_x^2
Expand Down Expand Up @@ -748,7 +748,7 @@ function assemble_system_matrix!(cache, h, b_x, D1, D1mat,

if equations.bathymetry_type isa BathymetryMildSlope
factor = 0.75
elseif equations.bathymetry_type isa BathymetryVariable
else # equations.bathymetry_type isa BathymetryVariable
factor = 1.0
end
@.. M_h_p_h_bx2 = h + factor * h * b_x^2
Expand Down Expand Up @@ -1019,9 +1019,6 @@ function rhs_sgn_central!(dq, q, t, equations, source_terms, solver, cache,
# Compute all derivatives required below
(; h, h_x, v_x, h_hpb_x, b, b_x, hv_x, v2_x,
h2_v_vx_x, h_vx_x, p_h, p_x, tmp) = cache
if equations.bathymetry_type isa BathymetryVariable
(; psi) = cache
end

@.. b = equations.eta0 - D
@.. h = eta - b
Expand Down Expand Up @@ -1050,16 +1047,19 @@ function rhs_sgn_central!(dq, q, t, equations, source_terms, solver, cache,
mul!(p_x, D1, tmp)
@.. p_h += 0.25 * p_x
if equations.bathymetry_type isa BathymetryVariable
(; psi) = cache
@.. psi = 0.125 * p_x
end
@.. tmp = b_x * v
mul!(p_x, D1, tmp)
@.. p_h += 0.25 * h * v * p_x
if equations.bathymetry_type isa BathymetryVariable
(; psi) = cache
@.. psi += 0.125 * h * v * p_x
end
@.. p_h = p_h - 0.25 * (h_x * v + h * v_x) * b_x * v
if equations.bathymetry_type isa BathymetryVariable
(; psi) = cache
@.. psi -= 0.125 * (h_x * v + h * v_x) * b_x * v
end
@.. tmp = p_h * h
Expand All @@ -1086,6 +1086,7 @@ function rhs_sgn_central!(dq, q, t, equations, source_terms, solver, cache,
+ p_x
+ 1.5 * p_h * b_x)
if equations.bathymetry_type isa BathymetryVariable
(; psi) = cache
@.. dv = dv - psi * b_x
end
end
Expand Down Expand Up @@ -1134,9 +1135,6 @@ function rhs_sgn_upwind!(dq, q, t, equations, source_terms, solver, cache,
# Compute all derivatives required below
(; h, h_x, v_x, v_x_upwind, h_hpb_x, b, b_x, hv_x, v2_x,
h2_v_vx_x, h_vx_x, p_h, p_0, p_x, tmp) = cache
if equations.bathymetry_type isa BathymetryVariable
(; psi) = cache
end

@.. b = equations.eta0 - D
@.. h = eta - b
Expand Down Expand Up @@ -1165,12 +1163,14 @@ function rhs_sgn_upwind!(dq, q, t, equations, source_terms, solver, cache,
mul!(p_x, D1, tmp)
@.. p_h += 0.25 * p_x
if equations.bathymetry_type isa BathymetryVariable
(; psi) = cache
@.. psi = 0.125 * p_x
end
@.. tmp = b_x * v
mul!(p_x, D1, tmp)
@.. p_h += 0.25 * h * v * p_x
if equations.bathymetry_type isa BathymetryVariable
(; psi) = cache
@.. psi += 0.125 * h * v * p_x
end
@.. p_0 = p_h * h
Expand All @@ -1180,6 +1180,7 @@ function rhs_sgn_upwind!(dq, q, t, equations, source_terms, solver, cache,
-
0.25 * (h_x * v + h * v_x) * b_x * v)
if equations.bathymetry_type isa BathymetryVariable
(; psi) = cache
@.. psi -= 0.125 * (h_x * v + h * v_x) * b_x * v
end
@.. p_h = p_h + tmp
Expand Down Expand Up @@ -1207,6 +1208,7 @@ function rhs_sgn_upwind!(dq, q, t, equations, source_terms, solver, cache,
+ p_x
+ 1.5 * p_h * b_x)
if equations.bathymetry_type isa BathymetryVariable
(; psi) = cache
@.. dv = dv - psi * b_x
end
end
Expand Down
26 changes: 11 additions & 15 deletions src/visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,10 @@ end

initial_condition = semi.initial_condition
t = sol.t[step]

if plot_initial == true
q_exact = compute_coefficients(initial_condition, t, semi)
data_exact = zeros(nvars, nnodes(semi))
end

q = sol.u[step]

data = zeros(nvars, nnodes(semi))
if plot_bathymetry == true
bathy = zeros(nnodes(semi))
end
for j in eachnode(semi)
if plot_bathymetry == true
bathy[j] = bathymetry(get_node_vars(q, equations, j), equations)
end
if plot_initial == true
data_exact[:, j] .= conversion(get_node_vars(q_exact, equations, j), equations)
end
data[:, j] .= conversion(get_node_vars(q, equations, j), equations)
end

Expand All @@ -62,6 +48,12 @@ end

subplot += 1
if plot_initial == true
q_exact = compute_coefficients(initial_condition, t, semi)
data_exact = zeros(nvars, nnodes(semi))
for j in eachnode(semi)
data_exact[:, j] .= conversion(get_node_vars(q_exact, equations, j),
equations)
end
@series begin
subplot --> subplot
linestyle --> :solid
Expand All @@ -82,6 +74,10 @@ end

# Plot the bathymetry
if plot_bathymetry == true
bathy = zeros(nnodes(semi))
for j in eachnode(semi)
bathy[j] = bathymetry(get_node_vars(q, equations, j), equations)
end
@series begin
subplot --> 1
linestyle --> :solid
Expand Down