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

Merged
merged 17 commits into from
Oct 10, 2024

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.

src/equations/ideal_glm_mhd_2d.jl Show resolved Hide resolved
@DanielDoehring DanielDoehring mentioned this pull request Sep 18, 2024
10 tasks
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.

It looks good. I leave here only a couple of comments.

src/basic_types.jl Show resolved Hide resolved
src/basic_types.jl Show resolved Hide resolved
src/equations/ideal_glm_mhd_2d.jl Show resolved Hide resolved
src/equations/ideal_glm_mhd_3d.jl Show resolved Hide resolved
@ranocha
Copy link
Member

ranocha commented Sep 30, 2024

A lot of tests fail. Could you please check what's going on?

@patrickersing
Copy link
Contributor Author

A lot of tests fail. Could you please check what's going on?

Most tests are failing, because we get slightly different results with the averaged normal direction. Since there haven't been any objections, I will proceed and update the reference values to fix the tests.

To fix the downstream test for TrixiShallowWater.jl I prepared a corresponding PR trixi-framework/TrixiShallowWater.jl#58, that needs to be merged after this one.

Copy link

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.34%. Comparing base (480aea9) to head (dc95c26).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/solvers/dgmulti/flux_differencing.jl 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2062      +/-   ##
==========================================
- Coverage   96.34%   96.34%   -0.00%     
==========================================
  Files         470      470              
  Lines       37497    37495       -2     
==========================================
- Hits        36125    36123       -2     
  Misses       1372     1372              
Flag Coverage Δ
unittests 96.34% <96.30%> (-<0.01%) ⬇️

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

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

@ranocha
Copy link
Member

ranocha commented Oct 2, 2024

@amrueda Could you please review this PR again?

Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Could you please add some NEWS.md?

@ranocha
Copy link
Member

ranocha commented Oct 9, 2024

@amrueda There are still some open conversations from your review. Could you please have a look at them?

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!

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!

@patrickersing
Copy link
Contributor Author

@andrewwinters5000 @amrueda thanks for the reviews!

@ranocha From my end this is then ready to be merged. I noticed that the invalidations test is failing, but that should not be related to this PR.

@patrickersing patrickersing requested a review from ranocha October 9, 2024 13:08
@ranocha
Copy link
Member

ranocha commented Oct 10, 2024

I noticed that the invalidations test is failing, but that should not be related to this PR.

Yes, that's an upstream issue: timholy/SnoopCompile.jl#397

Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Thank you all!

@ranocha ranocha merged commit 1494aa2 into trixi-framework:main Oct 10, 2024
34 of 37 checks passed
@patrickersing patrickersing deleted the remove_normal_direction_ll branch October 10, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants