Skip to content

Make dv_shifting, surface_tension_force and adhesion_force inplace#1124

Merged
LasNikas merged 7 commits intotrixi-framework:mainfrom
efaulhaber:inplace-dv
Apr 10, 2026
Merged

Make dv_shifting, surface_tension_force and adhesion_force inplace#1124
LasNikas merged 7 commits intotrixi-framework:mainfrom
efaulhaber:inplace-dv

Conversation

@efaulhaber
Copy link
Copy Markdown
Member

@efaulhaber efaulhaber commented Apr 1, 2026

This PR makes dv_shifting, surface_tension_force and adhesion_force inplace and is part of #1131. Instead of accumulating zero SVectors when no shifting/surface tension/adhesion is used, these functions are now no-ops. It also reduces the number of live variables, which reduces register pressure.

Note that these optimizations make almost no difference on modern Hopper GPUs, but are very noticable on older Ampere GPUs.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 91.37931% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.70%. Comparing base (155f9f1) to head (20da330).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/schemes/fluid/surface_tension.jl 81.48% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1124      +/-   ##
==========================================
- Coverage   88.71%   88.70%   -0.01%     
==========================================
  Files         128      128              
  Lines        9752     9764      +12     
==========================================
+ Hits         8651     8661      +10     
- Misses       1101     1103       +2     
Flag Coverage Δ
total 88.70% <91.37%> (-0.01%) ⬇️
unit 66.95% <56.36%> (-0.05%) ⬇️

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.

Copy link
Copy Markdown

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 SPH interaction terms (dv_shifting, surface_tension_force, adhesion_force) to be in-place updates (no-ops when disabled) instead of returning/accumulating zero vectors, aiming to reduce live SSA values and register pressure (notably on older GPUs).

Changes:

  • Replaced returned-vector helpers with in-place ...! variants and updated fluid/structure RHS interaction loops to accumulate into a single mutable accumulator.
  • Updated surface tension and shifting technique implementations to add their contributions directly into the accumulator (including passing a surface_tension_correction factor in-place).
  • Adjusted VTK output computation to use the in-place surface tension force to accumulate per-particle diagnostics.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/schemes/structure/structure.jl Switches structure–fluid interaction to an in-place adhesion contribution via a mutable accumulator.
src/schemes/structure/rigid_body/system.jl Converts rigid-body adhesion force helper into an in-place adhesion_force!.
src/schemes/fluid/weakly_compressible_sph/rhs.jl Updates WCSPH RHS interaction loop to accumulate shifting/surface tension/adhesion contributions in-place.
src/schemes/fluid/surface_tension.jl Refactors surface tension + boundary adhesion force APIs to ...! and applies correction factor internally.
src/schemes/fluid/shifting_techniques.jl Refactors shifting momentum-term API to in-place dv_shifting! and updates implementations accordingly.
src/schemes/fluid/entropically_damped_sph/rhs.jl Updates EDAC RHS interaction loop to use in-place shifting/surface tension/adhesion accumulation.
src/io/write_vtk.jl Updates surface tension diagnostic accumulation to use the new in-place API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@efaulhaber efaulhaber marked this pull request as ready for review April 7, 2026 16:33
@efaulhaber efaulhaber self-assigned this Apr 7, 2026
@efaulhaber efaulhaber requested a review from svchb April 7, 2026 16:34
@svchb svchb self-requested a review April 10, 2026 14:07
@svchb svchb enabled auto-merge (squash) April 10, 2026 14:08
@svchb
Copy link
Copy Markdown
Collaborator

svchb commented Apr 10, 2026

/run-gpu-tests

@LasNikas LasNikas disabled auto-merge April 10, 2026 15:28
@LasNikas LasNikas enabled auto-merge (squash) April 10, 2026 18:46
@LasNikas
Copy link
Copy Markdown
Collaborator

/run-gpu-tests

@LasNikas LasNikas merged commit 3a5900a into trixi-framework:main Apr 10, 2026
17 checks passed
@efaulhaber efaulhaber deleted the inplace-dv branch April 13, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants