Skip to content

Add Hyperbolic Sainte-Marie Equations 1D#135

Open
MarcoArtiano wants to merge 18 commits intomainfrom
ma/hyperbolized_sainte_marie
Open

Add Hyperbolic Sainte-Marie Equations 1D#135
MarcoArtiano wants to merge 18 commits intomainfrom
ma/hyperbolized_sainte_marie

Conversation

@MarcoArtiano
Copy link
Copy Markdown
Contributor

@MarcoArtiano MarcoArtiano commented Mar 29, 2026

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

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

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
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.30%. Comparing base (a9ae27b) to head (1b9ceff).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #135      +/-   ##
==========================================
+ Coverage   99.28%   99.30%   +0.02%     
==========================================
  Files          96       98       +2     
  Lines        5146     5290     +144     
==========================================
+ Hits         5109     5253     +144     
  Misses         37       37              

☔ View full report in Codecov by Sentry.
📢 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
Copy link
Copy Markdown
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

Comment on lines +4 to +12
@doc raw"""
HyperbolicSainteMarieEquations1D(; bathymetry_type = bathymetry_mild_slope,
gravity,
eta0 = 0.0,
h0,
alpha = 3.0)

Hyperbolic approximation of the Sainte-Marie system
[`SainteMarieEquations1D`](@ref) in one spatial dimension
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 fix the docstring so that it matches the code here and not DispersiveShallowWater.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.

Copy link
Copy Markdown
Contributor Author

@MarcoArtiano MarcoArtiano Mar 29, 2026

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?

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.

Copy link
Copy Markdown
Contributor Author

@MarcoArtiano MarcoArtiano Mar 29, 2026

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 on lines +313 to +328
# Convert conservative variables to entropy
# Note, only the first two are the entropy variables, the third entry still
# just carries the bottom topography values for convenience
@inline function Trixi.cons2entropy(u, equations::HyperbolicSainteMarieEquations1D)
h, h_v, h_w, h_p, b = u

v = h_v / h
w = h_w / h
p = h_p / h

w1 = equations.gravity * (h + b) - 0.5f0 * (v^2 + w^2 + p^2 / equations.celerity^2)
w2 = v
w3 = w
w4 = p / equations.celerity^2
return SVector(w1, w2, w3, w4, zero(eltype(u)))
end
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 about the bottom topography and the code do not match.

MarcoArtiano and others added 4 commits March 29, 2026 18:11
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
…work/TrixiShallowWater.jl into ma/hyperbolized_sainte_marie
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.

3 participants