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

Add flexibility to nonconservative BCs #2200

Merged
merged 44 commits into from
Feb 7, 2025

Conversation

MarcoArtiano
Copy link
Contributor

@MarcoArtiano MarcoArtiano commented Dec 10, 2024

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

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 Dec 10, 2024

Codecov Report

Attention: Patch coverage is 93.18182% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.87%. Comparing base (f586b0d) to head (c85aba7).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/basic_types.jl 62.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2200      +/-   ##
==========================================
- Coverage   96.87%   96.87%   -0.01%     
==========================================
  Files         490      490              
  Lines       39463    39485      +22     
==========================================
+ Hits        38229    38248      +19     
- Misses       1234     1237       +3     
Flag Coverage Δ
unittests 96.87% <93.18%> (-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.

@MarcoArtiano
Copy link
Contributor Author

MarcoArtiano commented Dec 11, 2024

According to the way this feature has been implemented, the functions boundary_condition_slip_wall in shallow_water_wet_dry_1d.jl and shallow_water_wet_dry_2d.jl should have been modified accordingly.

CC @andrewwinters5000

@MarcoArtiano MarcoArtiano changed the title Add flexibility to nonconservative BCs WIP: Add flexibility to nonconservative BCs Dec 11, 2024
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.

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 ?

@MarcoArtiano MarcoArtiano marked this pull request as ready for review January 7, 2025 12:21
Copy link
Contributor

@DanielDoehring DanielDoehring left a comment

Choose a reason for hiding this comment

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

Thanks for this! The only thing that I suggest is using the little more verbose noncons_flux instead of noncons.

MarcoArtiano and others added 13 commits January 8, 2025 12:48
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
MarcoArtiano and others added 7 commits February 3, 2025 22:00
Co-authored-by: Patrick Ersing <114223904+patrickersing@users.noreply.github.com>
Co-authored-by: Patrick Ersing <114223904+patrickersing@users.noreply.github.com>
Co-authored-by: Patrick Ersing <114223904+patrickersing@users.noreply.github.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
Co-authored-by: Daniel Doehring <doehringd2@gmail.com>
DanielDoehring
DanielDoehring previously approved these changes Feb 6, 2025
@patrickersing patrickersing linked an issue Feb 6, 2025 that may be closed by this pull request
@ranocha
Copy link
Member

ranocha commented Feb 7, 2025

What's the status of this PR? We will have a breaking release soon and it would be nice to include this improvement.

@andrewwinters5000
Copy link
Member

What's the status of this PR? We will have a breaking release soon and it would be nice to include this improvement.

I will review it again today, but the feature itself has converged quite well. We have mainly been making small adjustments to the comments. It should (more or less) be good to go. What do you think @patrickersing ?

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!

@MarcoArtiano
Copy link
Contributor Author

I will add the docs today and commit the last few changes. After that everything should be fine, as already mentioned by @andrewwinters5000.

@patrickersing
Copy link
Contributor

What's the status of this PR? We will have a breaking release soon and it would be nice to include this improvement.

I will review it again today, but the feature itself has converged quite well. We have mainly been making small adjustments to the comments. It should (more or less) be good to go. What do you think @patrickersing ?

Yes, there are only a few minor changes remaining. So from my end this is ready to merge, once these have been addressed.

Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
MarcoArtiano and others added 3 commits February 7, 2025 11:07
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com>
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 also add a NEWS.md entry in the section of stuff that changed when updating to Trixi.jl v0.10?

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.

Thanks!

@ranocha ranocha merged commit ce4f75d into trixi-framework:main Feb 7, 2025
37 of 38 checks passed
Comment on lines +78 to 88
@inline function (::BoundaryConditionDoNothing)(u_inner,
orientation_or_normal_direction,
direction::Integer, x, t,
surface_flux_functions::Tuple,
equations)
surface_flux_function, nonconservative_flux_function = surface_flux_functions
return surface_flux_function(u_inner, u_inner,
orientation_or_normal_direction, equations),
nonconservative_flux_function(u_inner, u_inner,
orientation_or_normal_direction, equations)
end
Copy link
Member

Choose a reason for hiding this comment

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

codecov reports this function to be uncovered. Could you add a test for this, please?

Copy link
Member

Choose a reason for hiding this comment

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

...oh, was already merged in the same second 😅

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, didn't see that. @MarcoArtiano Could you please create a new PR with this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry, yes, I'm gonna make a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking enhancement New feature or request refactoring Refactoring code without functional changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistency in boundary conditions for nonconservative terms
6 participants