Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add two-sided Zalesak-type IDP subcell limiting #1648

Merged
merged 35 commits into from
Nov 13, 2023

Conversation

bennibolm
Copy link
Contributor

@bennibolm bennibolm commented Sep 26, 2023

Right now, only the positivity IDP limiter for conservative variables was merged into main. This PR adds the two-sided local IDP limiting for conservative variables.
It is a Zalesak-type limiter which uses the low-order FV solution to calculate the local bounds.

Since the bound calculation requires boundary values, we introduce the routine get_boundary_outer_state. Since yet we only use this in one elixir, it is only implemented for BoundaryConditionDirichlet.

TODO:

  • Add comment/warning in docstring of limiter to clarify functionality and problems of non-conforming meshes (e.g. with AMR) with subcell limiting (see here).
  • Add comment in News.md

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

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 Sep 26, 2023

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Comparison is base (1b75f5e) 96.23% compared to head (f7b8d0a) 86.65%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1648      +/-   ##
==========================================
- Coverage   96.23%   86.65%   -9.58%     
==========================================
  Files         425      428       +3     
  Lines       34253    34482     +229     
==========================================
- Hits        32960    29878    -3082     
- Misses       1293     4604    +3311     
Flag Coverage Δ
unittests 86.65% <93.60%> (-9.58%) ⬇️

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

Files Coverage Δ
.../elixir_euler_blast_wave_sc_subcell_nonperiodic.jl 100.00% <100.00%> (ø)
..._dgsem/elixir_euler_sedov_blast_wave_sc_subcell.jl 100.00% <100.00%> (ø)
...ee_2d_dgsem/elixir_euler_shockcapturing_subcell.jl 100.00% <ø> (ø)
...ulti_shock_bubble_shockcapturing_subcell_minmax.jl 100.00% <100.00%> (ø)
..._shock_bubble_shockcapturing_subcell_positivity.jl 100.00% <ø> (ø)
...tree_2d_dgsem/elixir_mhd_shockcapturing_subcell.jl 100.00% <ø> (ø)
src/solvers/dg.jl 91.87% <ø> (ø)
src/solvers/dgsem_tree/dg_2d_subcell_limiters.jl 99.57% <100.00%> (+0.01%) ⬆️
src/solvers/dgsem_tree/subcell_limiters.jl 90.20% <100.00%> (+4.90%) ⬆️
src/equations/equations.jl 96.55% <80.00%> (-1.56%) ⬇️
... and 3 more

... and 84 files with indirect coverage changes

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

@bennibolm bennibolm marked this pull request as ready for review October 16, 2023 13:17
@bennibolm bennibolm changed the title WIP: Add two-sided Zalesak-type IDP subcell limiting Add two-sided Zalesak-type IDP subcell limiting Oct 16, 2023
@bennibolm
Copy link
Contributor Author

bennibolm commented Oct 16, 2023

The runtime analysis (1 thread and with --check-bounds=no) looks good to me.
Sedov blast example (local limiting of density) with initial_refinement_level=5 and cfl=0.5:

────────────────────────────────────────────────────────────────────────────────────────────────────
 Simulation running 'CompressibleEulerEquations2D' with DGSEM(polydeg=3)
────────────────────────────────────────────────────────────────────────────────────────────────────
 #timesteps:                513                run time:       2.20128571e+00 s
 Δt:             4.71011779e-03                └── GC time:    0.00000000e+00 s (0.000%)
 sim. time:      3.00000000e+00 (100.000%)     time/DOF/rhs!:  7.25639782e-08 s
                                               PID:            8.72189755e-08 s
 #DOFs per field:         16384                alloc'd memory:        427.290 MiB
 #elements:                1024

 Variable:       rho              rho_v1           rho_v2           rho_e         
 L2 error:       9.58103097e-01   1.87127221e-01   1.87127744e-01   6.35166241e-01
 Linf error:     3.23308655e+00   9.21537372e-01   9.21545552e-01   6.58655521e+00
 ∑∂S/∂U ⋅ Uₜ :  -1.06783168e+02
────────────────────────────────────────────────────────────────────────────────────────────────────

