Skip to content

[newchem-cpp] Remove Hard-coded injection path names from grackle_field_data#480

Merged
brittonsmith merged 14 commits into
grackle-project:newchem-cppfrom
mabruzzo:ncc/remove-InjectPathFieldPack
Mar 31, 2026
Merged

[newchem-cpp] Remove Hard-coded injection path names from grackle_field_data#480
brittonsmith merged 14 commits into
grackle-project:newchem-cppfrom
mabruzzo:ncc/remove-InjectPathFieldPack

Conversation

@mabruzzo

@mabruzzo mabruzzo commented Jan 1, 2026

Copy link
Copy Markdown
Collaborator

To be reviewed after #479 is merged


This PR replaces all hard-coded injection pathway data-members from the grackle_field_data (e.g. grackle_field_data::local_ISM_metal_density, grackle_field_data::y19_metal_density, ...) with an array of pointers known as grackle_field_data::inject_pathway_metal_density. In other words, Grackle no longer hardcodes the names of each injection pathway members as part of the grackle_field_data struct. (To determine the names, users must use the query-machinery introduced in #479).

This is significant for 2 reasons:

  1. I think the old approach would have been a pretty bad choice from an API perspective
    • injection pathway models or supernova models is the exact sort of thing where one might expect "churn"
    • under the old approach, we would have needed to keep adding more and more members to grackle_field_data whenever someone wanted another model (while maintaining members for all existing models)
    • Likewise, a simulation code that wanted to use another model would need to add several lines of code to support each kind of model
    • the newer approach is much more scalable
  2. It's also important from an implementation perspective:
    • the number of inject field paths are now entirely determined by the values read in from the table. To add/remove/rename pathways, you "just" need to modify inject_model/raw_data.[ch]pp and inject_model/load_data.[ch]pp.
    • this is a massive step that will make it possible to move this data into HDF5 tables (and let users supply arbitrary data)

@mabruzzo mabruzzo added the refactor internal reorganization or code simplification with no behavior changes label Jan 1, 2026
@mabruzzo mabruzzo marked this pull request as draft January 1, 2026 21:46
@mabruzzo mabruzzo force-pushed the ncc/remove-InjectPathFieldPack branch from 1b615a0 to 1bbb83e Compare January 3, 2026 15:10
@mabruzzo mabruzzo force-pushed the ncc/remove-InjectPathFieldPack branch 3 times, most recently from 643a69c to a41f096 Compare January 3, 2026 21:18
@mabruzzo mabruzzo force-pushed the ncc/remove-InjectPathFieldPack branch from a41f096 to 7e2d847 Compare January 4, 2026 00:35
This is uglier, but the number of inject field paths are now entirely
determined by the values read in from the table. To add/remove/rename
pathways, you "just" need to modify `inject_model/raw_data.[ch]pp` and
`inject_model/load_data.[ch]pp`.

This is a massive step that will make it possible to move this data into
HDF5 tables
@mabruzzo mabruzzo changed the title WIP: [newchem-cpp] Remove Hard-coded injection path names from grackle_field_data [newchem-cpp] Remove Hard-coded injection path names from grackle_field_data Jan 4, 2026
@mabruzzo mabruzzo marked this pull request as ready for review January 4, 2026 04:02
@mabruzzo mabruzzo changed the base branch from newchem-cpp to main March 19, 2026 13:49
@mabruzzo mabruzzo changed the base branch from main to newchem-cpp March 19, 2026 13:49
@brittonsmith brittonsmith changed the base branch from newchem-cpp to main March 31, 2026 10:19
@brittonsmith brittonsmith changed the base branch from main to newchem-cpp March 31, 2026 10:19

@brittonsmith brittonsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is great. I'm excited to start using it. It also finally hit me what has been rubbing me the wrong way about the injection pathway metal densities. For all but the first one, the name refers to a progenitor supernova making the metal. However, "local_ISM", while also alluding to an abundance pattern, is doing so through a different conceptual path. This is a single field representing an abundance pattern. I'm not at all advocating for a change in the naming convention but I think this will be crucial in the documentation.

@brittonsmith brittonsmith merged commit 7388deb into grackle-project:newchem-cpp Mar 31, 2026
5 checks passed
@mabruzzo mabruzzo deleted the ncc/remove-InjectPathFieldPack branch April 14, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor internal reorganization or code simplification with no behavior changes

Projects

Development

Successfully merging this pull request may close these issues.

2 participants