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

Fix noncons mortars for remaining mesh types #2134

Merged
merged 12 commits into from
Nov 14, 2024

Conversation

andrewwinters5000
Copy link
Member

@andrewwinters5000 andrewwinters5000 commented Oct 29, 2024

This is a 2D analog of #2127 .

  • P4estMesh 2D
  • TreeMesh 2D
  • TreeMesh 3D

The downstream tests for Trixi2Vtk are failing because the MHD rotor output was used for testing of these conversion routines. So the reference files for Trixi2Vtk would need to be updated.

Looking toward fixing the TreeMesh, these should not mess with the Trixi2Vtk testing because the reference files used there are for Euler runs.

Copy link
Contributor

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.

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 92.22222% with 14 lines in your changes missing coverage. Please review.

Project coverage is 89.93%. Comparing base (c45f919) to head (b20e587).

Files with missing lines Patch % Lines
src/solvers/dgsem_tree/dg_2d_parallel.jl 0.00% 12 Missing ⚠️
src/solvers/dgsem_p4est/dg_2d_parallel.jl 0.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (c45f919) and HEAD (b20e587). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (c45f919) HEAD (b20e587)
unittests 26 23
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2134      +/-   ##
==========================================
- Coverage   96.36%   89.93%   -6.43%     
==========================================
  Files         477      477              
  Lines       37760    37823      +63     
==========================================
- Hits        36385    34015    -2370     
- Misses       1375     3808    +2433     
Flag Coverage Δ
unittests 89.93% <92.22%> (-6.43%) ⬇️

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 ranocha requested a review from amrueda October 29, 2024 11:05
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.

Looks great to me!
I just have a couple of questions:

src/solvers/dgsem_p4est/dg_2d.jl Show resolved Hide resolved
test/test_parabolic_2d.jl Outdated Show resolved Hide resolved
@andrewwinters5000 andrewwinters5000 changed the title Fix noncons mortars for P4estMesh 2D Fix noncons mortars for remaining mesh types Oct 29, 2024
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.

Looks good to me! Thanks for adding this, @andrewwinters5000!

All my comments are about the repeated flux computations. One possibility would be to merge this as is, and create an issue (and maybe a new PR, if you have time/interest) about that. Would that be a good way to proceed, @sloede @ranocha?

