Skip to content

[SPH] migrate compute omega from shamrock pre-history to modern age#1265

Merged
tdavidcl merged 1 commit intoShamrock-code:mainfrom
tdavidcl:patch-2025-09-15-14-30
Sep 16, 2025
Merged

[SPH] migrate compute omega from shamrock pre-history to modern age#1265
tdavidcl merged 1 commit intoShamrock-code:mainfrom
tdavidcl:patch-2025-09-15-14-30

Conversation

@tdavidcl
Copy link
Member

No description provided.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @tdavidcl, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly modernizes the compute_omega function within the SPH (Smoothed Particle Hydrodynamics) module. The primary goal is to transition the computation to a more efficient and scalable distributed kernel call mechanism. This refactoring streamlines the code, improves how data is handled through structured field references, and prepares the SPH computations for better performance in a distributed computing environment.

Highlights

  • Modernized compute_omega Function: The compute_omega function has been entirely refactored to utilize a modern distributed kernel call mechanism, moving away from an older, patch-data-centric approach.
  • Distributed Kernel Integration: The computation now leverages sham::distributed_data_kernel_call for parallel execution across distributed data, enhancing scalability and performance.
  • Improved Data Management: Introduction of FieldRefs and DDPatchDataFieldRef provides a more structured and efficient way to handle field data references within the solver graph.
  • Inlined Computation Logic: The core omega calculation logic, previously abstracted, is now directly embedded within a lambda function passed to the distributed kernel, making the computation more self-contained and explicit.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the compute_omega function to use the modern distributed_data_kernel_call infrastructure, which is a good step forward. The implementation correctly sets up the distributed call.

However, I've found a critical issue in the new kernel logic where it seems to be using an incorrect density value for the omega correction factor calculation. Specifically, it uses a theoretical density rho_ha instead of the summed SPH density rho_sum, and the latter is calculated but left unused. This will likely lead to incorrect physical results. My review includes a suggestion to fix this.

Please address this critical point to ensure the correctness of the simulation.

Comment on lines +93 to +97
using namespace shamrock::sph;

Tscal rho_ha = rho_h(part_mass, h_a, Kernel::hfactd);
Tscal omega_a = 1 + (h_a / (3 * rho_ha)) * part_omega_sum;
omega[id_a] = omega_a;
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The calculation of omega_a appears to be using rho_ha (a theoretical density) instead of rho_sum (the actual SPH density summation). The variable rho_sum is calculated in the neighbor loop but is currently unused, which strongly suggests it should be used here. Using rho_sum is consistent with the standard SPH formulation for the variable smoothing length correction factor.

Additionally, a check should be added to prevent division by zero when rho_sum is zero (e.g., for isolated particles), in which case omega_a should be 1.

Suggested change
using namespace shamrock::sph;
Tscal rho_ha = rho_h(part_mass, h_a, Kernel::hfactd);
Tscal omega_a = 1 + (h_a / (3 * rho_ha)) * part_omega_sum;
omega[id_a] = omega_a;
Tscal omega_a = 1.0;
if (rho_sum > 0.0) {
omega_a = 1.0 + (h_a / (3.0 * rho_sum)) * part_omega_sum;
}
omega[id_a] = omega_a;

@github-actions
Copy link
Contributor

Workflow report

workflow report corresponding to commit 94080df
Commiter email is timothee.davidcleris@proton.me
GitHub page artifact URL GitHub page artifact link (can expire)

Pre-commit check report

Pre-commit check: ✅

trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check for merge conflicts................................................Passed
check that executables have shebangs.....................................Passed
check that scripts with shebangs are executable..........................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for broken symlinks................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
No-tabs checker..........................................................Passed
Tabs remover.............................................................Passed
Validate GitHub Workflows................................................Passed
clang-format.............................................................Passed
black....................................................................Passed
ruff check...............................................................Passed
Check doxygen headers....................................................Passed
Check license headers....................................................Passed
Check #pragma once.......................................................Passed
Check SYCL #include......................................................Passed
No ssh in git submodules remote..........................................Passed

Test pipeline can run.

Clang-tidy diff report

No relevant changes found.
Well done!

You should now go back to your normal life and enjoy a hopefully sunny day while waiting for the review.

Doxygen diff with main

Removed warnings : 0
New warnings : 0
Warnings count : 7955 → 7955 (0.0%)

Detailed changes :

@tdavidcl tdavidcl merged commit 9a77007 into Shamrock-code:main Sep 16, 2025
100 of 138 checks passed
@tdavidcl tdavidcl deleted the patch-2025-09-15-14-30 branch September 16, 2025 06:55
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.

1 participant