Skip to content

Reconstruction for 1D BlockFV - #3156

Open
Sreeram-Shankar wants to merge 17 commits into
trixi-framework:mainfrom
Sreeram-Shankar:BlockFV-reconstruction
Open

Reconstruction for 1D BlockFV#3156
Sreeram-Shankar wants to merge 17 commits into
trixi-framework:mainfrom
Sreeram-Shankar:BlockFV-reconstruction

Conversation

@Sreeram-Shankar

@Sreeram-Shankar Sreeram-Shankar commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Part of #3155 (Reconstructions for Block Finite Volume).

This PR adds second-order MUSCL-type reconstructions for the 1D TreeMesh BlockFV solver. The first-order BlockFV path is left unchanged. A new BlockFVO2 solver (with VolumeIntegralFiniteVolumeO2) is introduced for the O2 scheme.

  • Added BlockFVO2 / VolumeIntegralFiniteVolumeO2 with a reconstruction API (reconstruction_mode, slope_limiter, cons2recon / recon2cons).
  • Volume-local reconstruction at internal subcell faces
  • Surface reconstruction at element interfaces and boundaries via specialized prolong2interfaces! / prolong2boundaries!
  • BlockFV-specific reconstruction_O2 function
  • 1D TreeMesh only for now
  • Examples and tests (elixir + convergence and L2/Ling tests) are included

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

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.62921% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.95%. Comparing base (630c6ee) to head (959daf0).

Files with missing lines Patch % Lines
src/solvers/blockfv/blockfv_1d.jl 96.15% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3156      +/-   ##
==========================================
- Coverage   96.95%   96.95%   -0.00%     
==========================================
  Files         673      673              
  Lines       52160    52248      +88     
==========================================
+ Hits        50570    50655      +85     
- Misses       1590     1593       +3     
Flag Coverage Δ
unittests 96.95% <96.63%> (-<0.01%) ⬇️

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

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

@jlchan jlchan 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.

This is looking like a great draft. When you have time, could you share results from a convergence test and a comparison of solution profiles for BlockFV vs BlockFVO2?

Once you've had a chance to add CI tests and a NEWS.md entry, please feel free to ping me again

Comment thread src/solvers/blockfv/blockfv.jl Outdated
Comment thread src/solvers/blockfv/blockfv_1d.jl
Comment thread src/solvers/blockfv/blockfv_1d.jl
Comment thread src/solvers/blockfv/blockfv_1d.jl
@Sreeram-Shankar

Copy link
Copy Markdown
Contributor Author
l2
rho                         rho_v1                   rho_e_total         
error         EOC      error        EOC       error        EOC       
1.72e-04  -            1.77e-04  -            5.49e-04  -         
4.01e-05  2.10      4.19e-05  2.08      1.41e-04  1.96      
9.57e-06  2.07      1.03e-05  2.02      3.52e-05  2.00      

mean      2.08         mean      2.05          mean      1.98      

linf
rho                      rho_v1                 rho_e_total         
error        EOC      error         EOC      error        EOC       
6.23e-04  -          6.00e-04  -           1.36e-03  -         
1.57e-04  1.99      1.56e-04  1.95      3.46e-04  1.98      
4.19e-05  1.90      4.15e-05  1.90      8.94e-05  1.95      

mean      1.95           mean      1.93      mean      1.96      

Convergence Test

@Sreeram-Shankar

Copy link
Copy Markdown
Contributor Author
image

@Sreeram-Shankar
Sreeram-Shankar requested a review from jlchan July 27, 2026 00:08
@jlchan

jlchan commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Nice! Can you also show a comparison for a shock or discontinuous solution?

@Sreeram-Shankar

Copy link
Copy Markdown
Contributor Author
image

Comment thread src/solvers/blockfv/blockfv_1d.jl

@jlchan jlchan 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.

Thanks for making the changes before! One question

Comment thread src/solvers/blockfv/blockfv.jl Outdated
@Sreeram-Shankar
Sreeram-Shankar marked this pull request as ready for review August 5, 2026 01:33
@Sreeram-Shankar
Sreeram-Shankar requested a review from jlchan August 5, 2026 01:33
@jlchan

jlchan commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

The CI failure looks real, can you fix it? Prob just a namespace issue

@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 for working on this!

