diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 420a167c..e35f1886 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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: @@ -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: diff --git a/.github/workflows/Documenter.yml b/.github/workflows/Documenter.yml index 94297d55..c4afc273 100644 --- a/.github/workflows/Documenter.yml +++ b/.github/workflows/Documenter.yml @@ -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: @@ -19,6 +20,7 @@ on: - '.github/workflows/CI.yml' - '.github/workflows/CompatHelper.yml' - '.github/workflows/TagBot.yml' + - '.github/workflows/JET.yml' - 'benchmark/**' workflow_dispatch: diff --git a/.github/workflows/Downgrade.yml b/.github/workflows/Downgrade.yml index d9efbe9c..250b3eb0 100644 --- a/.github/workflows/Downgrade.yml +++ b/.github/workflows/Downgrade.yml @@ -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: diff --git a/.github/workflows/JET.yml b/.github/workflows/JET.yml index 42c9948a..83b32e7e 100644 --- a/.github/workflows/JET.yml +++ b/.github/workflows/JET.yml @@ -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,)) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 8949d35c..83f9346b 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -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 diff --git a/src/callbacks_step/relaxation.jl b/src/callbacks_step/relaxation.jl index e9ec1e85..6a36b33b 100644 --- a/src/callbacks_step/relaxation.jl +++ b/src/callbacks_step/relaxation.jl @@ -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 diff --git a/src/equations/bbm_1d.jl b/src/equations/bbm_1d.jl index d4b2cec0..d9282ea1 100644 --- a/src/equations/bbm_1d.jl +++ b/src/equations/bbm_1d.jl @@ -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 @@ -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) diff --git a/src/equations/bbm_bbm_1d.jl b/src/equations/bbm_bbm_1d.jl index 6a24a5fe..f139e30c 100644 --- a/src/equations/bbm_bbm_1d.jl +++ b/src/equations/bbm_bbm_1d.jl @@ -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 @@ -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 diff --git a/src/equations/serre_green_naghdi_1d.jl b/src/equations/serre_green_naghdi_1d.jl index 6d3e7453..8a96d316 100644 --- a/src/equations/serre_green_naghdi_1d.jl +++ b/src/equations/serre_green_naghdi_1d.jl @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/src/visualization.jl b/src/visualization.jl index 530c158f..62120115 100644 --- a/src/visualization.jl +++ b/src/visualization.jl @@ -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 @@ -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 @@ -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