Trixi.jl icon indicating copy to clipboard operation
Trixi.jl copied to clipboard

EC mortars: Tree 2D

Open DanielDoehring opened this issue 1 year ago • 9 comments

I tried to port https://github.com/trixi-framework/Trixi.jl/pull/247 to Trixi's current state. Does currently not work - not sure if I did a mistake or if the original draft was flawed.

@amrueda

DanielDoehring avatar Mar 05 '25 22:03 DanielDoehring

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 :heart: by the Trixi.jl community.

github-actions[bot] avatar Mar 05 '25 22:03 github-actions[bot]

Codecov Report

Attention: Patch coverage is 97.29730% with 4 lines in your changes missing coverage. Please review.

Project coverage is 96.91%. Comparing base (dc8cd7e) to head (d3085f0).

Files with missing lines Patch % Lines
src/solvers/dgsem/basis_lobatto_legendre.jl 83.33% 3 Missing :warning:
src/solvers/dgsem_tree/dg_2d.jl 98.97% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2302      +/-   ##
==========================================
- Coverage   96.91%   96.91%   -0.00%     
==========================================
  Files         496      497       +1     
  Lines       41140    41267     +127     
==========================================
+ Hits        39870    39993     +123     
- Misses       1270     1274       +4     
Flag Coverage Δ
unittests 96.91% <97.30%> (-<0.01%) :arrow_down:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Mar 06 '25 18:03 codecov[bot]

Does currently not work - not sure if I did a mistake or if the original draft was flawed.

What exactly does not work? IIRC (though that's from >4 years ago), the final version of the original PR was fully functional for at least one test setup and did show proper convergence behavior as well as EC properties.

sloede avatar Mar 20 '25 08:03 sloede

What exactly does not work? IIRC (though that's from >4 years ago), the final version of the original PR was fully functional for at least one test setup and did show proper convergence behavior as well as EC properties.

Not sure, the current version seems to be correct - (although there are some allocations that need to be removed). My first try did not work, this is why I have not touched this for a long time. I believe https://github.com/trixi-framework/Trixi.jl/pull/2134 resolved this.

DanielDoehring avatar Mar 25 '25 16:03 DanielDoehring

Convergence test:

####################################################################################################
l2
rho                 rho_v1              rho_v2              rho_e               
error     EOC       error     EOC       error     EOC       error     EOC       
6.13e-04  -         2.49e-02  -         2.64e-02  -         5.80e-02  -         
8.40e-05  2.87      3.43e-03  2.86      3.74e-03  2.82      8.20e-03  2.82      
2.98e-06  4.82      1.58e-04  4.44      1.52e-04  4.62      3.19e-04  4.68      
7.15e-08  5.38      4.71e-06  5.06      3.94e-06  5.27      7.94e-06  5.33      

mean      4.35      mean      4.12      mean      4.24      mean      4.28      
----------------------------------------------------------------------------------------------------
linf
rho                 rho_v1              rho_v2              rho_e               
error     EOC       error     EOC       error     EOC       error     EOC       
1.15e-02  -         3.02e-01  -         2.88e-01  -         1.04e+00  -         
1.68e-03  2.77      4.73e-02  2.67      5.28e-02  2.45      1.69e-01  2.63      
7.23e-05  4.54      2.67e-03  4.15      2.42e-03  4.45      7.14e-03  4.57      
2.35e-06  4.95      1.28e-04  4.38      1.21e-04  4.32      2.61e-04  4.78      

mean      4.08      mean      3.73      mean      3.74      mean      3.99      
----------------------------------------------------------------------------------------------------

I suspect that the superconvergence is due to the refinement patch.

For the standard L2 mortar:

####################################################################################################
l2
rho                 rho_v1              rho_v2              rho_e               
error     EOC       error     EOC       error     EOC       error     EOC       
6.11e-04  -         2.48e-02  -         2.61e-02  -         5.78e-02  -         
8.47e-05  2.85      3.49e-03  2.83      3.75e-03  2.80      8.30e-03  2.80      
2.86e-06  4.89      1.52e-04  4.52      1.46e-04  4.68      3.03e-04  4.78      
5.60e-08  5.68      3.57e-06  5.41      3.19e-06  5.52      6.13e-06  5.63      

mean      4.47      mean      4.25      mean      4.33      mean      4.40      
----------------------------------------------------------------------------------------------------
linf
rho                 rho_v1              rho_v2              rho_e               
error     EOC       error     EOC       error     EOC       error     EOC       
1.14e-02  -         3.02e-01  -         2.85e-01  -         1.04e+00  -         
1.70e-03  2.75      4.86e-02  2.64      5.22e-02  2.45      1.70e-01  2.61      
7.21e-05  4.56      2.67e-03  4.19      2.33e-03  4.48      6.95e-03  4.62      
1.89e-06  5.25      7.37e-05  5.18      6.75e-05  5.11      1.62e-04  5.42      

mean      4.19      mean      4.00      mean      4.01      mean      4.22      
----------------------------------------------------------------------------------------------------

To test the entropy-conservation property I probably need to run this with an EC integrator.

DanielDoehring avatar Mar 26 '25 10:03 DanielDoehring

To test the entropy-conservation property I probably need to run this with an EC integrator.

Yes, but an arguably easier test would be to have a refined mesh and use it with an entropy-generating setup, and to then verify that a call to rhs! will produce an EC update.

For example, the weak blast wave is usually such a test, since it does want to produce entropy. Another option for an initial condition is to just randomly initialize the conservative variables (in a physically valid state of course) such that you get small jumps - that would ordinarily produce entropy - everywhere.

sloede avatar Mar 27 '25 08:03 sloede

A broader question - why are the parabolic routines modified? the mortars should only impact the hyperbolic interface flux computations?

Yeah that looks a bit odd. The reason is that the p4est mesh reuses the rhs! from the TreeMesh, which now passes also the u vector as an argument. As the parabolic p4est implementation re-uses some functions of the hyperbolic p4est implementation we have now the observed changes.

DanielDoehring avatar Mar 27 '25 12:03 DanielDoehring

So something is not quite working yet. I do not yet get entropy conservation, but more importantly, conservation of cons. variables is violated.

DanielDoehring avatar Mar 27 '25 13:03 DanielDoehring

The current implementation of the mortars has primary and secondary fluxes, while the implementation had only one (probably primary) . Maybe the bug is somewhere there.

DanielDoehring avatar Mar 30 '25 15:03 DanielDoehring