Comment thread src/solvers/blockfv/blockfv.jl Outdated
Comment on lines +142 to +156
"""
BlockFVO2(; n_nodes::Integer,
surface_flux,
slope_limiter = minmod,
cons2recon = cons2prim,
recon2cons = prim2cons,
RealT = Float64)

Create a second-order block finite volume solver with high-order volume reconstruction.
See [`VolumeIntegralFiniteVolumeO2`](@ref).

!!! warning "Experimental code"
This code is experimental and may change in any future release.
"""
const BlockFVO2 = DG{Basis, Mortar, SurfaceIntegral,

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 don't think we need a new solver alias for this, do we? Can't we just continue to use BlockFV as before, maybe with a new method accepting a reconstruction?

Comment on lines +103 to +104
# Near the element ends the missing neighbor is clamped to the
# outermost cell (volume-local stencil; no values from other elements).

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.

We have some options (the reconstruction_mode) for choosing how to handle cell boundaries for

Trixi.jl/src/solvers/dg.jl

Lines 598 to 660 in 0aaa001

"""
VolumeIntegralPureLGLFiniteVolumeO2(basis;
volume_flux_fv = flux_lax_friedrichs,
reconstruction_mode = reconstruction_O2_full,
slope_limiter = minmod,
cons2recon = cons2prim,
recon2cons = prim2cons)
This gives an up to second order accurate finite volume scheme on an LGL-type subcell
mesh (LGL = Legendre-Gauss-Lobatto).
Depending on the `reconstruction_mode` and `slope_limiter`, experimental orders of convergence
between 1 and 2 can be expected in practice.
Since this is a volume integral, all reconstructions are purely cell-local, i.e.,
no neighboring elements are queried at reconstruction stage.
The interface values of the inner DG-subcells are reconstructed using the standard MUSCL-type reconstruction.
For the DG-subcells at the boundaries, two options are available:
1) The unlimited slope is used on these cells.
This gives full second order accuracy, but also does not damp overshoots between cells.
The `reconstruction_mode` corresponding to this is `reconstruction_O2_full`.
2) On boundary subcells, the solution is represented using a constant value, thereby falling back to formally only first order.
The `reconstruction_mode` corresponding to this is `reconstruction_O2_inner`.
In the reference below, this is the recommended reconstruction mode and is thus used by default.
**Symmetric** total-Variation-Diminishing (TVD) choices for the `slope_limiter` are
1) [`minmod`](@ref)
2) [`monotonized_central`](@ref)
3) [`superbee`](@ref)
4) [`vanleer`](@ref)
5) [`koren_symmetric`](@ref)
**Asymmetric** TVD limiters are also available, e.g.,
1) [`koren`](@ref) for positive (right-going) velocities
2) [`koren_flipped`](@ref) for negative (left-going) velocities
The reconstruction is performed in reconstruction variables, which default to the primitive variables.
Other choices are possible, e.g., thermodynamic variables, see [`cons2thermo`](@ref) and [`thermo2cons`](@ref)
for [`NonIdealCompressibleEulerEquations1D`](@ref) and [`NonIdealCompressibleEulerEquations2D`](@ref).
!!! note "Conservative systems only"
Currently only implemented for systems in conservative form, i.e.,
`have_nonconservative_terms(equations) = False()`
## References
See especially Section 3.2, Section 4, and Appendix D of the paper
- Rueda-Ramírez, Hennemann, Hindenlang, Winters, & Gassner (2021).
"An entropy stable nodal discontinuous Galerkin method for the resistive MHD equations.
Part II: Subcell finite volume shock capturing"
[JCP: 2021.110580](https://doi.org/10.1016/j.jcp.2021.110580)
"""
struct VolumeIntegralPureLGLFiniteVolumeO2{SubCellInterfaceCoordinates, VolumeFluxFV,
Reconstruction, Limiter,
Cons2Recon, Recon2Cons} <:
AbstractVolumeIntegralPureLGLFiniteVolume
sc_interface_coords::SubCellInterfaceCoordinates # (x-)coordinates of the sub-cell element interfaces
volume_flux_fv::VolumeFluxFV # non-symmetric in general, e.g. entropy-dissipative
reconstruction_mode::Reconstruction # which type of FV reconstruction to use
slope_limiter::Limiter # which type of slope limiter function
cons2recon::Cons2Recon # function to convert from conservative variables to the variables used for reconstruction
recon2cons::Recon2Cons # function to convert from the variables used for reconstruction back to conservative variables
end

Could we please enable the same flexibility here (and more options later)? We should also cross-reference these methods from their docstrings.

Comment thread src/solvers/blockfv/blockfv.jl
Comment thread src/solvers/blockfv/blockfv_1d.jl
Comment thread src/solvers/blockfv/blockfv_1d.jl
Comment thread src/solvers/blockfv/blockfv_1d.jl
@DanielDoehring

Copy link
Copy Markdown
Member
image

Could you also provide a figure how this looks for reconstruction_mode_inner ?

@Sreeram-Shankar

Copy link
Copy Markdown
Contributor Author

Could you re-upload the image? Im not able to see it

@DanielDoehring DanielDoehring added the enhancement New feature or request label Aug 26, 2026
@DanielDoehring

Copy link
Copy Markdown
Member

Could you re-upload the image? Im not able to see it

Strange 🤔 , it is the one you posted here.

@jlchan

jlchan commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Could you re-upload the image? Im not able to see it

Strange 🤔 , it is the one you posted here.

I actually can't view the image either @DanielDoehring. Can you specify which one it is?

@DanielDoehring

Copy link
Copy Markdown
Member
DiscontSol

This one

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