Skip to content

[newchem-cpp] Replace SpeciesLUTFieldAdaptor with FieldAdaptorManager and SpeciesMultiView#562

Open
mabruzzo wants to merge 27 commits into
grackle-project:newchem-cppfrom
mabruzzo:ncc/SpeciesFieldAdaptor
Open

[newchem-cpp] Replace SpeciesLUTFieldAdaptor with FieldAdaptorManager and SpeciesMultiView#562
mabruzzo wants to merge 27 commits into
grackle-project:newchem-cppfrom
mabruzzo:ncc/SpeciesFieldAdaptor

Conversation

@mabruzzo

@mabruzzo mabruzzo commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

This PR depends on changes from #558 and #561


This PR introduces FieldAdaptorManager and SpeciesMultiView:

  • SpeciesMultiView<T> is just an alias for Multi1DView<T> (introduced in PR [newchem-cpp] Introduce Multi1dView #561)
  • I'm using an alias because I could imagine using Multi1DView<T> in a few other places and using the type alias will make it easy for us to change the definition for SpeciesMultiView<T> (e.g. if we, as we've discussed before, ever decide to copy the species values into a temporary contiguous 2d array)
  • The FieldAdaptorManager is a tool that actually facilitates the creation of a SpeciesMultiView from a grackle_field_data pointer
    • I decided to try to keep the implementation as simple as possible (but there are a bunch of improvements that could be made)

In order to avoid making this PR too big, I have primarily focused on just using this new machinery to replace the old, very hacky SpeciesLUTFieldAdaptor machinery

mabruzzo added 25 commits June 21, 2026 12:55
…data

Currently, `time_deriv_0d` works by preparing a context pack with all of
the infrastructure for creating a 1-element version of grackle_field_data.
This was a pragmatic choice early during transcription, but it's hacky &
inefficient.

Before this PR:

- the `time_derivative_0d::derivative` function would overwrite
  `pack.field.internal_energy` and `pack.field.e_density`,
  `pack.field.HI_density`, `pack.field.HII_density`, ... to point to the
  buffers provided in the function arguments
- now, the context pack will pre-allocate the evolved buffers tracked
  within the 1-element version `grackle_field_data` and we will just copy over
  the values from the function arguments

Aside: for all fields that aren't evolved (e.g. `density`, `dust_density`,
`volumetric_heating_rate`, RT-fields, etc.) the 1-zone `grackle_field_data`
instance just points to the appropriate location in the full 3D field.
This is inadvisable, but will be necessary to achieve reasonable
performance in step_rate_newton_raphson
@mabruzzo mabruzzo force-pushed the ncc/SpeciesFieldAdaptor branch from e1d601d to 2ed79c3 Compare June 23, 2026 15:36
@mabruzzo mabruzzo changed the title [newchem-cpp] WIP: Replace SpeciesLUTFieldAdaptor with FieldAdaptorManager and SpeciesMultiView [newchem-cpp] Replace SpeciesLUTFieldAdaptor with FieldAdaptorManager and SpeciesMultiView Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant