Skip to content

Add Hyperbolic Sainte-Marie Equations 1D#135

Open
MarcoArtiano wants to merge 52 commits into
mainfrom
ma/hyperbolized_sainte_marie
Open

Add Hyperbolic Sainte-Marie Equations 1D#135
MarcoArtiano wants to merge 52 commits into
mainfrom
ma/hyperbolized_sainte_marie

Conversation

@MarcoArtiano

@MarcoArtiano MarcoArtiano commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

The entropy conserving and well-balanced scheme is derived in https://arxiv.org/abs/2603.18978.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

JuliaFormatter

[JuliaFormatter] reported by reviewdog 🐶

f2_fluxdiff = alpha_1 * equations.gravity * h_avg * b_jump + alpha_2 * 2 * p_avg * b_jump
f2_pointwise = (1 - alpha_1) * equations.gravity * h_ll * b_jump + (1 - alpha_2) * 2 * p_ll * b_jump


[JuliaFormatter] reported by reviewdog 🐶

f4_fluxdiff = alpha_3 * equations.celerity^2 * h_avg * v_jump - 2 * alpha_2 * equations.celerity^2 * v_avg * b_jump
f4_pointwise = (1 - alpha_3) * equations.celerity^2 * h_ll * v_jump - 2 * (1 - alpha_2) * equations.celerity^2 * v_ll * b_jump


[JuliaFormatter] reported by reviewdog 🐶

f2,
f3,
f4,
zero(eltype(u_ll)))


[JuliaFormatter] reported by reviewdog 🐶

equations::HyperbolicSainteMarieEquations1D)


[JuliaFormatter] reported by reviewdog 🐶


[JuliaFormatter] reported by reviewdog 🐶

e = (h_v^2 + h_w^2) / (2 * h) + h_p^2 / (2 * equations.celerity^2 * h) + 0.5f0 * equations.gravity * h^2 + equations.gravity * h * b


[JuliaFormatter] reported by reviewdog 🐶

@inline function Trixi.lake_at_rest_error(u, equations::HyperbolicSainteMarieEquations1D)


[JuliaFormatter] reported by reviewdog 🐶

@codecov

