Skip to content

[SPH] Hutchison 2018 Multigrain#1616

Open
tdavidcl wants to merge 40 commits intoShamrock-code:mainfrom
tdavidcl:patch-2026-02-05-15-21
Open

[SPH] Hutchison 2018 Multigrain#1616
tdavidcl wants to merge 40 commits intoShamrock-code:mainfrom
tdavidcl:patch-2026-02-05-15-21

Conversation

@tdavidcl
Copy link
Copy Markdown
Member

@tdavidcl tdavidcl commented Feb 5, 2026

No description provided.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 5, 2026

Thanks @tdavidcl for opening this PR!

You can do multiple things directly here:
1 - Comment pre-commit.ci run to run pre-commit checks.
2 - Comment pre-commit.ci autofix to apply fixes.
3 - Add label autofix.ci to fix authorship & pre-commit for every commit made.
4 - Add label light-ci to only trigger a reduced & faster version of the CI (need the full one before merge).
5 - Add label trigger-ci to create an empty commit to trigger the CI.

Once the workflow completes a message will appear displaying informations related to the run.

Also the PR gets automatically reviewed by gemini, you can:
1 - Comment /gemini review to trigger a review
2 - Comment /gemini summary for a summary
3 - Tag it using @gemini-code-assist either in the PR or in review comments on files

@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 integrates a new multigrain dust model into the SPH solver, specifically focusing on the MonofluidTVI configuration. It introduces new particle fields and implements the numerical calculation for the time evolution of a key dust-related variable, S_j, following the methodology outlined in the Hutchison 2018 paper. Additionally, it enhances the solver's configuration safety by restricting experimental dust features.

Highlights

  • New Dust Model Field: Introduced new particle data fields, 's_j' and 'ds_j_dt', for the MonofluidTVI dust model, representing a key variable and its time derivative.
  • Derivative Calculation Implementation: Implemented the update_derivs_dust_monofluid_tvi_Sj function to compute the time derivative of the 's_j' field, following Equation 51 from the Hutchison 2018 paper.
  • Experimental Feature Safeguard: Added a check in the solver configuration to prevent the use of experimental dust configurations unless explicitly allowed, throwing a runtime error otherwise.
  • Configuration Helper Methods: Added utility methods is_monofluid_tvi, is_monofluid_complete, and has_Sj_field to SolverConfig.hpp to query the active dust model configuration.
Changelog
  • src/shammodels/sph/include/shammodels/sph/SolverConfig.hpp
    • Added is_monofluid_tvi(), is_monofluid_complete(), and has_Sj_field() methods to query the current dust configuration.
    • Modified check_config() to throw a std::runtime_error if experimental dust configurations are used without shamrock::are_experimental_features_allowed() being true.
  • src/shammodels/sph/include/shammodels/sph/modules/UpdateDerivs.hpp
    • Declared the update_derivs_dust_monofluid_tvi_Sj(DustConfig cfg) function for calculating dust derivatives.
  • src/shammodels/sph/src/SolverConfig.cpp
    • Added 's_j' and 'ds_j_dt' fields to the PatchDataLayer and 's_j' to the ghost layout fields when dust_config.has_Sj_field() is true.
  • src/shammodels/sph/src/modules/UpdateDerivs.cpp
    • Integrated the call to update_derivs_dust_monofluid_tvi_Sj into the main update_derivs() function if the dust configuration has the 'Sj' field.
    • Implemented the update_derivs_dust_monofluid_tvi_Sj function, which computes ds_j_dt based on Equation 51 from Hutchison 2018, utilizing various particle properties and neighbor interactions.
Activity
  • New functionality for a specific dust model has been introduced.
  • Modifications span across header and source files related to solver configuration and derivative updates.
  • The changes include the addition of new data fields, helper methods, and a core computational function for dust dynamics.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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
Copy Markdown
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 introduces functionality for multigrain dust based on the Hutchison (2018) model. The changes span configuration and solver logic, adding new fields and a dedicated derivative update function. My review has identified a critical issue in the new derivative calculation where a key term is hardcoded to zero, which will lead to incorrect results. Additionally, there are several instances of unused variables and redundant code, likely from copy-pasting, which impact readability and performance. I've provided suggestions to clean this up and improve maintainability.

Comment thread src/shammodels/sph/src/modules/UpdateDerivs.cpp Outdated
Comment thread src/shammodels/sph/src/modules/UpdateDerivs.cpp Outdated
Comment thread src/shammodels/sph/include/shammodels/sph/SolverConfig.hpp Outdated
Comment thread src/shammodels/sph/include/shammodels/sph/SolverConfig.hpp
Comment thread src/shammodels/sph/src/modules/UpdateDerivs.cpp Outdated
@tdavidcl tdavidcl marked this pull request as ready for review April 23, 2026 14:36
@github-actions
Copy link
Copy Markdown
Contributor

Workflow report

workflow report corresponding to commit bafc5ea
Commiter email is timothee.davidcleris@proton.me

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
cmake-format.............................................................Passed
Validate GitHub Workflows................................................Passed
clang-format.............................................................Passed
ruff check...............................................................Passed
ruff format..............................................................Passed
Check doxygen headers....................................................Passed
Check license headers....................................................Passed
Check #pragma once.......................................................Passed
Check SYCL #include......................................................Passed
No ssh in git submodules remote..........................................Passed
No UTF-8 in files (except for authors)...................................Passed

Test pipeline can run.