────────────────────────────────────────────────────────────────────────────────────────────────────
Trixi.jl simulation finished.  Final time: 3.0  Time steps: 513 (accepted), 513 (total)
────────────────────────────────────────────────────────────────────────────────────────────────────

 ───────────────────────────────────────────────────────────────────────────────────────
               Trixi.jl                        Time                    Allocations      
                                      ───────────────────────   ────────────────────────
           Tot / % measured:               2.44s /  87.1%           40.1MiB /   8.7%    

 Section                      ncalls     time    %tot     avg     alloc    %tot      avg
 ───────────────────────────────────────────────────────────────────────────────────────
 rhs!                          1.54k    1.83s   86.1%  1.19ms   9.33KiB    0.3%    6.21B
   volume integral             1.54k    1.62s   76.2%  1.05ms     0.00B    0.0%    0.00B
   interface flux              1.54k    119ms    5.6%  77.3μs     0.00B    0.0%    0.00B
   prolong2interfaces          1.54k   32.1ms    1.5%  20.9μs     0.00B    0.0%    0.00B
   surface integral            1.54k   31.7ms    1.5%  20.6μs     0.00B    0.0%    0.00B
   reset ∂u/∂t                 1.54k   14.4ms    0.7%  9.35μs     0.00B    0.0%    0.00B
   Jacobian                    1.54k   11.0ms    0.5%  7.13μs     0.00B    0.0%    0.00B
   ~rhs!~                      1.54k   2.09ms    0.1%  1.36μs   9.33KiB    0.3%    6.21B
   prolong2boundaries          1.54k   97.4μs    0.0%  63.3ns     0.00B    0.0%    0.00B
   prolong2mortars             1.54k   81.1μs    0.0%  52.7ns     0.00B    0.0%    0.00B
   mortar flux                 1.54k   43.4μs    0.0%  28.2ns     0.00B    0.0%    0.00B
   boundary flux               1.54k   25.3μs    0.0%  16.5ns     0.00B    0.0%    0.00B
   source terms                1.54k   24.9μs    0.0%  16.2ns     0.00B    0.0%    0.00B
 a posteriori limiter          1.54k    258ms   12.2%   168μs    338KiB    9.4%     225B
   blending factors            1.54k    198ms    9.3%   129μs    337KiB    9.4%     224B
     local min/max limiting    1.54k    174ms    8.2%   113μs    337KiB    9.4%     224B
     ~blending factors~        1.54k   24.4ms    1.1%  15.8μs      752B    0.0%    0.49B
   ~a posteriori limiter~      1.54k   60.0ms    2.8%  39.0μs      752B    0.0%    0.49B
 calculate dt                    514   29.7ms    1.4%  57.8μs     0.00B    0.0%    0.00B
 I/O                               3   4.11ms    0.2%  1.37ms   3.13MiB   89.3%  1.04MiB
   save solution                   2   3.31ms    0.2%  1.65ms   3.03MiB   86.5%  1.52MiB
   ~I/O~                           3    742μs    0.0%   247μs   87.8KiB    2.4%  29.3KiB
   get element variables           2   56.1μs    0.0%  28.1μs   14.6KiB    0.4%  7.30KiB
   save mesh                       2    132ns    0.0%  66.0ns     0.00B    0.0%    0.00B
 analyze solution                  2   4.05ms    0.2%  2.03ms   36.0KiB    1.0%  18.0KiB
 ───────────────────────────────────────────────────────────────────────────────────────

The same example with IndicatorHennemannGassner (with cfl=0.5 although cfl=0.6 is also possible here -> In that case it takes ~1.57s) gives this:

────────────────────────────────────────────────────────────────────────────────────────────────────
 Simulation running 'CompressibleEulerEquations2D' with DGSEM(polydeg=3)
────────────────────────────────────────────────────────────────────────────────────────────────────
 #timesteps:                495                run time:       1.57175039e+00 s
 Δt:             6.26367957e-03                └── GC time:    0.00000000e+00 s (0.000%)
 sim. time:      3.00000000e+00 (100.000%)     time/DOF/rhs!:  6.01968891e-08 s
                                               PID:            6.45347957e-08 s
 #DOFs per field:         16384                alloc'd memory:        510.093 MiB
 #elements:                1024

 Variable:       rho              rho_v1           rho_v2           rho_e         
 L2 error:       8.43149239e-01   1.68693912e-01   1.68693912e-01   6.35026581e-01
 Linf error:     2.52459483e+00   7.10378224e-01   7.10378224e-01   6.58830417e+00
 ∑∂S/∂U ⋅ Uₜ :  -3.29792691e+00
────────────────────────────────────────────────────────────────────────────────────────────────────

