Skip to content

Add helpers for array type, precision, and quantity conversion#2223

Merged
sethrj merged 45 commits intoceleritas-project:developfrom
sethrj:quantity-array
Mar 10, 2026
Merged

Add helpers for array type, precision, and quantity conversion#2223
sethrj merged 45 commits intoceleritas-project:developfrom
sethrj:quantity-array

Conversation

@sethrj
Copy link
Member

@sethrj sethrj commented Feb 1, 2026

The existing convert_{to/from}_geant functions are rather confusing because they do three things:

  1. Convert the type from geant4 to/from celeritas types
  2. Static-cast the precision of scalars/arrays if using single-precision Celeritas
  3. Apply unit conversion factors but without using quantities.

To avoid confusion and errors i.e. the ones I originally thought were present in #2218, this defines new helper functions:

  1. to_array and to_g4vector for type conversion
  2. renames array_cast to static_array_cast to clarify what exactly is being cast (similar to the standard library)
  3. make_array_quantity and related function for creating Array<Quantity<...>> that allows more expressive and type-safe conversion.

@sethrj sethrj added enhancement New feature or request external Dependencies and framework-oriented features labels Feb 1, 2026
@sethrj sethrj requested review from amandalund and removed request for drbenmorgan, elliottbiondo, mrguilima and stognini February 1, 2026 22:47
@sethrj
Copy link
Member Author

sethrj commented Feb 26, 2026

Once #2278 is in I'll pull in develop and update new usage as discussed.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 65 out of 65 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@sethrj sethrj marked this pull request as ready for review March 10, 2026 12:34
@sethrj sethrj merged commit 37e853d into celeritas-project:develop Mar 10, 2026
75 of 79 checks passed
@sethrj sethrj deleted the quantity-array branch March 10, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request external Dependencies and framework-oriented features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants