From d0524b53a52d330dddfcad44bbfdc33875c17533 Mon Sep 17 00:00:00 2001 From: Andrey Prokopenko Date: Tue, 1 Oct 2024 12:05:34 -0400 Subject: [PATCH 1/2] Update ParticleLevelSet ArborX to work with both ArborX versions --- src/Picasso_ParticleLevelSet.hpp | 63 ++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/src/Picasso_ParticleLevelSet.hpp b/src/Picasso_ParticleLevelSet.hpp index 948e2f7..f224382 100644 --- a/src/Picasso_ParticleLevelSet.hpp +++ b/src/Picasso_ParticleLevelSet.hpp @@ -95,16 +95,23 @@ struct ParticleLevelSetPredicateData // Query callback. When the query occurs we store the distance to the closest // point. We don't use the tree graph so we don't insert anything into the // graph. +#if ARBORX_VERSION < 10799 template +#else +template +#endif struct ParticleLevelSetCallback { +#if ARBORX_VERSION < 10799 ParticleLevelSetPrimitiveData< CoordinateSlice, Kokkos::View> primitive_data; +#endif DistanceEstimateView distance_estimate; float radius; +#if ARBORX_VERSION < 10799 template KOKKOS_FUNCTION void operator()( Predicate const& predicate, int primitive_index ) const @@ -122,6 +129,22 @@ struct ParticleLevelSetCallback distance_estimate( storage.i, storage.j, storage.k, 0 ) = sqrt( dx * dx + dy * dy + dz * dz ) - radius; } +#else + template + KOKKOS_FUNCTION void operator()( Predicate const& predicate, + Point const& point ) const + { + // Get the predicate storage. + auto storage = getData( predicate ); + + // Compute the distance from the grid entity to the particle sphere. + float dx = static_cast( point[0] ) - storage.x; + float dy = static_cast( point[1] ) - storage.y; + float dz = static_cast( point[2] ) - storage.z; + distance_estimate( storage.i, storage.j, storage.k, 0 ) = + sqrt( dx * dx + dy * dy + dz * dz ) - radius; + } +#endif }; } // end namespace Picasso @@ -135,8 +158,12 @@ namespace ArborX // coordinates of the color we build the level set for. template struct AccessTraits< - Picasso::ParticleLevelSetPrimitiveData, - PrimitivesTag> + Picasso::ParticleLevelSetPrimitiveData +#if ARBORX_VERSION < 10799 + , + PrimitivesTag +#endif + > { using primitive_data = Picasso::ParticleLevelSetPrimitiveData; @@ -146,15 +173,15 @@ struct AccessTraits< { return data.num_color; } - static KOKKOS_FUNCTION Point get( const primitive_data& data, size_type i ) + static KOKKOS_FUNCTION auto get( const primitive_data& data, size_type i ) { // Get the actual index of the particle. auto p = data.c( i ); // Return a point made from the particles. - return { static_cast( data.x( p, 0 ) ), - static_cast( data.x( p, 1 ) ), - static_cast( data.x( p, 2 ) ) }; + return ArborX::Point{ static_cast( data.x( p, 0 ) ), + static_cast( data.x( p, 1 ) ), + static_cast( data.x( p, 2 ) ) }; } }; @@ -162,8 +189,12 @@ struct AccessTraits< // on which we build the level set. template struct AccessTraits< - Picasso::ParticleLevelSetPredicateData, - PredicatesTag> + Picasso::ParticleLevelSetPredicateData +#if ARBORX_VERSION < 10799 + , + PredicatesTag +#endif + > { using predicate_data = Picasso::ParticleLevelSetPredicateData; @@ -366,19 +397,27 @@ class ParticleLevelSet primitive_data.x = x_p; primitive_data.c = _color_indices; primitive_data.num_color = _color_count; +#if ARBORX_VERSION < 10799 ArborX::BVH bvh( exec_space, primitive_data ); +#else + ArborX::BoundingVolumeHierarchy bvh( exec_space, primitive_data ); +#endif // Make the search predicates. ParticleLevelSetPredicateData predicate_data( local_mesh, *local_grid ); // Make the distance callback. +#if ARBORX_VERSION < 10799 ParticleLevelSetCallback - distance_callback; - distance_callback.primitive_data = primitive_data; - distance_callback.distance_estimate = estimate_view; - distance_callback.radius = static_cast( _radius ); + distance_callback{ primitive_data, estimate_view, + static_cast( _radius ) }; +#else + ParticleLevelSetCallback + distance_callback{ estimate_view, + static_cast( _radius ) }; +#endif // Query the particle tree with the mesh entities to find the // closest particle and compute the initial signed distance From 0dec352fb9c042bc9f8cb0fb71a5da5520f4dadd Mon Sep 17 00:00:00 2001 From: Sam Reeve <6740307+streeve@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:17:37 -0500 Subject: [PATCH 2/2] Add tests with 1.7 and near-2.0 ArborX --- .github/workflows/CI.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b365742..42c59c9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -22,8 +22,8 @@ jobs: cxx: ['g++', 'clang++'] openmp: ['ON', 'OFF'] cmake_build_type: ['Debug', 'Release'] - kokkos_ver: ['4.1.00'] - arborx: ['ArborX'] + kokkos_ver: ['4.2.00'] + arborx: ['v1.7'] coverage: ['OFF'] include: - distro: 'ubuntu:latest' @@ -37,7 +37,15 @@ jobs: cxx: 'g++' openmp: 'ON' cmake_build_type: 'Debug' - kokkos_ver: '4.1.00' + kokkos_ver: '4.3.00' + arborx: 'fee3d777c0325a90ab50671fca69f2dc98f2a882' + coverage: 'OFF' + - distro: 'ubuntu:latest' + cxx: 'g++' + openmp: 'ON' + cmake_build_type: 'Debug' + kokkos_ver: '4.2.00' + arborx: 'v1.7' coverage: 'ON' runs-on: ubuntu-latest container: ghcr.io/ecp-copa/ci-containers/${{ matrix.distro }} @@ -69,7 +77,7 @@ jobs: uses: actions/checkout@v3 with: repository: arborx/ArborX - ref: v1.2 + ref: ${{ matrix.arborx }} path: arborx - name: Build arborx if: ${{ matrix.arborx != 'OFF' }} @@ -151,7 +159,7 @@ jobs: matrix: cxx: ['hipcc'] cmake_build_type: ['Release'] - kokkos_ver: ['3.7.02'] + kokkos_ver: ['4.2.00'] runs-on: ubuntu-20.04 container: ghcr.io/ecp-copa/ci-containers/rocm:latest steps: @@ -191,7 +199,7 @@ jobs: uses: actions/checkout@v3 with: repository: arborx/ArborX - ref: v1.2 + ref: v1.7 path: arborx - name: Build arborx working-directory: arborx @@ -250,7 +258,7 @@ jobs: strategy: matrix: cmake_build_type: ['Release'] - kokkos_ver: ['3.7.02'] + kokkos_ver: ['4.2.00'] runs-on: ubuntu-20.04 container: ghcr.io/ecp-copa/ci-containers/cuda:12.2.0 steps: @@ -290,7 +298,7 @@ jobs: uses: actions/checkout@v3 with: repository: arborx/ArborX - ref: v1.2 + ref: v1.7 path: arborx - name: Build arborx working-directory: arborx