────────────────────────────────────────────────────────────────────────────────────────────────────
Trixi.jl simulation finished.  Final time: 3.0  Time steps: 495 (accepted), 495 (total)
────────────────────────────────────────────────────────────────────────────────────────────────────

 ────────────────────────────────────────────────────────────────────────────────────
              Trixi.jl                      Time                    Allocations      
                                   ───────────────────────   ────────────────────────
         Tot / % measured:              1.82s /  82.4%           39.8MiB /   8.1%    

 Section                   ncalls     time    %tot     avg     alloc    %tot      avg
 ────────────────────────────────────────────────────────────────────────────────────
 rhs!                       1.49k    1.46s   97.7%   986μs   18.6KiB    0.6%    12.8B
   volume integral          1.49k    1.28s   85.1%   859μs   9.28KiB    0.3%    6.40B
     blended DG-FV          1.49k    632ms   42.2%   425μs     0.00B    0.0%    0.00B
     pure DG                1.49k    527ms   35.2%   355μs     0.00B    0.0%    0.00B
     blending factors       1.49k    109ms    7.3%  73.6μs     0.00B    0.0%    0.00B
     ~volume integral~      1.49k   7.47ms    0.5%  5.03μs   9.28KiB    0.3%    6.40B
   interface flux           1.49k    107ms    7.2%  72.2μs     0.00B    0.0%    0.00B
   surface integral         1.49k   29.6ms    2.0%  19.9μs     0.00B    0.0%    0.00B
   prolong2interfaces       1.49k   25.7ms    1.7%  17.3μs     0.00B    0.0%    0.00B
   reset ∂u/∂t              1.49k   14.3ms    1.0%  9.61μs     0.00B    0.0%    0.00B
   Jacobian                 1.49k   10.1ms    0.7%  6.78μs     0.00B    0.0%    0.00B
   ~rhs!~                   1.49k   1.67ms    0.1%  1.12μs   9.33KiB    0.3%    6.43B
   prolong2mortars          1.49k   90.0μs    0.0%  60.6ns     0.00B    0.0%    0.00B
   prolong2boundaries       1.49k   87.4μs    0.0%  58.9ns     0.00B    0.0%    0.00B
   mortar flux              1.49k   47.8μs    0.0%  32.2ns     0.00B    0.0%    0.00B
   boundary flux            1.49k   38.0μs    0.0%  25.6ns     0.00B    0.0%    0.00B
   source terms             1.49k   23.7μs    0.0%  15.9ns     0.00B    0.0%    0.00B
 calculate dt                 496   26.4ms    1.8%  53.3μs     0.00B    0.0%    0.00B
 I/O                            3   4.19ms    0.3%  1.40ms   3.13MiB   97.2%  1.04MiB
   save solution                2   3.37ms    0.2%  1.68ms   3.03MiB   94.1%  1.52MiB
   ~I/O~                        3    621μs    0.0%   207μs   87.8KiB    2.7%  29.3KiB
   get element variables        2    198μs    0.0%  99.1μs   14.6KiB    0.4%  7.30KiB
   save mesh                    2    137ns    0.0%  68.5ns     0.00B    0.0%    0.00B
 analyze solution               2   3.50ms    0.2%  1.75ms   74.3KiB    2.3%  37.1KiB
 ────────────────────────────────────────────────────────────────────────────────────

Copy link
Member

@efaulhaber efaulhaber left a comment

Choose a reason for hiding this comment

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

Again, just a quick review. I didn't work through the details of the method.

Copy link
Contributor

@amrueda amrueda left a comment

Choose a reason for hiding this comment

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

LGTM!
A couple of comments below.

src/solvers/dgsem_tree/dg_2d_subcell_limiters.jl Outdated Show resolved Hide resolved
src/solvers/dgsem_tree/subcell_limiters.jl Outdated Show resolved Hide resolved
@bennibolm bennibolm marked this pull request as draft October 22, 2023 16:55
@bennibolm bennibolm requested a review from sloede October 25, 2023 08:17
src/solvers/dgsem_tree/subcell_limiters.jl Outdated Show resolved Hide resolved
src/solvers/dgsem_tree/subcell_limiters.jl Show resolved Hide resolved
src/solvers/dgsem_tree/subcell_limiters.jl Show resolved Hide resolved
src/solvers/dgsem_tree/subcell_limiters.jl Outdated Show resolved Hide resolved
test/test_tree_2d_euler.jl Show resolved Hide resolved
src/solvers/dgsem_tree/subcell_limiters_2d.jl Outdated Show resolved Hide resolved
src/solvers/dgsem_tree/subcell_limiters_2d.jl Outdated Show resolved Hide resolved
src/solvers/dgsem_tree/subcell_limiters_2d.jl Outdated Show resolved Hide resolved
@bennibolm bennibolm requested a review from sloede November 8, 2023 08:45
src/solvers/dgsem_tree/subcell_limiters.jl Outdated Show resolved Hide resolved
src/solvers/dgsem_tree/subcell_limiters.jl Outdated Show resolved Hide resolved
Copy link
Member

@sloede sloede left a comment

Choose a reason for hiding this comment

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

Some more suggestions 😅

src/solvers/dgsem_tree/subcell_limiters.jl Outdated Show resolved Hide resolved
test/test_unit.jl Show resolved Hide resolved
src/solvers/dgsem_tree/subcell_limiters.jl Outdated Show resolved Hide resolved
@bennibolm bennibolm requested a review from sloede November 8, 2023 13:49
src/equations/equations.jl Outdated Show resolved Hide resolved
Copy link
Member

@sloede sloede left a comment

Choose a reason for hiding this comment

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

Once the last conversation is resolved, this LGTM

@bennibolm bennibolm requested a review from sloede November 9, 2023 13:23
Copy link
Member

@sloede sloede left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@sloede sloede requested a review from amrueda November 9, 2023 13:30
@sloede
Copy link
Member

sloede commented Nov 9, 2023

@amrueda wants to take a final look. the test failures seem unrelated to this PR, so if he's happy with it, we can merge this

Copy link
Contributor

@amrueda amrueda left a comment

Choose a reason for hiding this comment

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

Almost there!
However, I just realized a problem with the bounds check routines 😅 :

@sloede sloede enabled auto-merge (squash) November 13, 2023 12:38
@sloede sloede merged commit 7bb3b46 into trixi-framework:main Nov 13, 2023
32 of 34 checks passed
@bennibolm bennibolm deleted the subcell-limiting-minmax branch November 13, 2023 18:26
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.

5 participants