From 7f498fbb0280e78b11c35eb33fc9f173666981b3 Mon Sep 17 00:00:00 2001 From: Joana Niermann Date: Wed, 2 Aug 2023 20:41:49 +0200 Subject: [PATCH] Add material grids as material maps and add the relevant types to the detector metadata. The material maps of different shapes are tested in a dedicated unittest. Mapeterial maps are added to the toy detector and wire chamber via the detector helper. The material is a silicon and aluminium mixture that is mapped in configurable binning onto the disc and cylinder portals. --- core/include/detray/core/detector.hpp | 11 +- .../include/detray/core/detector_metadata.hpp | 63 ++++- core/include/detray/geometry/surface.hpp | 11 +- core/include/detray/masks/masks.hpp | 4 + core/include/detray/materials/material.hpp | 57 +++- .../include/detray/materials/material_map.hpp | 29 +++ .../include/detray/materials/material_rod.hpp | 10 + .../detray/materials/material_slab.hpp | 12 + .../actors/pointwise_material_interactor.hpp | 100 ++++--- core/include/detray/propagator/navigator.hpp | 8 + .../surface_finders/brute_force_finder.hpp | 9 + .../detray/surface_finders/grid/grid.hpp | 16 +- .../surface_finders/grid/grid_collection.hpp | 38 +++ core/include/detray/tools/volume_builder.hpp | 13 +- .../detray/io/common/detail/type_traits.hpp | 19 +- .../detray/io/common/detector_writer.hpp | 2 +- .../io/common/homogeneous_material_writer.hpp | 32 ++- .../tests/common/test_toy_detector.hpp | 24 +- tests/unit_tests/cpu/CMakeLists.txt | 1 + tests/unit_tests/cpu/material_maps.cpp | 237 +++++++++++++++++ .../detray/tutorial/detector_metadata.hpp | 7 +- .../detray/detectors/create_toy_geometry.hpp | 245 ++++++++++++------ .../detray/detectors/create_wire_chamber.hpp | 52 +++- .../detray/detectors/detector_helper.hpp | 186 ++++++++----- .../include/detray/detectors/itk_metadata.hpp | 44 +++- .../detray/detectors/telescope_metadata.hpp | 10 +- .../include/detray/detectors/toy_metadata.hpp | 36 ++- 27 files changed, 998 insertions(+), 278 deletions(-) create mode 100644 core/include/detray/materials/material_map.hpp create mode 100644 tests/unit_tests/cpu/material_maps.cpp diff --git a/core/include/detray/core/detector.hpp b/core/include/detray/core/detector.hpp index 2c217bf41c..9f2d8b3f90 100644 --- a/core/include/detray/core/detector.hpp +++ b/core/include/detray/core/detector.hpp @@ -97,7 +97,7 @@ class detector { /// Forward mask types that are present in this detector using material_container = - typename metadata::template material_store; + typename metadata::template material_store; using materials = typename material_container::value_types; using material_link = typename material_container::single_link; @@ -314,15 +314,16 @@ class detector { /// @returns the portals of a given volume @param v - const /// @note Depending on the detector type, this can also container other /// surfaces - DETRAY_HOST_DEVICE constexpr auto portals(const volume_type &v) const { + DETRAY_HOST_DEVICE constexpr auto portals(const volume_type &v) { // Index of the portal collection in the surface store const dindex pt_coll_idx{ v.template link().index()}; - const auto &pt_coll = - _surfaces - .template get()[pt_coll_idx]; + auto &bf_finder = + _surfaces.template get(); + + auto pt_coll = bf_finder[pt_coll_idx]; return pt_coll.all(); } diff --git a/core/include/detray/core/detector_metadata.hpp b/core/include/detray/core/detector_metadata.hpp index da5140f80a..e209e0e0d4 100644 --- a/core/include/detray/core/detector_metadata.hpp +++ b/core/include/detray/core/detector_metadata.hpp @@ -19,6 +19,7 @@ #include "detray/masks/masks.hpp" #include "detray/masks/unbounded.hpp" #include "detray/masks/unmasked.hpp" +#include "detray/materials/material_map.hpp" #include "detray/materials/material_rod.hpp" #include "detray/materials/material_slab.hpp" #include "detray/surface_finders/accelerator_grid.hpp" @@ -61,9 +62,34 @@ struct default_metadata { using slab = material_slab; using rod = material_rod; - /// @TODO material grids + /// Material grid types (default: closed bounds, regular binning) /// @{ - /// ... + + // Disc material grid + template + using disc_map_t = + material_map::axes<>, detray::scalar, container_t>; + + // Cylindrical material grid + template + using cylinder2_map_t = + material_map::axes<>, detray::scalar, container_t>; + + // Rectangular material grid + template + using rectangular_map_t = + material_map::axes<>, detray::scalar, container_t>; + + // Cuboid volume material grid + template + using cuboid_map_t = + material_map::axes<>, detray::scalar, container_t>; + + // Cylindrical volume material grid + template + using cylinder3_map_t = + material_map, detray::scalar, container_t>; + /// @} /// surface grid types (default boundaries: closed binning) @@ -162,19 +188,36 @@ unbounded_cell, unmasked_plane*/>; /// Give your material types a name (needs to be consecutive and has to /// match the types position in the mask store!) - /// @TODO: Add the material grid types for every surface shape enum class material_ids { - e_slab = 0, - e_rod = 1, - // ... material map types - e_none = 2, + // Material texture (grid) shapes + e_disc2_map = 0u, + e_cylinder2_map = 1u, + e_rectangle2_map = 2u, + e_trapezoid2_map = 2u, + e_annulus2_map = 0u, + e_cell_wire_map = 6u, + e_straw_wire_map = 6u, + // Volume material + e_cuboid3_map = 3u, + e_cylinder3_map = 4u, + // Homogeneous mapetrial + e_slab = 5u, + e_rod = 6u, + e_none = 7u, }; /// How to store materials template