trixi-framework / Trixi.jl

Trixi.jl: Adaptive high-order numerical simulations of conservation laws in Julia
https://trixi-framework.github.io/Trixi.jl
MIT License
541 stars 110 forks source link

Help understanding flux limiter implementation #1129

Open xtalax opened 2 years ago

xtalax commented 2 years ago

Hi!

I'm the lead developer over at MethodOfLines.jl, and it's come time for me to implement flux limiters for use when solving Hyperbolic PDEs. In trying to understand how to do this for semidiscretized systems, I have come across what I think is your implementation. I'm wondering if you would help me understand what exactly this is doing to the elements of u, assuming for arguments sake that u is discretized on a uniform grid.

My understanding of what you are doing is this:

  1. You are finding the minimum value of some variable u.
  2. You then find the average value of u.
  3. You calculate theta with the expression on line 35.
  4. You store the result of the calculation in the second argument of the call in line 38, in that location in u

Is this correct?

I get the impression that this is for use with the finite element method. Any pointers on how this algorithm might map to the method of lines would be greatly appreciated.

As a sidenote, I'm impressed with Trixi after testing it briefly, and I think we are going to move towards calling out to it in cases where a user has specified an equation that can be solved with it. Thank you for your hard work!

jlchan commented 2 years ago

Hi Alex You've got the right idea. I should probably note that this is specific to discontinuous finite elements, so we can do limiting on each element separately while still retaining conservation.

For finite differences, I know there are similar positivity-preserving limiters which rewrite a finite difference scheme so that it looks like a finite volume scheme at each node. The reconstructions of variables like density or pressure at the faces are then limited in a similar fashion as in Trixi.jl to ensure positivity.

There's also flux-corrected transport approaches and some generalizations https://arxiv.org/abs/1807.02563 and https://arxiv.org/abs/1807.02563, which can be directly applied to finite difference methods. Here, the authors basically use two methods - a stable but low order accurate FD method and a high order method which might require limiting. They blend the two schemes together at each time-step to guarantee positivity while retaining conservation.

One thing to note is that in both cases, these limiters generally require SSPRK methods to guarantee positivity preservation (the limiter is designed for a forward Euler step, and SSPRK methods take convex combinations of FE steps which preserve positivity).

I might be missing something, so I might wait for any of the other Trixi.jl devs to chime in.

ranocha commented 2 years ago

Hi @xtalax! I guess you will also be interested in shock capturing when thinking about flux limiters. You can find some hints in one of our tutorials on this topic and an implementation in Trixi.jl. This tutorial also mentions the positivity-preserving limiter you linked above (which Jesse has already described).

ranocha commented 2 years ago

By the way, I would not say it's something like method of lines vs. finite elements - for me, method of lines just means that you discretize space at first and time afterwards using an ODE solver (for a time-dependent PDE). Trixi.jl also uses this methods of lines approach - but with discontinuous Galerkin methods (some sort of finite elements) in space. The positivity-preserving limiter of Zhang and Shu goes a bit outside of this framework since it somewhat couples time and space discretizations.