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

Refactor create_cache #106

Merged
merged 3 commits into from
May 20, 2024
Merged

Refactor create_cache #106

merged 3 commits into from
May 20, 2024

Conversation

JoshuaLampert
Copy link
Owner

@JoshuaLampert JoshuaLampert commented May 19, 2024

This passes the boundary_conditions to create_cache and dispatches on them instead of looking at the type of the SBP operators to infer whether the problem has periodic or reflecting boundary conditions, e.g. previously it was possible to use boundary_conditions_reflecting and pass periodic operators to the Solver, which meant that the create_cache function also created the cache for the periodic problem instead of for reflecting. This was a bit messy. This way it should work more as expected and is also easier to extend.
On the fly, I put tmp1(needed by the RelaxationCallback) into the intitial_cache instead of always creating it in create_cache, which is weird because tmp1 is sometimes not needed for the discretization itself.
Finally, I fixed the upwind discretization for the reflecting boundary conditions for the BBMBBMEquations1D, which was broken before. I also added a test in a similar manner as in #105.

pass and dispatch on boundary condition

put tmp1 to initial cache (always needed for the RelaxationCallback to work)

fix upwind discretization for BBMBBMEquations1D for reflecting boundary conditions and add test
Copy link

codecov bot commented May 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.71%. Comparing base (6d27850) to head (87611ae).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #106      +/-   ##
==========================================
+ Coverage   96.44%   96.71%   +0.26%     
==========================================
  Files          17       17              
  Lines        1125     1126       +1     
==========================================
+ Hits         1085     1089       +4     
+ Misses         40       37       -3     

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

@JoshuaLampert JoshuaLampert requested a review from ranocha May 19, 2024 18:44
ranocha
ranocha previously approved these changes May 20, 2024
Copy link
Collaborator

@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! I just have some minor comments that can either be resolved quickly or maybe postponed to later development (issues). Feel free to merge 👍

elseif solver.D1 isa DerivativeOperator ||
solver.D1 isa UniformCoupledOperator ||
solver.D1 isa UpwindOperators
invImD2 = inv(I - 1 / 6 * D^2 * Matrix(solver.D2))
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the long run, one should consider allowing more flexibility here. For example, FD methods should use sparse matrices and just a factorization instead of the inverse of a dense matrix. But that's not critical right now.

Copy link
Owner Author

@JoshuaLampert JoshuaLampert May 20, 2024

Choose a reason for hiding this comment

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

Yeah, you are definitely right. IIRC, when I tried that some time ago, I had some problems making that properly work, but I don't remember the exact issue. Back then I focused on something that just works and is easy to implement and understand. But of course this is not the most performant way. I created #107 for that.

src/equations/bbm_bbm_1d.jl Outdated Show resolved Hide resolved
@JoshuaLampert JoshuaLampert mentioned this pull request May 20, 2024
3 tasks
@JoshuaLampert JoshuaLampert merged commit 338f8f8 into main May 20, 2024
13 checks passed
@JoshuaLampert JoshuaLampert deleted the refactor-create-cache branch May 20, 2024 19:48
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.

2 participants