-
Notifications
You must be signed in to change notification settings - Fork 112
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
Fix noncons mortars for remaining mesh types #2134
Conversation
Review checklistThis 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
Code quality
Documentation
Testing
Performance
Verification
Created with ❤️ by the Trixi.jl community. |
Codecov ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Looks great to me!
I just have a couple of questions:
P4estMesh
2DThere 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.
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?
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) |
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.
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.
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.
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.
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, |
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.
Same as above. I now see that we would have to pass large_sides[mortar]
as an argument as well.
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.
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.
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.
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.
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.
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! 🙂
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.
# 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. |
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.
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?
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.
I may have just not noticed the possible reduction in my effort to quickly throw this together. I will have a look again.
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.
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 :)
# 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) |
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.
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
?
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.
That is a fair point to save on computation. We could take this copying strategy and just comment why it is being done.
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.
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.
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.
This is dealt with here (7eb20f2), right?
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.
Yes, that was my intention. The tests are not running in CI for some reason.
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 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
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 ? |
Yes 👍 |
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 . |
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 |
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. |
Thanks for making the issue! And yes we can finalize the Trixi2Vtk PR |
This is a 2D analog of #2127 .
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 theTrixi2Vtk
testing because the reference files used there are for Euler runs.