Comment on lines -917 to 930
calc_fstar!(fstar_upper, equations, surface_flux, dg, u_upper, mortar,
calc_fstar!(fstar_primary_upper, equations, surface_flux, dg, u_upper, mortar,
orientation)
calc_fstar!(fstar_lower, equations, surface_flux, dg, u_lower, mortar,
calc_fstar!(fstar_primary_lower, equations, surface_flux, dg, u_lower, mortar,
orientation)
calc_fstar!(fstar_secondary_upper, equations, surface_flux, dg, u_upper, mortar,
orientation)
calc_fstar!(fstar_secondary_lower, equations, surface_flux, dg, u_lower, mortar,
orientation)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest to modify the function calc_fstar!, such that it takes fstar_primary and fstar_secondary as arguments and dispatch on nonconservative_terms. That way, we can save some computations for both conservative and non-conservative systems.

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically, to try and mimic how the P4estMesh passes this information around? I agree that this would avoid future confusion to unify the strategies across mesh types. Although this might be something better left to another PR.

Comment on lines -946 to +966
calc_fstar!(fstar_upper, equations, surface_flux, dg, u_upper, mortar,
calc_fstar!(fstar_primary_upper, equations, surface_flux, dg, u_upper, mortar,
orientation)
calc_fstar!(fstar_primary_lower, equations, surface_flux, dg, u_lower, mortar,
orientation)
calc_fstar!(fstar_secondary_upper, equations, surface_flux, dg, u_upper, mortar,
orientation)
calc_fstar!(fstar_lower, equations, surface_flux, dg, u_lower, mortar,
calc_fstar!(fstar_secondary_lower, equations, surface_flux, dg, u_lower, mortar,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. I now see that we would have to pass large_sides[mortar] as an argument as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, good point. I need to investigate this further. The TreeMesh and how it handles the mortars is a bit cumbersome / different from how I am used to.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, unifying the strategy to compute the mortar fluxes via a "smarter" calc_fstar! routine is indeed cumbersome. It would help readibility, but it is beyond this current PR (as well as my current bandwidth of projects to handle). I could open an issue and/or add such a unification to an existing mortar issue if one exists.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not aware of an existing issue that is related to this. It would be great if you can create one add a link to this PR to it! 🙂

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines +781 to +782
# Because `nonconservative_terms` is `False` the primary and secondary fluxes
# are identical. So, we could possibly save on computation and just pass two copies later.
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that you also considered a different implementation with fewer calls to the flux function. This would save computations also for the non-conservative terms. Is there any reason why you decided to use this implementation?

Copy link
Member Author

Choose a reason for hiding this comment

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

I may have just not noticed the possible reduction in my effort to quickly throw this together. I will have a look again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking again, I think I sacrificed efficiency (in this case) for parity with the non-parallel version of this routine. The mortar computations are already a bit confusing, I did not want to further increase the confusion :)

Comment on lines 747 to 764
# Calculate fluxes
orientation = orientations[mortar]
calc_fstar!(fstar_upper_left, equations_parabolic, surface_flux, dg,
u_upper_left, mortar,
orientation)
calc_fstar!(fstar_upper_right, equations_parabolic, surface_flux, dg,
u_upper_right,
mortar, orientation)
calc_fstar!(fstar_lower_left, equations_parabolic, surface_flux, dg,
u_lower_left, mortar,
orientation)
calc_fstar!(fstar_lower_right, equations_parabolic, surface_flux, dg,
u_lower_right,
mortar, orientation)
calc_fstar!(fstar_primary_upper_left, equations_parabolic, surface_flux, dg,
u_upper_left, mortar, orientation)
calc_fstar!(fstar_primary_upper_right, equations_parabolic, surface_flux, dg,
u_upper_right, mortar, orientation)
calc_fstar!(fstar_primary_lower_left, equations_parabolic, surface_flux, dg,
u_lower_left, mortar, orientation)
calc_fstar!(fstar_primary_lower_right, equations_parabolic, surface_flux, dg,
u_lower_right, mortar, orientation)
calc_fstar!(fstar_secondary_upper_left, equations_parabolic, surface_flux, dg,
u_upper_left, mortar, orientation)
calc_fstar!(fstar_secondary_upper_right, equations_parabolic, surface_flux, dg,
u_upper_right, mortar, orientation)
calc_fstar!(fstar_secondary_lower_left, equations_parabolic, surface_flux, dg,
u_lower_left, mortar, orientation)
calc_fstar!(fstar_secondary_lower_right, equations_parabolic, surface_flux, dg,
u_lower_right, mortar, orientation)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the parabolic discretization is conservative, it might be cleaner (and cheaper) to call the function four times for the primary fstar and then copy the solution to the secondary fstar?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is a fair point to save on computation. We could take this copying strategy and just comment why it is being done.

Copy link
Member Author

Choose a reason for hiding this comment

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

Aha, the reason I did it this way was that there was no 3D parabolic version of the mortar_fluxes_to_elements routine that specializes on AbstractEquationsParabolic like is present for the 2D counterpart. I will throw together such a 3D routine to save on computation.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is dealt with here (7eb20f2), right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that was my intention. The tests are not running in CI for some reason.

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.

Thanks again!
I think the only missing things are:

  • To create an issue about the possible performance improvements.
  • To update the Downstream tests for Trixi2Vtk.jl

@andrewwinters5000
Copy link
Member Author

  • To create an issue about the possible performance improvements.

  • To update the Downstream tests for Trixi2Vtk.jl

I can create such an issue. I already have a PR open in Trixi2Vtk that updates the tests there. However, I think we need to merge this PR first and then release a new Trixi version such that the Trixi2Vtk has it available. Am I remembering correctly @ranocha ?

@sloede
Copy link
Member

sloede commented Nov 14, 2024

However, I think we need to merge this PR first and then release a new Trixi version such that the Trixi2Vtk has it available. Am I remembering correctly

Yes 👍

@ranocha
Copy link
Member

ranocha commented Nov 14, 2024

I created issue #2163 to track the suggestions @amrueda made above. We are basically ready to merge this PR, @andrewwinters5000, so that the Trixi2Vtk.jl PR can be finalized, correct?

@amrueda
Copy link
Contributor

amrueda commented Nov 14, 2024

I created issue #2163 to track the suggestions @amrueda made above. We are basically ready to merge this PR, @andrewwinters5000, so that the Trixi2Vtk.jl PR can be finalized, correct?

Thanks @ranocha .
I think everything is ready for this PR. However, some tests were failing for no apparent reason (see, e.g., https://github.com/trixi-framework/Trixi.jl/actions/runs/11838336501/job/32987230489?pr=2134#step:10:71). I just restarted them to see what happens.

@ranocha
Copy link
Member

ranocha commented Nov 14, 2024

Codecov fails again. I'll merge the PR. Please keep the discussion above unresolved so that we can easily see them when working on #2163

@ranocha ranocha merged commit 07f960f into trixi-framework:main Nov 14, 2024
7 of 33 checks passed
@JoshuaLampert
Copy link
Member

Regarding the failing codecov: It usually helps to create a PR from the main repo (i.e. not from a fork) if possible. These errors are usually related to tokenless upload from forks, see also #1905 and the linked issue there.

@andrewwinters5000
Copy link
Member Author

I created issue #2163 to track the suggestions @amrueda made above. We are basically ready to merge this PR, @andrewwinters5000, so that the Trixi2Vtk.jl PR can be finalized, correct?

Thanks for making the issue! And yes we can finalize the Trixi2Vtk PR

@andrewwinters5000 andrewwinters5000 deleted the fix-noncons-mortars branch November 14, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent non-conservative mortars
5 participants