-
Notifications
You must be signed in to change notification settings - Fork 113
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
WIP: Add flexibility to nonconservative BCs #2200
base: main
Are you sure you want to change the base?
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 #2200 +/- ##
==========================================
- Coverage 96.15% 89.92% -6.23%
==========================================
Files 483 483
Lines 38353 38364 +11
==========================================
- Hits 36876 34497 -2379
- Misses 1477 3867 +2390
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
According to the way this feature has been implemented, the functions |
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 for tackling this @MarcoArtiano! The functionality works as discussed where it is on the user to put in the boundary conditions for the conservative and nonconservative terms and then combine them appropriately, i.e., scaling noncons
with 0.5f0
. This is the only aspect I am not a huge fan of, as it is related to how the nonconservative terms are implemented at interfaces and has nothing to do with boundary conditions.
Because of this, we should maybe document where this factor of 0.5f0
magically comes from in the new boundary condition routines (as it was documented beofre inside the compute boundary flux call).
What do you think @patrickersing ?
# Note the factor 0.5 necessary for the nonconservative fluxes based on | ||
# the interpretation of global SBP operators coupled discontinuously via | ||
# central fluxes/SATs |
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 comment would possibly need added to where the factor of 0.5 scaling occurs.
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 am also not very content that we have to expose this to the user in order to specify the boundary condition, but I don't see a better way to accomplish this. I definitely think that we should comment this to give some explanation where the factor 0.5
comes from and that it is not specific to any boundary condition.
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 agree with all of you. I'm also not a huge fan of the factor 0.5
. We may alternatively return a tuple from the boundary conditions for non-conservative systems and multiply by 0.5 inside the solver. As an example:
flux_, noncons_ = boundary_condition(u_inner, normal_direction, x, t, surface_integral.surface_flux, equations)
# Copy flux to element storage in the correct orientation
for v in eachvariable(equations)
# Note the factor 0.5 necessary for the nonconservative fluxes based on
# the interpretation of global SBP operators coupled discontinuously via
# central fluxes/SATs
surface_flux_values[v, node_index, direction_index, element_index] = flux_[v] + 0.5f0 * noncons_[v]
end
What do you think?
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 like this idea, since it doesn't require knowledge about the implementation aspect of adding the 0.5
to create the boundary condition. It should work well for the BCs that are currently implemented, but I am not sure what this would look like for the new type of boundary condition that you plan to add. Would you then only set the flux_
part and set the noncons_
part to zero?
I think it would be helpful to include a specific example with such a new BC in the PR to better understand and evaluate what the implementation should look like.
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 also like this idea with the documentation of how it would work in practice from Patrick's comment above. That is, for something like the standard shallow water equations the jump in the bottom topography is zero at the physical boundary (typically) so one's new boundary condition could compute the conservative flux pieces and then have
return flux_, SVector(0,0,0,0) # flux, noncons
This PR allows to have more flexibility when defining the boundary conditions for a set of equations with nonconservative terms. This issues has been discussed in #2175. Now the user can define his own boundary condition, considering that the function accepts both surface flux and the nonconservative flux. An example can be found in elixir_mhd_reflective_wall