1#ifndef __SIMULATION_MOVE_KERNEL_HPP__
2#define __SIMULATION_MOVE_KERNEL_HPP__
4#include "Kokkos_Assert.hpp"
5#include <Kokkos_Core.hpp>
6#include <Kokkos_Random.hpp>
7#include <biocma_cst_config.hpp>
9#include <mc/domain.hpp>
10#include <mc/events.hpp>
11#include <mc/prng/prng.hpp>
12#include <mc/traits.hpp>
13#include <simulation/alias.hpp>
14#include <simulation/probability_leaving.hpp>
15#include <simulation/probe.hpp>
42 KOKKOS_INLINE_FUNCTION std::size_t
45 const std::size_t i_compartment,
46 const double random_number)
48 const int max_neighbor =
static_cast<int>(neighbors.extent(1));
50 std::size_t next = neighbors(i_compartment, 0);
53 for (
int k_neighbor = 0; k_neighbor < max_neighbor - 1; ++k_neighbor)
57 const auto pi = cumulative_probability(i_compartment, k_neighbor);
59 cumulative_probability(i_compartment, k_neighbor + 1);
63 next = (random_number <= pn && pi <= random_number) ? neighbors(i_compartment, k_neighbor + 1)
70 template <
bool enable_leave,
bool enable_move>
struct MoveFunctor
82 KOKKOS_INLINE_FUNCTION
void
83 operator()(
const Kokkos::TeamPolicy<ComputeSpace>::member_type& team_handle,
84 std::size_t& dead_count)
const
107 const float rng1 = generator.frand(0., 1.);
108 const double rng2 = generator.drand(0., 1.);
111 const std::size_t i_current_compartment =
positions(idx);
122 : i_current_compartment;
126 if constexpr (AutoGenerated::FlagCompileTime::enable_event_counter)
135 KOKKOS_FUNCTION
void handle_exit(std::size_t idx, std::size_t& dead_count)
const
142 const float random_number = generator.frand(0., 1.);
147 if (position != index)
157 if constexpr (AutoGenerated::FlagCompileTime::use_probe)
Kokkos::Random_XorShift1024_Pool< Kokkos::DefaultExecutionSpace > pool_type
Definition prng.hpp:17
Kokkos::View< Status *, ComputeSpace > ParticleStatus
Definition alias.hpp:20
Kokkos::View< uint64_t *, ComputeSpace > ParticlePositions
Definition alias.hpp:19
@ Exit
Remove particle from list due to move in domain.
Definition move_kernel.hpp:19
constexpr bool enable_leave
Definition move_kernel.hpp:20
constexpr bool enable_move
Definition move_kernel.hpp:23
constexpr bool disable_leave
Definition move_kernel.hpp:21
KOKKOS_INLINE_FUNCTION std::size_t __find_next_compartment(const ConstNeighborsView< ComputeSpace > &neighbors, const CumulativeProbabilityView< ComputeSpace > &cumulative_probability, const std::size_t i_compartment, const double random_number)
Definition move_kernel.hpp:43
KOKKOS_INLINE_FUNCTION bool probability_leaving(float random_number, double volume, double flow, double dt)
Definition probability_leaving.hpp:31
constexpr bool disable_move
Definition move_kernel.hpp:22
Kokkos::View< std::size_t *, Kokkos::SharedHostPinnedSpace > LeavingFlowIndexType
Definition alias.hpp:25
Kokkos:: View< double *, Kokkos::LayoutLeft, ExecSpace, Kokkos::MemoryTraits< Kokkos::RandomAccess > > DiagonalView
Definition alias.hpp:14
Kokkos::View< double *, Kokkos::SharedHostPinnedSpace > LeavingFlowType
Definition alias.hpp:26
Kokkos:: View< const double **, Kokkos::LayoutRight, Space, Kokkos::MemoryTraits< Kokkos::RandomAccess > > CumulativeProbabilityView
Definition alias.hpp:20
Use to count events that occurs during Monte-Carlo processing cycles.
Definition events.hpp:43
KOKKOS_FORCEINLINE_FUNCTION constexpr void wrap_incr() const
Definition events.hpp:109
Definition move_kernel.hpp:71
KOKKOS_INLINE_FUNCTION void operator()(const Kokkos::TeamPolicy< ComputeSpace >::member_type &team_handle, std::size_t &dead_count) const
Definition move_kernel.hpp:83
MC::ParticleStatus status
Definition move_kernel.hpp:172
MoveFunctor(double _d_t, MC::ParticlePositions p, MC::ParticleStatus _status, std::size_t n_p, MoveInfo< ComputeSpace > m, MC::KPRNG::pool_type _random_pool, MC::EventContainer _events)
Definition move_kernel.hpp:72
MC::ParticlePositions positions
Definition move_kernel.hpp:168
MC::EventContainer events
Definition move_kernel.hpp:173
std::size_t n_particles
Definition move_kernel.hpp:169
MoveInfo< ComputeSpace > move
Definition move_kernel.hpp:170
KOKKOS_FUNCTION void handle_move(const std::size_t idx) const
Definition move_kernel.hpp:104
double d_t
Definition move_kernel.hpp:167
MC::KPRNG::pool_type random_pool
Definition move_kernel.hpp:171
KOKKOS_FUNCTION void handle_exit(std::size_t idx, std::size_t &dead_count) const
Definition move_kernel.hpp:135
Definition move_kernel.hpp:26
MoveInfo()
Definition move_kernel.hpp:34
DiagonalView< ExecSpace > diag_transition
Definition move_kernel.hpp:28
LeavingFlowType leaving_flow
Definition move_kernel.hpp:30
LeavingFlowIndexType index_leaving_flow
Definition move_kernel.hpp:31
CumulativeProbabilityView< ExecSpace > cumulative_probability
Definition move_kernel.hpp:29
ConstNeighborsView< ExecSpace > neighbors
Definition move_kernel.hpp:27
Kokkos::View< double *, ExecSpace > liquid_volume
Definition move_kernel.hpp:32