88#include < vector>
99
1010namespace specfem ::assembly::info::impl {
11- template <specfem::element::dimension_tag DimensionTag>
12- struct BoundingBox {
11+
12+ /* *
13+ * @brief Axis-aligned bounding box for mesh domain.
14+ *
15+ * Stores min/max bounds for each spatial dimension (x, y, z).
16+ * Provides dimension-specific accessors that handle 2D vs 3D cases.
17+ *
18+ * @tparam DimensionTag Spatial dimension (dim2 or dim3)
19+ */
20+ template <specfem::element::dimension_tag DimensionTag> struct BoundingBox {
1321
1422 constexpr static auto dimension_tag = DimensionTag;
1523 constexpr static int ndim =
1624 specfem::element::dimension<dimension_tag>::dim; // /< Number of dimensions
1725
18- specfem::datatype::RegisterArray<
19- Bounds,
20- Kokkos::extents<size_t , ndim>,
21- Kokkos::layout_left> bounds_array;
26+ specfem::datatype::RegisterArray<Bounds, Kokkos::extents<size_t , ndim>,
27+ Kokkos::layout_left>
28+ bounds_array; // /< Array of bounds per dimension
2229
2330 BoundingBox () = default ;
2431
32+ /* *
33+ * @brief Construct 2D bounding box from explicit min/max values.
34+ * @param x_min Minimum x coordinate
35+ * @param x_max Maximum x coordinate
36+ * @param z_min Minimum z coordinate
37+ * @param z_max Maximum z coordinate
38+ */
2539 template <specfem::element::dimension_tag U = dimension_tag,
26- typename std::enable_if<U == specfem::element::dimension_tag::dim2>::type
27- * = nullptr >
28- BoundingBox (const type_real x_min, const type_real x_max, const type_real z_min,
29- const type_real z_max)
30- : bounds_array(Bounds(x_min, x_max), Bounds(z_min, z_max)) {};
31-
40+ typename std::enable_if<
41+ U == specfem::element::dimension_tag::dim2>::type * = nullptr >
42+ BoundingBox (const type_real x_min, const type_real x_max,
43+ const type_real z_min, const type_real z_max)
44+ : bounds_array(Bounds(x_min, x_max), Bounds(z_min, z_max)){};
45+
46+ /* *
47+ * @brief Construct 3D bounding box from explicit min/max values.
48+ * @param x_min Minimum x coordinate
49+ * @param x_max Maximum x coordinate
50+ * @param y_min Minimum y coordinate
51+ * @param y_max Maximum y coordinate
52+ * @param z_min Minimum z coordinate
53+ * @param z_max Maximum z coordinate
54+ */
3255 template <specfem::element::dimension_tag U = dimension_tag,
33- typename std::enable_if<U == specfem::element::dimension_tag::dim3>::type
34- * = nullptr >
35- BoundingBox (const type_real x_min, const type_real x_max, const type_real y_min,
36- const type_real y_max, const type_real z_min, const type_real z_max)
37- : bounds_array(Bounds(x_min, x_max), Bounds(y_min, y_max), Bounds(z_min, z_max)) {};
38-
56+ typename std::enable_if<
57+ U == specfem::element::dimension_tag::dim3>::type * = nullptr >
58+ BoundingBox (const type_real x_min, const type_real x_max,
59+ const type_real y_min, const type_real y_max,
60+ const type_real z_min, const type_real z_max)
61+ : bounds_array(Bounds(x_min, x_max), Bounds(y_min, y_max),
62+ Bounds (z_min, z_max)){};
63+
64+ /* *
65+ * @brief Construct 2D bounding box from vector of Bounds.
66+ * @param bounds Vector of 2 Bounds objects (x, z)
67+ * @throws std::invalid_argument if bounds.size() != 2
68+ */
3969 template <specfem::element::dimension_tag U = dimension_tag,
40- typename std::enable_if<U == specfem::element::dimension_tag::dim2>::type
41- * = nullptr >
70+ typename std::enable_if<
71+ U == specfem::element::dimension_tag::dim2>::type * = nullptr >
4272 BoundingBox (const std::vector<Bounds> &bounds) {
4373 if (bounds.size () != 2 ) {
4474 throw std::invalid_argument (
@@ -47,9 +77,14 @@ struct BoundingBox {
4777 bounds_array = decltype (bounds_array)(bounds[0 ], bounds[1 ]);
4878 }
4979
80+ /* *
81+ * @brief Construct 3D bounding box from vector of Bounds.
82+ * @param bounds Vector of 3 Bounds objects (x, y, z)
83+ * @throws std::invalid_argument if bounds.size() != 3
84+ */
5085 template <specfem::element::dimension_tag U = dimension_tag,
51- typename std::enable_if<U == specfem::element::dimension_tag::dim3>::type
52- * = nullptr >
86+ typename std::enable_if<
87+ U == specfem::element::dimension_tag::dim3>::type * = nullptr >
5388 BoundingBox (const std::vector<Bounds> &bounds) {
5489 if (bounds.size () != 3 ) {
5590 throw std::invalid_argument (
@@ -58,28 +93,29 @@ struct BoundingBox {
5893 bounds_array = decltype (bounds_array)(bounds[0 ], bounds[1 ], bounds[2 ]);
5994 }
6095
61- Bounds &x () {
62- return bounds_array (0 );
63- }
96+ /* * @brief Access x-direction bounds. */
97+ Bounds &x () { return bounds_array (0 ); }
6498
65- const Bounds &x () const {
66- return bounds_array (0 );
67- }
99+ /* * @brief Access x-direction bounds (const). */
100+ const Bounds &x () const { return bounds_array (0 ); }
68101
102+ /* * @brief Access y-direction bounds (3D only). */
69103 template <specfem::element::dimension_tag U = dimension_tag,
70- typename std::enable_if<U == specfem::element::dimension_tag::dim3>::type
71- * = nullptr >
104+ typename std::enable_if<
105+ U == specfem::element::dimension_tag::dim3>::type * = nullptr >
72106 Bounds &y () {
73107 return bounds_array (1 );
74108 }
75109
110+ /* * @brief Access y-direction bounds (3D only, const). */
76111 template <specfem::element::dimension_tag U = dimension_tag,
77- typename std::enable_if<U == specfem::element::dimension_tag::dim3>::type
78- * = nullptr >
112+ typename std::enable_if<
113+ U == specfem::element::dimension_tag::dim3>::type * = nullptr >
79114 const Bounds &y () const {
80115 return bounds_array (1 );
81116 }
82117
118+ /* * @brief Access z-direction bounds (index 1 for 2D, index 2 for 3D). */
83119 Bounds &z () {
84120 if constexpr (dimension_tag == specfem::element::dimension_tag::dim2) {
85121 return bounds_array (1 );
@@ -88,14 +124,15 @@ struct BoundingBox {
88124 }
89125 }
90126
127+ /* * @brief Access z-direction bounds (const, index 1 for 2D, index 2 for 3D).
128+ */
91129 const Bounds &z () const {
92130 if constexpr (dimension_tag == specfem::element::dimension_tag::dim2) {
93131 return bounds_array (1 );
94132 } else {
95133 return bounds_array (2 );
96134 }
97135 }
98-
99136};
100137
101138} // namespace specfem::assembly::info::impl
0 commit comments