From 100818993376ae01b3e65d49b819b78e637bd9fd Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Fri, 4 Aug 2023 08:44:57 -0500 Subject: [PATCH] Use HyperTriangle --- benchmarks/tokamak/tokamak.cpp | 48 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/benchmarks/tokamak/tokamak.cpp b/benchmarks/tokamak/tokamak.cpp index ff60d2836..afc65f2ed 100644 --- a/benchmarks/tokamak/tokamak.cpp +++ b/benchmarks/tokamak/tokamak.cpp @@ -10,17 +10,12 @@ ****************************************************************************/ #include +#include #include #include -template -struct Triangle -{ - ArborX::ExperimentalHyperGeometry::Point a, b, c; -}; - struct Mapping { ArborX::ExperimentalHyperGeometry::Point<2> alpha; @@ -37,7 +32,7 @@ struct Mapping // x = a + alpha * (b - a) + beta * (c - a) // = (1-beta-alpha) * a + alpha * b + beta * c - void compute(Triangle<2> const &triangle) + void compute(ArborX::ExperimentalHyperGeometry::Triangle<2> const &triangle) { auto const &a = triangle.a; auto const &b = triangle.b; @@ -55,7 +50,7 @@ struct Mapping p0 = a; } - Triangle<2> get_triangle() const + ArborX::ExperimentalHyperGeometry::Triangle<2> get_triangle() const { float const inv_det = 1. / (alpha[0] * beta[1] - alpha[1] * beta[0]); ArborX::ExperimentalHyperGeometry::Point<2> a = p0; @@ -74,7 +69,8 @@ struct Triangles KOKKOS_FUNCTION int size() const { return triangles_.size(); } // Return the triangle with index i. - KOKKOS_FUNCTION Triangle<2> const &get_triangle(int i) const + KOKKOS_FUNCTION ArborX::ExperimentalHyperGeometry::Triangle<2> const & + get_triangle(int i) const { return triangles_(i); } @@ -84,7 +80,9 @@ struct Triangles return mappings_(i); } - Kokkos::View *, typename DeviceType::memory_space> triangles_; + Kokkos::View *, + typename DeviceType::memory_space> + triangles_; Kokkos::View mappings_; }; @@ -150,7 +148,7 @@ template Triangles parse_stl(typename DeviceType::execution_space const &execution_space) { - std::vector> triangles_host; + std::vector> triangles_host; std::vector mappings_host; std::ifstream stl_file("RZGrid.stl"); if (!stl_file.good()) @@ -158,7 +156,7 @@ parse_stl(typename DeviceType::execution_space const &execution_space) std::string line; std::istringstream in; Mapping mapping; - Triangle<2> triangle; + ArborX::ExperimentalHyperGeometry::Triangle<2> triangle; std::string dummy; while (std::getline(stl_file >> std::ws, line)) { @@ -195,12 +193,15 @@ parse_stl(typename DeviceType::execution_space const &execution_space) std::cout << "Read " << triangles_host.size() << " Triangles\n"; - Kokkos::View *, typename DeviceType::memory_space> triangles( - Kokkos::view_alloc(Kokkos::WithoutInitializing, "triangles"), - triangles_host.size()); - Kokkos::deep_copy(execution_space, triangles, - Kokkos::View *, Kokkos::HostSpace>( - triangles_host.data(), triangles_host.size())); + Kokkos::View *, + typename DeviceType::memory_space> + triangles(Kokkos::view_alloc(Kokkos::WithoutInitializing, "triangles"), + triangles_host.size()); + Kokkos::deep_copy( + execution_space, triangles, + Kokkos::View *, + Kokkos::HostSpace>(triangles_host.data(), + triangles_host.size())); Kokkos::View mappings( Kokkos::view_alloc(Kokkos::WithoutInitializing, "mappings"), @@ -296,7 +297,8 @@ int main() std::cout << "Creating BVH tree.\n"; ArborX::BasicBoundingVolumeHierarchy< - MemorySpace, ArborX::ExperimentalHyperGeometry::Box<2>> const + MemorySpace, ArborX::Details::PairIndexVolume< + ArborX::ExperimentalHyperGeometry::Box<2>>> const tree(execution_space, triangles); std::cout << "BVH tree set up.\n"; @@ -309,11 +311,9 @@ int main() ArborX::Point &coeffs; }; - ArborX::Details::TreeTraversal< - ArborX::BasicBoundingVolumeHierarchy< - MemorySpace, ArborX::ExperimentalHyperGeometry::Box<2>>, - Dummy, TriangleIntersectionCallback, - ArborX::Details::SpatialPredicateTag> + ArborX::Details::TreeTraversal, + ArborX::Details::SpatialPredicateTag> tree_traversal(tree, TriangleIntersectionCallback{triangles});