From 2fbac5daab4255d171d10efa7af95c3bd72a8186 Mon Sep 17 00:00:00 2001 From: Sam Reeve <6740307+streeve@users.noreply.github.com> Date: Wed, 7 Aug 2024 17:42:16 -0400 Subject: [PATCH] Add option for custom boundary index spaces --- src/CabanaPD_Boundary.hpp | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/CabanaPD_Boundary.hpp b/src/CabanaPD_Boundary.hpp index 6d2cffc..9acef4c 100644 --- a/src/CabanaPD_Boundary.hpp +++ b/src/CabanaPD_Boundary.hpp @@ -27,6 +27,9 @@ struct RectangularPrism struct Cylinder { }; +struct Custom +{ +}; // Forward declaration. template @@ -109,6 +112,7 @@ struct BoundaryIndexSpace> // Default for empty case. BoundaryIndexSpace() {} + // Construct from region (search for boundary particles). template BoundaryIndexSpace( ExecSpace exec_space, Particles particles, std::vector> planes, @@ -174,6 +178,19 @@ struct BoundaryIndexSpace> auto time() { return _timer.time(); }; }; +template +struct BoundaryIndexSpace +{ + using index_view_type = Kokkos::View; + index_view_type _view; + + // Construct from a View of boundary particles. + BoundaryIndexSpace( index_view_type input_view ) + : _view( input_view ) + { + } +}; + template auto createBoundaryIndexSpace( ExecSpace exec_space, Particles particles, std::vector planes, @@ -184,6 +201,13 @@ auto createBoundaryIndexSpace( ExecSpace exec_space, Particles particles, exec_space, particles, planes, initial_guess ); } +template +auto createBoundaryIndexSpace( BoundaryParticles particles ) +{ + using memory_space = typename BoundaryParticles::memory_space; + return BoundaryIndexSpace( particles ); +} + struct ForceValueBCTag { }; @@ -357,6 +381,30 @@ auto createBoundaryCondition( UserFunctor user_functor, ExecSpace exec_space, bc_indices, user_functor, force_update ); } +// Custom index space cases +template +auto createBoundaryCondition( BCTag, const double value, + BoundaryParticles particles ) +{ + using memory_space = typename Particles::memory_space; + using bc_index_type = BoundaryIndexSpace; + bc_index_type bc_indices = createBoundaryIndexSpace( particles ); + return BoundaryCondition( value, bc_indices ); +} + +template +auto createBoundaryCondition( UserFunctor user_functor, + BoundaryParticles particles, + const bool force_update ) +{ + using memory_space = typename Particles::memory_space; + using bc_index_type = BoundaryIndexSpace; + bc_index_type bc_indices = createBoundaryIndexSpace( particles ); + return BoundaryCondition( + bc_indices, user_functor, force_update ); +} + +// Wrappers for single plane cases. template auto createBoundaryCondition( BCTag tag, const double value, ExecSpace exec_space, Particles particles,