From bce042b6bb6915fc6b1fe8f2dca213f779ec8eee Mon Sep 17 00:00:00 2001 From: Fuad Hasibul Hasan Date: Sun, 14 Jul 2024 17:01:09 -0400 Subject: [PATCH 1/3] bboxWrap correction --- src/Omega_h_bbox.cpp | 5 ++--- src/Omega_h_vector.hpp | 10 ++++++++++ src/unit_mesh.cpp | 4 ++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Omega_h_bbox.cpp b/src/Omega_h_bbox.cpp index d3c974ab9..52c45244b 100644 --- a/src/Omega_h_bbox.cpp +++ b/src/Omega_h_bbox.cpp @@ -12,9 +12,8 @@ struct bboxWrap { KOKKOS_INLINE_FUNCTION // Default constructor - Initialize to 0's bboxWrap() { - const auto zero = zero_vector(); - box.min = zero; - box.max = zero; + box.min = max_float_vector(); + box.max = min_float_vector(); } KOKKOS_INLINE_FUNCTION // Copy Constructor bboxWrap(const bboxWrap & rhs) { diff --git a/src/Omega_h_vector.hpp b/src/Omega_h_vector.hpp index ac0f2295a..f2a718927 100644 --- a/src/Omega_h_vector.hpp +++ b/src/Omega_h_vector.hpp @@ -150,6 +150,16 @@ OMEGA_H_INLINE Vector zero_vector() OMEGA_H_NOEXCEPT { return fill_vector(0.0); } +template +OMEGA_H_INLINE Vector max_float_vector() OMEGA_H_NOEXCEPT { + return fill_vector(Kokkos::Experimental::finite_max_v); +} + +template +OMEGA_H_INLINE Vector min_float_vector() OMEGA_H_NOEXCEPT { + return fill_vector(Kokkos::Experimental::finite_min_v); +} + /* Moore-Penrose pseudo-inverse of a vector */ template OMEGA_H_INLINE Vector pseudo_invert(Vector a) OMEGA_H_NOEXCEPT { diff --git a/src/unit_mesh.cpp b/src/unit_mesh.cpp index bf4717872..e794ef610 100644 --- a/src/unit_mesh.cpp +++ b/src/unit_mesh.cpp @@ -235,6 +235,10 @@ static void test_hilbert() { } static void test_bbox() { + OMEGA_H_CHECK(are_close(BBox<2>(vector_2(-10, -15), vector_2(-1, -1)), + find_bounding_box<2>(Reals({-3, -12, -10, -1, -1, -15, -3, -2})))); + OMEGA_H_CHECK(are_close(BBox<2>(vector_2(1, 1), vector_2(10, 15)), + find_bounding_box<2>(Reals({3, 12, 10, 1, 1, 15, 3, 2})))); OMEGA_H_CHECK(are_close(BBox<2>(vector_2(-3, -3), vector_2(3, 3)), find_bounding_box<2>(Reals({0, -3, 3, 0, 0, 3, -3, 0})))); OMEGA_H_CHECK(are_close(BBox<3>(vector_3(-3, -3, -3), vector_3(3, 3, 3)), From 4e52b05a73f5742a4b44bf7512b74a86214be0fd Mon Sep 17 00:00:00 2001 From: Fuad Hasibul Hasan Date: Sun, 14 Jul 2024 22:16:37 -0400 Subject: [PATCH 2/3] change minmax function name for bboxwrap --- src/Omega_h_bbox.cpp | 6 +++--- src/Omega_h_vector.hpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Omega_h_bbox.cpp b/src/Omega_h_bbox.cpp index 52c45244b..8fb3252bc 100644 --- a/src/Omega_h_bbox.cpp +++ b/src/Omega_h_bbox.cpp @@ -10,10 +10,10 @@ template< int N > struct bboxWrap { BBox box; - KOKKOS_INLINE_FUNCTION // Default constructor - Initialize to 0's + KOKKOS_INLINE_FUNCTION // Default constructor bboxWrap() { - box.min = max_float_vector(); - box.max = min_float_vector(); + box.min = max_vector(); + box.max = min_vector(); } KOKKOS_INLINE_FUNCTION // Copy Constructor bboxWrap(const bboxWrap & rhs) { diff --git a/src/Omega_h_vector.hpp b/src/Omega_h_vector.hpp index f2a718927..984c12b63 100644 --- a/src/Omega_h_vector.hpp +++ b/src/Omega_h_vector.hpp @@ -151,13 +151,13 @@ OMEGA_H_INLINE Vector zero_vector() OMEGA_H_NOEXCEPT { } template -OMEGA_H_INLINE Vector max_float_vector() OMEGA_H_NOEXCEPT { - return fill_vector(Kokkos::Experimental::finite_max_v); +OMEGA_H_INLINE Vector max_vector() OMEGA_H_NOEXCEPT { + return fill_vector(Kokkos::Experimental::finite_max_v); } template -OMEGA_H_INLINE Vector min_float_vector() OMEGA_H_NOEXCEPT { - return fill_vector(Kokkos::Experimental::finite_min_v); +OMEGA_H_INLINE Vector min_vector() OMEGA_H_NOEXCEPT { + return fill_vector(Kokkos::Experimental::finite_min_v); } /* Moore-Penrose pseudo-inverse of a vector */ From 2312f1db844c472b35aa0a6fbfe8ac670cd5be7e Mon Sep 17 00:00:00 2001 From: Fuad Hasibul Hasan Date: Tue, 16 Jul 2024 14:06:56 -0400 Subject: [PATCH 3/3] move finite_max to bbox wrapper --- src/Omega_h_bbox.cpp | 4 ++-- src/Omega_h_vector.hpp | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Omega_h_bbox.cpp b/src/Omega_h_bbox.cpp index 8fb3252bc..91b7cfa78 100644 --- a/src/Omega_h_bbox.cpp +++ b/src/Omega_h_bbox.cpp @@ -12,8 +12,8 @@ struct bboxWrap { KOKKOS_INLINE_FUNCTION // Default constructor bboxWrap() { - box.min = max_vector(); - box.max = min_vector(); + box.min = fill_vector(Kokkos::Experimental::finite_max_v); + box.max = fill_vector(Kokkos::Experimental::finite_min_v); } KOKKOS_INLINE_FUNCTION // Copy Constructor bboxWrap(const bboxWrap & rhs) { diff --git a/src/Omega_h_vector.hpp b/src/Omega_h_vector.hpp index 984c12b63..ac0f2295a 100644 --- a/src/Omega_h_vector.hpp +++ b/src/Omega_h_vector.hpp @@ -150,16 +150,6 @@ OMEGA_H_INLINE Vector zero_vector() OMEGA_H_NOEXCEPT { return fill_vector(0.0); } -template -OMEGA_H_INLINE Vector max_vector() OMEGA_H_NOEXCEPT { - return fill_vector(Kokkos::Experimental::finite_max_v); -} - -template -OMEGA_H_INLINE Vector min_vector() OMEGA_H_NOEXCEPT { - return fill_vector(Kokkos::Experimental::finite_min_v); -} - /* Moore-Penrose pseudo-inverse of a vector */ template OMEGA_H_INLINE Vector pseudo_invert(Vector a) OMEGA_H_NOEXCEPT {