Skip to content

Conversation

@SimonCan
Copy link
Contributor

To run on meshes, like p4est meshes we needed a max_abs_speed_naive function for general vectors/directions.

@SimonCan SimonCan added the enhancement New feature or request label Oct 16, 2025
@github-actions
Copy link
Contributor

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md with its PR number.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

@codecov
Copy link

codecov bot commented Oct 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.81%. Comparing base (1d75f8f) to head (1a1d7bc).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2607   +/-   ##
=======================================
  Coverage   96.81%   96.81%           
=======================================
  Files         535      536    +1     
  Lines       42813    42859   +46     
=======================================
+ Hits        41446    41492   +46     
  Misses       1367     1367           
Flag Coverage Δ
unittests 96.81% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Copy link
Member

@DanielDoehring DanielDoehring left a comment

Choose a reason for hiding this comment

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

Could you add unit tests that show that the speed for the vectors [1, 0] and [0, 1]matches the existing speed for directions 1, 2?

@SimonCan
Copy link
Contributor Author

Still getting some type instability and memory allocations. I am stumped, as any attempted fix does nothing.

@SimonCan SimonCan marked this pull request as ready for review October 24, 2025 17:24
Comment on lines +55 to +61
limiter_idp = SubcellLimiterIDP(equations, basis;
positivity_variables_cons = ["rho" * string(i)
for i in eachcomponent(equations)])

volume_integral = VolumeIntegralSubcellLimiting(limiter_idp;
volume_flux_dg = volume_flux,
volume_flux_fv = surface_flux)
Copy link
Member

Choose a reason for hiding this comment

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

Did you check this code for type instabilities? Do you get type instabilities with mainstream solvers like shock capturing Hennemann & Gassner?

Copy link
Member

Choose a reason for hiding this comment

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

+1 that is something you should check first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would that not require a min_max_speed_davis? If so it might just shift the type instability.

Copy link
Member

Choose a reason for hiding this comment

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

Your new code looks reasonable. Thus, I guess the type instabilities come from this choice of solver. You can also profile it or use Cthulhu.jl to @descend into our rhs!.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that the type instability does not come from max_abs_speed_naive after all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Strangely enough,
@btime Trixi.rhs!($du, $sol.u[1], $semi, 0.0)
does not give me any extra memory allocations.

DanielDoehring and others added 2 commits October 25, 2025 16:52
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines 701 to 715
norm_ = norm(normal_direction)
normal_vector = normal_direction / norm_
# Project velocities onto the direction normal_direction.
v_ll = dot(v_ll_vec, normal_vector)
v_rr = dot(v_rr_vec, normal_vector)

# Compute pressures
p_ll = (gamma_ll - 1) * (rho_e_ll - 0.5f0 * dot(v_ll_vec, v_ll_vec) * rho_ll)
p_rr = (gamma_rr - 1) * (rho_e_rr - 0.5f0 * dot(v_rr_vec, v_rr_vec) * rho_rr)

# Sound speeds
c_ll = sqrt(gamma_ll * p_ll / rho_ll)
c_rr = sqrt(gamma_rr * p_rr / rho_rr)

return (max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr)) * norm_
Copy link
Member

Choose a reason for hiding this comment

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

I changed the normal stuff a bit to follow

@inline function max_abs_speed_naive(u_ll, u_rr, normal_direction::AbstractVector,
equations::CompressibleEulerEquations2D)
rho_ll, v1_ll, v2_ll, p_ll = cons2prim(u_ll, equations)
rho_rr, v1_rr, v2_rr, p_rr = cons2prim(u_rr, equations)
# Calculate normal velocities and sound speed
# left
v_ll = (v1_ll * normal_direction[1]
+
v2_ll * normal_direction[2])
c_ll = sqrt(equations.gamma * p_ll / rho_ll)
# right
v_rr = (v1_rr * normal_direction[1]
+
v2_rr * normal_direction[2])
c_rr = sqrt(equations.gamma * p_rr / rho_rr)
return max(abs(v_ll), abs(v_rr)) + max(c_ll, c_rr) * norm(normal_direction)

closer. But better check this for a convergence problem or with unit tests

SimonCan and others added 10 commits October 27, 2025 14:39
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines +685 to +686
@inline function max_abs_speed_naive(u_ll::SVector{N,T}, u_rr::SVector{N,T}, normal_direction::SVector{2,T},
equations::CompressibleEulerMulticomponentEquations2D) where {N, T<:AbstractFloat}
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
@inline function max_abs_speed_naive(u_ll::SVector{N,T}, u_rr::SVector{N,T}, normal_direction::SVector{2,T},
equations::CompressibleEulerMulticomponentEquations2D) where {N, T<:AbstractFloat}
@inline function max_abs_speed_naive(u_ll::SVector{N, T}, u_rr::SVector{N, T},
normal_direction::SVector{2, T},
equations::CompressibleEulerMulticomponentEquations2D) where {
N,
T <:
AbstractFloat
}

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants