-
Notifications
You must be signed in to change notification settings - Fork 99
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
Division by zero in zero function case #1371
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Please find a comment below. Could you please also add a test for this?
More changes pending Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
I am wondering though if this is the right strategy. The indicator was designed to work with an "energy-like" quantity, such as the total energy. If you are using a different quantity that is not strictly positive, I am not sure if it still makes sense to use the indicator. Wouldn't it be better to fix the positivity in the variable selection function? E.g., if you have a function that extracts the jump, can you just make it |
I don't understand what you say here. I guess this is meant for something like an identically vanishing solution, where you just have vanishing energy. |
Suggested change 1 Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Suggested change 2 Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Suggested change 3 Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Suggested change 3 Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Suggested change 4 Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Thanks! We need to wait for a hotfix of some CI issues caused by upstream changes. |
I think I misunderstood something from the description of the PR, so what I wrote before does not really make that much sense, sorry. I am still wondering: Does it really make sense to test for equality to zero in the general case, and what is the performance impact of that change? I have rarely encountered a situation where testing for zero makes sense in practice for floating point numbers. AFAICT, this will only happen for very special initial conditions (as otherwise it will never hit zero exactly), thus I wonder if it would make more sense to modify the initial conditions instead? |
Modifying the initial conditions is also fine but the library should give the user the right error when they do use a vanishing initial condition. The previous works of Persson-Peraire (2006) and Klockner Et Al (2011) test such indicators on initial conditions that vanish at some points. So, I might naively expect Trixi's indicator to also work out of the box. |
You are right, the current situation is not satisfying insofar it leaves the user with weird errors and no documentation on this issue. I am just trying to figure out what the best solution is for everyone in Trixi.jl. Maybe it is indeed the approach chosen in this PR 🙂 |
examples/structured_1d_dgsem/elixir_advection_shockcapturing.jl
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this LGTM. My only concern is that this negatively affects performance, but since there are already a number of if statements in that loop, and some other expensive operations, I guess it's OK 🙂
In the smoothness indicator function, we can encounter division by zero in computing
This will never occur if the indicator variable comprises of positive quantity but indicator variable may not always be positive (example, testing a jump discontinuity in linear advection or Burger's equation)
One way to handle this is by putting an
if
in casetotal_energy
is zero (currently in PR, will extend to other files if that is okay). The better way isbut this will technically change all other cases. Another option which won't interfere existing code is
All of these options do fix the issue in my test case of interest (1-D multiple profile).