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

Remove normal_direction_ll for nonconservative terms #2062

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

patrickersing
Copy link
Contributor

@patrickersing patrickersing commented Sep 4, 2024

This PR simplifies the nonconservative terms to only depend on a single averaged normal_direction, instead of both normal_direction_average and normal_direction_ll (see #2049).
This should also enable setting boundary conditions for nonconservative terms #1445

Copy link
Contributor

github-actions bot commented Sep 4, 2024

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.

@patrickersing
Copy link
Contributor Author

As expected changing the normal directions caused slightly different results and with that some failing mhd tests.
The p4est and t8code test results are almost the same and only the psi value fails testing with differences in L2 between 1e-8 and 1e-10.
For UnstructuredMesh and StructuredMesh there are more failing tests, but the differences in the L2-Error remain relatively small between 1e-5 and 1e-8. The reason is probably that we use a very coarse mesh for the testing, with only four elements per dimension, which leads to larger differences in the normal direction.
Entropy is still conserved in all relevant tests.

For validation I additionally ran convergence tests using structured_2d/elixir_mhd_alfen_wave.jl and compared the result with the previous implementation using normal_direction_ll. The results show almost identical convergence rates.

polydeg=3, normal_direction_average:
Convergence_structured2D_P3_average

polydeg=3, normal_direction_ll:
Convergence_structured2D_P3_inner

polydeg=4, normal_direction_average:
Convergence_structured2D_P4_average

polydeg=4, normal_direction_ll:
Convergence_structured2D_P4_inner

Looking at these results, I think it would be fine to introduce the averaged normal direction and update the test values.
It would be great if someone working with MHD (maybe @amrueda @SimonCan @andrewwinters5000) can have a look at this and let me know if they think this is fine or if more validation is needed.

Another open problem is that the test dgmulti_2d/elixir_mhd_reflective_wall.jl is failing. @jlchan do you have any idea why this test could be failing?

@jlchan
Copy link
Contributor

jlchan commented Sep 5, 2024

Another open problem is that the test dgmulti_2d/elixir_mhd_reflective_wall.jl is failing. @jlchan do you have any idea why this test could be failing?

Thanks for testing it out in DGMulti too! I'll take a look this afternoon.

Since the test is failing due to domain error (negative density or pressure) I think it's a real failure. My guess is that it's related to the boundary condition imposition

noncons_flux_at_face_node = boundary_condition(u_face_values[i, f],
face_normal,
face_coordinates,
t,
nonconservative_flux,
equations)

since all the other MHD tests still pass.

@patrickersing
Copy link
Contributor Author

Since the test is failing due to domain error (negative density or pressure) I think it's a real failure. My guess is that it's related to the boundary condition imposition

That makes sense. I just looked at the boundary conditions that are used in the elixir and noticed that BoundaryConditionDoNothing needs to be adapted. Currently this always calls the flux function (even if we call it with the nonconservative term) so this definitely imposes a wrong boundary condition.

I will try to replace this with

@inline function (::BoundaryConditionDoNothing)(u_inner,
                                                outward_direction::AbstractVector,
                                                x, t, surface_flux, equations)
    #return flux(u_inner, outward_direction, equations)
    return surface_flux(u_inner, u_inner, outward_direction, equations)
end```

@jlchan
Copy link
Contributor

jlchan commented Sep 6, 2024

@patrickersing looks like your new BoundaryConditionDoNothing fixed the issue; the failing tests for unstructured_dgmulti now just seem to be due to floating point differences.

@patrickersing patrickersing changed the title [WIP] Remove normal_direction_ll for nonconservative terms Remove normal_direction_ll for nonconservative terms Sep 10, 2024
@DanielDoehring
Copy link
Contributor

Once this is ready to go we can schedule the next breaking release 0.9, cf. #1997

@patrickersing patrickersing marked this pull request as ready for review September 12, 2024 09:58
Copy link
Member

@andrewwinters5000 andrewwinters5000 left a comment

Choose a reason for hiding this comment

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

LGTM! I just left one question for Andrés. It would be good to get this PR ship-shape and ready for the next breaking release. Can you have a look @amrueda or @SimonCan as you both more actively work with the MHD system.

Comment on lines +291 to +293
et al. [`flux_nonconservative_powell`](@ref) for conforming meshes but it yields different
results on non-conforming meshes(!). On curvilinear meshes this formulation applies the
local normal direction compared to the averaged one used in [`flux_nonconservative_powell`](@ref).
Copy link
Member

Choose a reason for hiding this comment

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

This would also be true in 3D but the subcell limiting implementation is not done (yet) right @amrueda ? That is why a corresponding comment in the 3D ideal GLM-MHD file is not done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants