Skip to content

Make PST work for different smoothing length factors#834

Merged
svchb merged 7 commits intotrixi-framework:mainfrom
efaulhaber:fix-shifting
Jul 23, 2025
Merged

Make PST work for different smoothing length factors#834
svchb merged 7 commits intotrixi-framework:mainfrom
efaulhaber:fix-shifting

Conversation

@efaulhaber
Copy link
Copy Markdown
Member

@efaulhaber efaulhaber commented Jun 16, 2025

On main, PST doesn't work for small smoothing length factors. The following examples are all with the Wendland C2 kernel.

h = 1.5 * Δx h = 2.5 * Δx
Δx = 0.02, Δt = 5e-3 grafik grafik

This PR makes it work for a wide range of time steps, smoothing length factors, and resolutions:

h = 1.5 * Δx h = 2.5 * Δx
Δx = 0.02, Δt = 1e-3 grafik grafik
Δx = 0.02, Δt = 5e-3 grafik grafik
Δx = 0.01, Δt = 5e-3 grafik grafik
Δx = 0.05, Δt = 1e-2 grafik grafik

@efaulhaber efaulhaber added the bug Something isn't working label Jun 16, 2025
@efaulhaber efaulhaber self-assigned this Jun 16, 2025
@efaulhaber efaulhaber requested review from LasNikas, Copilot and svchb June 16, 2025 10:20
@efaulhaber efaulhaber modified the milestone: 0.4 Jun 16, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the particle shifting callback to correctly handle a range of smoothing length factors by introducing a dedicated dx variable and updating the shift magnitude calculation.

  • Extracted particle_spacing(system, 1) into dx and reused it for kernel evaluation.
  • Replaced the original linear-in-h formula with a quadratic-in-h and linear-in-dx scaling for delta_r_, adding comments to explain the change.
Comments suppressed due to low confidence (2)

src/callbacks/particle_shifting.jl:108

  • [nitpick] Referencing an internal PR link in comments can be brittle; consider citing the original paper (Sun et al. 2017, p.29) or documenting the rationale in the external changelog instead.
# See https://github.com/trixi-framework/TrixiParticles.jl/pull/834.

src/callbacks/particle_shifting.jl:109

  • The new shifting formula significantly alters particle behavior; consider adding unit or integration tests that verify correct behavior across small and large smoothing length factors.
delta_r_ = -dt * v_max * (2 * h)^2 / (2 * dx) * (1 + R * (kernel / Wdx)^n) *

Comment thread src/callbacks/particle_shifting.jl
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 16, 2025

Codecov Report

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

Project coverage is 70.45%. Comparing base (ac2acd2) to head (0909b81).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/callbacks/particle_shifting.jl 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #834      +/-   ##
==========================================
- Coverage   70.46%   70.45%   -0.02%     
==========================================
  Files         106      106              
  Lines        6894     6895       +1     
==========================================
  Hits         4858     4858              
- Misses       2036     2037       +1     
Flag Coverage Δ
unit 70.45% <0.00%> (-0.02%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@efaulhaber efaulhaber marked this pull request as draft June 16, 2025 13:12
@efaulhaber efaulhaber marked this pull request as ready for review June 16, 2025 17:08
Comment thread src/callbacks/particle_shifting.jl
@efaulhaber
Copy link
Copy Markdown
Member Author

Please verify that this is also correct for 3D cases.

This is a slice of the same vortex street simulation in 3D, where the cylinder is now a full sphere.
Top is 1.5Δx, bottom is 2.5Δx. Both with this branch.
anim 0004

On main:
anim 0005

So I guess this is fine in 3D. We will probably only be using consistent shifting in the future anyway.

@svchb
Copy link
Copy Markdown
Collaborator

svchb commented Jul 23, 2025

/run-gpu-tests

@svchb svchb enabled auto-merge (squash) July 23, 2025 11:18
@svchb svchb merged commit 9972df0 into trixi-framework:main Jul 23, 2025
16 of 18 checks passed
@efaulhaber efaulhaber deleted the fix-shifting branch July 31, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants