Skip to content

Make PST work for different smoothing length factors #834

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

efaulhaber
Copy link
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 Copilot, LasNikas and svchb June 16, 2025 10:20
@efaulhaber efaulhaber modified the milestone: 0.4 Jun 16, 2025
Copy link

@Copilot 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) *

Copy link

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.42%. Comparing base (4c72f4e) to head (508018a).
Report is 2 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.43%   70.42%   -0.02%     
==========================================
  Files         106      106              
  Lines        6867     6868       +1     
==========================================
  Hits         4837     4837              
- Misses       2030     2031       +1     
Flag Coverage Δ
unit 70.42% <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
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.

1 participant