codecov Bot commented Mar 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.16%. Comparing base (b2f176a) to head (00072d6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #135      +/-   ##
==========================================
+ Coverage   99.14%   99.16%   +0.03%     
==========================================
  Files         105      107       +2     
  Lines        5565     5746     +181     
==========================================
+ Hits         5517     5698     +181     
  Misses         48       48              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MarcoArtiano MarcoArtiano marked this pull request as ready for review March 29, 2026 12:40

@ranocha ranocha left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

Comment thread test/test_tree_1d.jl Outdated
Comment thread src/equations/hyperbolic_sainte_marie_1d.jl Outdated
Comment thread src/equations/hyperbolic_sainte_marie_1d.jl
Comment on lines +69 to +76
function HyperbolicSainteMarieEquations1D(; gravity, H0 = zero(gravity),
b0 = one(gravity), alpha = 3,
threshold_limiter = nothing)
T = promote_type(typeof(gravity), typeof(H0), typeof(b0), typeof(alpha))
if threshold_limiter === nothing
threshold_limiter = 500 * eps(T)
end
celerity = alpha * sqrt(gravity * b0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not use b0 to determine the hyperbolization parameter, since Escalante et al. use a reference water height h_0 (and the exact value of the bathymetry b can be changed arbitrarily by moving everything in the vertical direction).

H0 should also not be used since it is a reference for the surface elevation h + b, correct? Maybe we need to introduce another argument, h0, although this can be confusing...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to use H0 - b0 for the reference water height?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - but b0 is not used otherwise. Thus, it would be more straightforward to use another parameter name for it, wouldn't it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes if b0 is not used otherwise I agree it makes more sense to use another parameter name.

@MarcoArtiano MarcoArtiano Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using something like h_ref or eta0?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with h_ref and h_0. The docstring is talking about h_0. So why not that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favor of h_ref because with h_0 I would expect the relation H_0 = b + h_0 to hold.

Comment on lines +152 to +161
"""
flux_conservative_ec(u_ll, u_rr, normal_direction::AbstractVector, equations::HyperbolicSainteMarieEquations1D)

Total energy conserving and well-balanced two-point flux by
- Marco Artiano, Hendrik Ranocha (2026)
On Affordable High-Order Entropy-Conservative/Stable and
Well-Balanced Methods for Nonconservative Hyperbolic Systems
[DOI: 10.48550/arXiv.2603.18978](https://arxiv.org/abs/2603.18978)
"""
struct flux_conservative_ec{RealT <: Real}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Structs should have capital names like FluxConservativeEC. Please also adapt the docstring to describe what the parameters alpha1, alpha2, alpha3 mean, and how the flux can be applied.
It would also be possible to just pick one set of parameters that performs well and stick with it instead of implementing the whole family. I don't have a strong opinion on this. Since performance is not critical right now, it is definitely nice to have the flexibility - but we may recommend some reasonable default value.

@MarcoArtiano MarcoArtiano Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed the structs' name and adapted the docstrings. We may recommend alpha_1 = 1.0, alpha_2 = 0, alpha_3 = 0, which corresponds to the split form of the shallow water terms and strong form of the remaining terms. Eventually also alpha_1 = 1.0, alpha_2 = 1.0, alpha_3 = 1.0 works (as informative example), which results in a split form for all the terms.

Comment thread src/equations/hyperbolic_sainte_marie_1d.jl
MarcoArtiano and others added 6 commits March 29, 2026 18:11

@JoshuaLampert JoshuaLampert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me. It might make sense to also implement a flux function computing the analytical flux because it enables using, e.g., LLF.

if threshold_limiter === nothing
threshold_limiter = 500 * eps(T)
end
celerity = alpha * sqrt(gravity * b0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we only need the squared celerity it probably makes sense to also just store the square.

Comment on lines +69 to +76
function HyperbolicSainteMarieEquations1D(; gravity, H0 = zero(gravity),
b0 = one(gravity), alpha = 3,
threshold_limiter = nothing)
T = promote_type(typeof(gravity), typeof(H0), typeof(b0), typeof(alpha))
if threshold_limiter === nothing
threshold_limiter = 500 * eps(T)
end
celerity = alpha * sqrt(gravity * b0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with h_ref and h_0. The docstring is talking about h_0. So why not that?

@patrickersing patrickersing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this new system! That is a really nice addition to the package.
The implementation looks quite good already, I mainly had suggestions about naming conventions and comments.

Could you please also:

Comment thread examples/tree_1d_dgsem/elixir_hyperbolic_sainte_marie_ec.jl Outdated
Comment thread examples/tree_1d_dgsem/elixir_hyperbolic_sainte_marie_ec.jl Outdated
Comment thread src/equations/hyperbolic_sainte_marie_1d.jl Outdated
Comment on lines +69 to +76
function HyperbolicSainteMarieEquations1D(; gravity, H0 = zero(gravity),
b0 = one(gravity), alpha = 3,
threshold_limiter = nothing)
T = promote_type(typeof(gravity), typeof(H0), typeof(b0), typeof(alpha))
if threshold_limiter === nothing
threshold_limiter = 500 * eps(T)
end
celerity = alpha * sqrt(gravity * b0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favor of h_ref because with h_0 I would expect the relation H_0 = b + h_0 to hold.

Comment thread src/equations/hyperbolic_sainte_marie_1d.jl Outdated
Comment thread src/equations/hyperbolic_sainte_marie_1d.jl
Comment thread src/equations/hyperbolic_sainte_marie_1d.jl Outdated
Comment thread src/equations/hyperbolic_sainte_marie_1d.jl Outdated
Comment thread src/equations/hyperbolic_sainte_marie_1d.jl
Comment thread src/equations/hyperbolic_sainte_marie_1d.jl Outdated
MarcoArtiano and others added 4 commits June 3, 2026 10:17
Co-authored-by: Patrick Ersing <114223904+patrickersing@users.noreply.github.com>
Co-authored-by: Patrick Ersing <114223904+patrickersing@users.noreply.github.com>
@MarcoArtiano

Copy link
Copy Markdown
Contributor Author

Thanks for adding this new system! That is a really nice addition to the package. The implementation looks quite good already, I mainly had suggestions about naming conventions and comments.

Could you please also:

* [x]  Add a convergence test and document convergence result in the PR.

* [ ]  Add equation specific unit tests such as https://github.com/trixi-framework/TrixiShallowWater.jl/blob/main/test/test_unit.jl#L26.

* [ ]  Create an entry to `NEWS.md` about the addition.
l2
h                   h_v                 h_w                 h_p                 b
error     EOC       error     EOC       error     EOC       error     EOC       error     EOC
4.69e-01  -         3.52e-01  -         1.00e+01  -         3.10e+00  -         1.77e-04  -
1.06e-02  5.47      6.47e-03  5.77      3.11e-01  5.01      7.49e-02  5.37      1.11e-05  3.99
4.22e-04  4.65      3.19e-04  4.34      2.09e-02  3.89      3.23e-03  4.54      6.98e-07  4.00
2.42e-05  4.12      1.74e-05  4.19      1.54e-03  3.76      2.17e-04  3.89      4.36e-08  4.00
1.73e-06  3.81      1.31e-06  3.73      1.07e-04  3.85      1.44e-05  3.91      2.73e-09  4.00
1.16e-07  3.90      9.21e-08  3.84      6.21e-06  4.11      9.22e-07  3.96      1.70e-10  4.00
6.93e-09  4.06      5.74e-09  4.00      2.70e-07  4.52      5.12e-08  4.17      1.06e-11  4.00

mean      4.34      mean      4.31      mean      4.19      mean      4.31      mean      4.00
----------------------------------------------------------------------------------------------------
linf
h                   h_v                 h_w                 h_p                 b
error     EOC       error     EOC       error     EOC       error     EOC       error     EOC
1.29e+00  -         1.03e+00  -         3.42e+01  -         6.28e+00  -         3.64e-04  -
3.25e-02  5.31      1.90e-02  5.77      1.26e+00  4.76      1.76e-01  5.16      2.43e-05  3.91
1.43e-03  4.51      9.13e-04  4.38      1.04e-01  3.60      1.38e-02  3.68      1.54e-06  3.98
1.13e-04  3.66      5.84e-05  3.97      1.15e-02  3.18      1.02e-03  3.75      9.66e-08  3.99
8.40e-06  3.75      4.46e-06  3.71      9.61e-04  3.58      8.19e-05  3.64      6.05e-09  4.00
4.76e-07  4.14      3.17e-07  3.82      6.25e-05  3.94      4.43e-06  4.21      3.78e-10  4.00
2.05e-08  4.54      1.94e-08  4.03      2.84e-06  4.46      1.88e-07  4.56      2.36e-11  4.00

mean      4.32      mean      4.28      mean      3.92      mean      4.17      mean      3.98
----------------------------------------------------------------------------------------------------

@patrickersing patrickersing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentioned in #135 (comment) still needs to be addressed and I have added a couple of questions regarding the tolerances in the EC elixir.

Comment thread examples/tree_1d_dgsem/elixir_hyperbolic_sainte_marie_manufactured.jl Outdated
Comment thread test/test_tree_1d.jl Outdated
Comment thread src/equations/hyperbolic_sainte_marie_1d.jl Outdated
Co-authored-by: Marco Artiano <57838732+MarcoArtiano@users.noreply.github.com>
Comment thread examples/tree_1d_dgsem/elixir_hyperbolic_sainte_marie_ec.jl Outdated
Comment thread examples/tree_1d_dgsem/elixir_hyperbolic_sainte_marie_ec.jl Outdated
Comment thread examples/tree_1d_dgsem/elixir_hyperbolic_sainte_marie_ec.jl Outdated
Comment thread test/test_tree_1d.jl Outdated
Comment thread test/test_tree_1d.jl Outdated

@patrickersing patrickersing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment regarding the tolerances as mentioned in #135 (comment).
Other than that the PR looks good!

@MarcoArtiano

MarcoArtiano commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Please add a comment regarding the tolerances as mentioned in #135 (comment). Other than that the PR looks good!

Done, should I add also a comment in the elixirs? Usually this is not done in the main repo Trixi.jl. Adaptive time-stepper methods often allow to run maximum stable CFL number at loose tolerances, therefore it is often suggested, unless restricted by temporal accuracy, to use loose tolerances.

@patrickersing patrickersing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, to me it's sufficient to document it in the test file.
LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants