Skip to content

Nested material parametrization for voxellized geometry#41

Merged
sethrj merged 16 commits intoceleritas-project:mainfrom
michele-colle:main
Nov 3, 2025
Merged

Nested material parametrization for voxellized geometry#41
sethrj merged 16 commits intoceleritas-project:mainfrom
michele-colle:main

Conversation

@michele-colle
Copy link
Contributor

Based on the ICRUPhantom example:

https://gitlab.cern.ch/geant4/geant4/-/tree/master/examples/advanced/ICRP110_HumanPhantoms

I have added a minimal test of a voxellized 2x3x5 geometry with 7 material (plus air) in order to verify the correctness of the geometry creation.

…trization.test.cc

- Implemented ICRP110PhantomMaterial_Female class to define materials for the female phantom model.
- Created ICRP110PhantomNestedParameterisation class to handle voxel parameterisation and material assignment.
Copy link
Member

@sethrj sethrj left a comment

Choose a reason for hiding this comment

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

Thanks for this @michele-colle! Would it be possible for you to simplify the example even further? The goal is to show with the least amount of code that we're missing something important, and then find the next step to the basic capability of material-dependent parameterization.

  1. I think you can get rid of the phantom materials. All we really need is hydrogen at 8 different densities (separate G4Material objects).
  2. Similarly, you should be able to delete the visualization-related code.

Superficial changes that should be made before this is merged (lower priority)

  • Install the pre-commit utility so that the code will be formatted consistently with the rest of the repository? Then run pre-commit run --all-files to update the formatting of the C++ files.
  • Revert the reformatting of CMakePresets.json
  • Delete commented-out code, or if it should remain in there, replace // (signifying textual comments) by #if 0/#endif pairs (signifying disabled code) with a comment explaining why it's there but disabled

I hope it's not too much of a burden, but that will help improve the readability of the changes and make it easier to review. Thanks for bringing it to this point already!

@michele-colle
Copy link
Contributor Author

Ok, I have deleted the parts of code related to the visualization and the material generation files, now the materials are the 7 requested hydrogen densities.
I have also delete every comment.
I reverted the CMakePresets.json
I tried running the precommit but i get this error:

An error has occurred: InvalidManifestError: 
==> File /home/colle/.cache/pre-commit/repofji9xiwl/.pre-commit-hooks.yaml
==> At Hook(id='clang-format')
==> At key: types_or
==> At index 10
=====> Type tag 'metal' is not recognized.  Try upgrading identify and pre-commit?
Check the log at /home/colle/.cache/pre-commit/pre-commit.log
colle@colle-HP-Z2-Tower-G9-Workstation-Desktop-PC:~/Desktop/g4vg/g4vg$ 

@mrguilima
Copy link

Remove 'metal' from the .yml files under /home/colle/.cache/pre-commit, and re-run the command that shows this error.

@michele-colle
Copy link
Contributor Author

Remove 'metal' from the .yml files under /home/colle/.cache/pre-commit, and re-run the command that shows this error.

thanks! it worked!

Prompt:

> The nested parameterization code needs some major cleanup: please use Custom.test.cc as a "best practices" baseline. Although there are some unusual memory semantics dictated by the underlying Geant4 API, please:
>
> - use C++17 best practices where possible
> - use std::array<int, 3> instead of x,y,z sequences of numbers
> - use vectors instead of raw pointers where possible
> - update names to be consistent with Custom.test.cc
> - Remove superfluous comments, and use inline variable comments such as /* rotation = */ instead of a end-of-line comment
> - Move construction of the paramterization (vector, dimensions) into the construction, and delete the setters
@sethrj
Copy link
Member

sethrj commented Oct 31, 2025

Hi @michele-colle I'm unable to upload fixes this PR because (I think?) the pull request is from your "main" branch rather than a topic branch. Could you please run the following commands in your local development repository:

git remote add -f sethrj https://github.com/sethrj/g4vg
git merge --ff-only sethrj/pr-41-fixes
git push
git remote rm sethrj

@sethrj sethrj enabled auto-merge (squash) October 31, 2025 16:46
@sethrj sethrj disabled auto-merge November 3, 2025 13:36
@sethrj sethrj merged commit a676f20 into celeritas-project:main Nov 3, 2025
4 checks passed
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.

4 participants