celeritas-project / celeritas

Celeritas is a new Monte Carlo transport code designed to accelerate scientific discovery in high energy physics by improving detector simulation throughput and energy efficiency using GPUs.
https://celeritas-project.github.io/celeritas/user/index.html
Other
58 stars 32 forks source link

Add generic grid inserter to simplify construction #1229

Closed hhollenb closed 1 month ago

hhollenb commented 2 months ago

Add a simple inserter for generic grids, similar to ValueGridInserter. I use this for constructing the step limit grids for optical processes, but it can probably be reviewed separately since we'll want to use it in more than one place. Since ValueGridBuilder handles grids differently than GenericGridBuilder, we can't just copy the ValueGridInserter implementation.

The main idea is to handle the GenericGridBuilder and CollectionBuilder that the grids are being inserted into as a single object, making it easy to pass this data to processes and have them build their grids directly instead of having to manage both the mutable scalar host data (which is an implementation detail) as well as constructing the generic grid collection. Currently I have it templated on the collection index type so it's usable by more collections.

I wrote a trivial change for CerenkovParams.cc to use GenericGridInserter as an example and to make sure it passed a simple test. The same can't be done for ScintillationParams.cc since per particle grids are encapsulated in another data structure before being added to a particle-indexed collection.