Clang-tidy diff report


336 warnings generated.
Suppressed 337 warnings (334 in non-user code, 2 due to line filter, 1 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

365 warnings generated.
Suppressed 366 warnings (365 in non-user code, 1 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

349 warnings generated.
Suppressed 350 warnings (343 in non-user code, 6 due to line filter, 1 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

453 warnings generated.
Suppressed 454 warnings (451 in non-user code, 2 due to line filter, 1 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

/__w/Shamrock/Shamrock/src/shammodels/sph/src/modules/ComputeEos.cpp:90:75: warning: parameter 'e' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
   90 |     void complete_event_state(sycl::event e) { buf_h.complete_event_state(e); }
      |                                                                           ^
      |                                                                           std::move( )
/__w/Shamrock/Shamrock/src/shammodels/sph/src/modules/ComputeEos.cpp:90:75: note: FIX-IT applied suggested code changes
/__w/Shamrock/Shamrock/src/shammodels/sph/src/modules/ComputeEos.cpp:90:76: note: FIX-IT applied suggested code changes
   90 |     void complete_event_state(sycl::event e) { buf_h.complete_event_state(e); }
      |                                                                            ^
/__w/Shamrock/Shamrock/src/shammodels/sph/src/modules/ComputeEos.cpp:129:43: warning: the parameter 'e' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
  129 |     void complete_event_state(sycl::event e) {
      |                                           ^
      |                               const      &
/__w/Shamrock/Shamrock/src/shammodels/sph/src/modules/ComputeEos.cpp:129:31: note: FIX-IT applied suggested code changes
  129 |     void complete_event_state(sycl::event e) {
      |                               ^
/__w/Shamrock/Shamrock/src/shammodels/sph/src/modules/ComputeEos.cpp:129:42: note: FIX-IT applied suggested code changes
  129 |     void complete_event_state(sycl::event e) {
      |                                          ^

944 warnings generated.
clang-tidy applied 4 of 4 suggested fixes.
Suppressed 943 warnings (941 in non-user code, 1 due to line filter, 1 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

664 warnings generated.
Suppressed 665 warnings (664 in non-user code, 1 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

/__w/Shamrock/Shamrock/src/shammodels/sph/src/pySPHModel.cpp:280:51: warning: parameter 'ts' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
  280 |                 self.dust_config.stopping_times = ts;
      |                                                   ^ 
      |                                                   std::move( )
/__w/Shamrock/Shamrock/src/shammodels/sph/src/pySPHModel.cpp:280:51: note: FIX-IT applied suggested code changes
/__w/Shamrock/Shamrock/src/shammodels/sph/src/pySPHModel.cpp:280:53: note: FIX-IT applied suggested code changes
  280 |                 self.dust_config.stopping_times = ts;
      |                                                     ^
/__w/Shamrock/Shamrock/src/shammodels/sph/src/pySPHModel.cpp:783:47: warning: the const qualified parameter 'pos_to_val' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]
  783 |                const std::function<f64(Tvec)> pos_to_val,
      |                                               ^
/__w/Shamrock/Shamrock/src/shammodels/sph/src/pySPHModel.cpp:795:49: warning: the const qualified parameter 'pos_to_val' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]
  795 |                const std::function<f64_3(Tvec)> pos_to_val,
      |                                                 ^

868 warnings generated.
clang-tidy applied 2 of 2 suggested fixes.
Suppressed 851 warnings (740 in non-user code, 110 due to line filter, 1 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

816 warnings generated.
Suppressed 817 warnings (803 in non-user code, 13 due to line filter, 1 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

Suggested changes

Detailed changes :
diff --git a/src/shammodels/sph/src/modules/ComputeEos.cpp b/src/shammodels/sph/src/modules/ComputeEos.cpp
index 81de5b52..3fcce237 100644
--- a/src/shammodels/sph/src/modules/ComputeEos.cpp
+++ b/src/shammodels/sph/src/modules/ComputeEos.cpp
@@ -87,7 +87,7 @@ struct RhoGetterMonofluid {
         return accessed{h, epsilon, nvar_dust, pmass, hfact};
     }
 
-    void complete_event_state(sycl::event e) { buf_h.complete_event_state(e); }
+    void complete_event_state(sycl::event e) { buf_h.complete_event_state(std::move(e)); }
 };
 
 template<class Tscal>
@@ -126,7 +126,7 @@ struct RhoGetterSJ {
         return accessed{h, s_j, nvar_dust, pmass, hfact};
     }
 
-    void complete_event_state(sycl::event e) {
+    void complete_event_state(const sycl::event& e) {
         buf_h.complete_event_state(e);
         buf_s_j.complete_event_state(e);
     }
diff --git a/src/shammodels/sph/src/pySPHModel.cpp b/src/shammodels/sph/src/pySPHModel.cpp
index baad3c82..bc6f769e 100644
--- a/src/shammodels/sph/src/pySPHModel.cpp
+++ b/src/shammodels/sph/src/pySPHModel.cpp
@@ -277,7 +277,7 @@ void add_instance(py::module &m, std::string name_config, std::string name_model
         .def(
             "set_dust_stopping_times",
             [](TConfig &self, std::vector<Tscal> ts) {
-                self.dust_config.stopping_times = ts;
+                self.dust_config.stopping_times = std::move(ts);
             })
         .def("add_ext_force_point_mass", &TConfig::add_ext_force_point_mass)
         .def(

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