Skip to content

Conversation

@efaulhaber
Copy link
Member

@efaulhaber efaulhaber commented Oct 6, 2025

This PR implements the second version demonstrated in #897:

A cheaper version that evaluates the forces on "fixed" particles only in a callback and then integrates the energy with the explicit Euler method. In my small experiment this added a 6% overhead vs 25% of version 1. It can be made even cheaper by applying the callback only every n steps at the cost of larger time integration errors.

@efaulhaber efaulhaber added the enhancement New feature or request label Oct 6, 2025
@efaulhaber efaulhaber self-assigned this Oct 6, 2025
@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 73.80952% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.70%. Comparing base (433e394) to head (93273d9).

Files with missing lines Patch % Lines
src/callbacks/energy_calculator.jl 74.64% 18 Missing ⚠️
test/examples/examples.jl 0.00% 2 Missing ⚠️
src/callbacks/split_integration.jl 0.00% 1 Missing ⚠️
test/callbacks/energy_calculator.jl 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #940      +/-   ##
==========================================
+ Coverage   64.45%   64.70%   +0.25%     
==========================================
  Files         117      119       +2     
  Lines        8122     8203      +81     
==========================================
+ Hits         5235     5308      +73     
- Misses       2887     2895       +8     
Flag Coverage Δ
unit 64.70% <73.80%> (+0.25%) ⬆️

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 requested a review from Copilot October 6, 2025 12:44
Copy link

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 implements the EnergyCalculatorCallback, a second version of energy calculation that evaluates forces on "fixed" (clamped) particles and integrates energy using explicit Euler method. The implementation provides a more efficient alternative to previous energy calculation approaches, adding only ~6% overhead compared to 25% of an earlier version.

  • Adds a new EnergyCalculatorCallback for calculating energy contributions from clamped particles in TLSPH systems
  • Modifies TotalLagrangianSPHSystem to support energy calculator functionality with new cache allocation
  • Updates interaction functions to support selective particle processing for energy calculations

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/callbacks/energy_calculator.jl New callback implementation with energy calculation logic and CombinedMatrix utility
src/schemes/structure/total_lagrangian_sph/system.jl Added support flag and cache creation for energy calculator functionality
src/schemes/structure/total_lagrangian_sph/rhs.jl Modified interaction functions to accept custom particle ranges
test/callbacks/energy_calculator.jl Comprehensive test suite for the new callback
test/examples/examples.jl Integration test using oscillating beam example
src/TrixiParticles.jl Export declaration for the new callback
src/callbacks/callbacks.jl Include statement for new callback file
test/callbacks/callbacks.jl Include statement for new test file

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@efaulhaber efaulhaber requested review from LasNikas and svchb October 14, 2025 13:27
@efaulhaber efaulhaber marked this pull request as ready for review October 14, 2025 13:27
@efaulhaber efaulhaber marked this pull request as draft October 14, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant