Skip to content

Add Legendre-Gauss basis for DGSEM and implement solver support for 1D/2D TreeMesh#1965

Merged
DanielDoehring merged 32 commits intomainfrom
msl/legendre-gauss-basis
Feb 24, 2026
Merged

Add Legendre-Gauss basis for DGSEM and implement solver support for 1D/2D TreeMesh#1965
DanielDoehring merged 32 commits intomainfrom
msl/legendre-gauss-basis

Conversation

@sloede
Copy link
Copy Markdown
Member

@sloede sloede commented May 31, 2024

No description provided.

@github-actions
Copy link
Copy Markdown
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.

@sloede
Copy link
Copy Markdown
Member Author

sloede commented May 31, 2024

Convergence test results:

julia>  convergence_test("examples/tree_2d_dgsem/elixir_euler_convergence_gauss.jl", 5, tspan=(0.0, 0.1)

####################################################################################################
l2
rho                 rho_v1              rho_v2              rho_e
error     EOC       error     EOC       error     EOC       error     EOC
6.84e-07  -         8.45e-07  -         8.45e-07  -         2.69e-06  -
3.49e-08  4.29      4.30e-08  4.30      4.30e-08  4.30      1.56e-07  4.11
2.25e-09  3.95      2.81e-09  3.94      2.81e-09  3.94      9.84e-09  3.98
1.36e-10  4.05      1.70e-10  4.04      1.70e-10  4.04      6.13e-10  4.00
8.57e-12  3.99      1.08e-11  3.98      1.08e-11  3.98      3.83e-11  4.00

mean      4.07      mean      4.06      mean      4.06      mean      4.03
----------------------------------------------------------------------------------------------------
linf
rho                 rho_v1              rho_v2              rho_e
error     EOC       error     EOC       error     EOC       error     EOC
2.36e-06  -         3.08e-06  -         3.08e-06  -         1.30e-05  -
1.74e-07  3.77      2.15e-07  3.84      2.15e-07  3.84      9.16e-07  3.82
1.30e-08  3.74      1.61e-08  3.74      1.61e-08  3.74      6.05e-08  3.92
6.76e-10  4.26      8.31e-10  4.28      8.31e-10  4.28      3.50e-09  4.11
4.40e-11  3.94      5.59e-11  3.89      5.59e-11  3.89      2.27e-10  3.95

mean      3.93      mean      3.94      mean      3.94      mean      3.95
----------------------------------------------------------------------------------------------------
Dict{Symbol, Any} with 3 entries:
  :variables => ("rho", "rho_v1", "rho_v2", "rho_e")
  :l2        => [4.07106, 4.06455, 4.06455, 4.02501]
  :linf      => [3.92877, 3.93774, 3.9377, 3.95104]

@codecov
Copy link
Copy Markdown

codecov bot commented May 31, 2024

Codecov Report

❌ Patch coverage is 97.35450% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.13%. Comparing base (79cf51e) to head (88ac730).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/solvers/dgsem_tree/dg_1d.jl 93.33% 2 Missing ⚠️
src/solvers/dgsem_tree/dg_2d.jl 95.56% 2 Missing ⚠️
src/solvers/dgsem/basis_gauss_legendre.jl 99.10% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1965    +/-   ##
========================================
  Coverage   97.13%   97.13%            
========================================
  Files         595      596     +1     
  Lines       45802    45943   +141     
========================================
+ Hits        44486    44623   +137     
- Misses       1316     1320     +4     
Flag Coverage Δ
unittests 97.13% <97.35%> (+<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.

DanielDoehring and others added 2 commits October 25, 2025 12:03
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@DanielDoehring DanielDoehring added the enhancement New feature or request label Oct 25, 2025
@DanielDoehring DanielDoehring marked this pull request as ready for review February 23, 2026 10:07
@DanielDoehring DanielDoehring changed the title WIP: Add Legendre-Gauss basis for DGSEM and implement solver support for 2D TreeMesh Add Legendre-Gauss basis for DGSEM and implement solver support for 1D/2D TreeMesh Feb 23, 2026
@DanielDoehring
Copy link
Copy Markdown
Member

That's really nice! As a smoke test, I compared the solution of the 1D advection test case to a 1D Gauss-Legendre solver I once implemented in SimpleDiscontinuousGalerkin.jl using the same setup and the two solutions have differences of the order of 1e-16 👍

Ah that is nice!

DanielDoehring
DanielDoehring previously approved these changes Feb 23, 2026
Copy link
Copy Markdown
Member

@JoshuaLampert JoshuaLampert left a comment

Choose a reason for hiding this comment

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

Only one small final comment.

Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com>
JoshuaLampert
JoshuaLampert previously approved these changes Feb 23, 2026
Copy link
Copy Markdown
Contributor

@jlchan jlchan left a comment

Choose a reason for hiding this comment

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

This is very cool! One suggestion - this should work for VolumeIntegralWeakForm but not VolumeIntegralFluxDifferencing yet since that would require some modifications of calc_volume_integral! to incorporate surface corrections. Might make sense to note that in NEWS.md?

@DanielDoehring
Copy link
Copy Markdown
Member

This is very cool! One suggestion - this should work for VolumeIntegralWeakForm but not VolumeIntegralFluxDifferencing yet since that would require some modifications of calc_volume_integral! to incorporate surface corrections. Might make sense to note that in NEWS.md?

Yes, makes sense to me - I would probably also delete the derivative_matrix_split as well to really make sure that this is not used right now.

@DanielDoehring DanielDoehring enabled auto-merge (squash) February 24, 2026 08:07
@DanielDoehring DanielDoehring merged commit 30ac6a2 into main Feb 24, 2026
40 checks passed
@DanielDoehring DanielDoehring deleted the msl/legendre-gauss-basis branch February 24, 2026 09:38
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.

Can we use a uniform naming pattern - either _gauss or _gauss_legendre, please?


"""
DGSEM(; RealT=Float64, polydeg::Integer,
basis = LobattoLegendreBasis(RealT, polydeg)
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.

Suggested change
basis = LobattoLegendreBasis(RealT, polydeg)
basis = LobattoLegendreBasis(RealT, polydeg),

Comment on lines 64 to +66
function DGSEM(; RealT = Float64,
polydeg::Integer,
basis = LobattoLegendreBasis(RealT, polydeg),
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.

This can be very confusing, since it allows you to pass

DGSEM(; polydeg = 3, basis = GaussLegendreBasis(5))

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 agree. I will add a PR which adds a new constructor for this.

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.

5 participants