BioCMAMC-ST
serdes_class.hpp
1#ifndef __UTILS_SERDES_HPP__
2#define __UTILS_SERDES_HPP__
3
4#include "mc/alias.hpp"
5#include <cassert>
6#include <mc/traits.hpp>
7#include <optional>
8
9// NOLINTBEGIN
11{
12 using uniform_weight = std::true_type; // Using type alias
14 using FloatType = float;
15 using Config = std::nullopt_t;
16
17 enum class particle_var : int
18 {
19 a = 0,
23 };
24
25 static constexpr std::size_t n_var = INDEX_FROM_ENUM(particle_var::COUNT);
26 static constexpr std::string_view name = "simple";
28
29 MODEL_CONSTANT FloatType a_i = 5e-6; // m
30
31 KOKKOS_INLINE_FUNCTION static void
32 init([[maybe_unused]] const MC::KPRNG::pool_type& random_pool,
33 std::size_t idx,
34 const SelfParticle& arr)
35 {
36 GET_PROPERTY(SerdeModel::particle_var::a) = a_i;
37 }
38
39 KOKKOS_INLINE_FUNCTION static double
40 mass([[maybe_unused]] std::size_t idx,
41 [[maybe_unused]] const SelfParticle& arr)
42 {
43 return 1.;
44 }
45
46 KOKKOS_INLINE_FUNCTION static MC::Status
47 update([[maybe_unused]] const MC::KPRNG::pool_type& random_pool,
48 [[maybe_unused]] FloatType d_t,
49 [[maybe_unused]] std::size_t idx,
50 [[maybe_unused]] const SelfParticle& arr,
51 [[maybe_unused]] const MC::LocalConcentration& c)
52 {
53
54 return MC::Status::Idle;
55 }
56
57 KOKKOS_INLINE_FUNCTION static void
58 division([[maybe_unused]] const MC::KPRNG::pool_type& random_pool,
59 [[maybe_unused]] std::size_t idx,
60 [[maybe_unused]] std::size_t idx2,
61 [[maybe_unused]] const SelfParticle& arr,
62 [[maybe_unused]] const SelfParticle& buffer_arr)
63 {
64 }
65
67 {
68 return {0, 0};
69 }
70};
71static_assert(ModelType<SerdeModel>, "Check non serde model");
72
73#endif
Kokkos::Random_XorShift1024_Pool< Kokkos::DefaultExecutionSpace > pool_type
Definition prng.hpp:33
Model type.
Definition traits.hpp:148
Status
Definition alias.hpp:37
@ Idle
Definition alias.hpp:38
Kokkos::Subview< KernelConcentrationType, int, decltype(Kokkos::ALL)> LocalConcentration
Definition alias.hpp:72
Kokkos::View< F *[Nd], Kokkos::LayoutRight > ParticlesModel
Definition traits.hpp:34
Definition alias.hpp:45
Definition serdes_class.hpp:11
static constexpr std::string_view name
Definition serdes_class.hpp:26
static constexpr std::size_t n_var
Definition serdes_class.hpp:25
static KOKKOS_INLINE_FUNCTION void init(const MC::KPRNG::pool_type &random_pool, std::size_t idx, const SelfParticle &arr)
Definition serdes_class.hpp:32
particle_var
Definition serdes_class.hpp:18
@ a
Definition serdes_class.hpp:19
@ COUNT
Definition serdes_class.hpp:22
@ c
Definition serdes_class.hpp:21
@ b
Definition serdes_class.hpp:20
static KOKKOS_INLINE_FUNCTION MC::Status update(const MC::KPRNG::pool_type &random_pool, FloatType d_t, std::size_t idx, const SelfParticle &arr, const MC::LocalConcentration &c)
Definition serdes_class.hpp:47
std::nullopt_t Config
Definition serdes_class.hpp:15
static MC::ContribIndexBounds get_bounds()
Definition serdes_class.hpp:66
static KOKKOS_INLINE_FUNCTION void division(const MC::KPRNG::pool_type &random_pool, std::size_t idx, std::size_t idx2, const SelfParticle &arr, const SelfParticle &buffer_arr)
Definition serdes_class.hpp:58
SerdeModel Self
Definition serdes_class.hpp:13
float FloatType
Definition serdes_class.hpp:14
MC::ParticlesModel< Self::n_var, Self::FloatType > SelfParticle
Definition serdes_class.hpp:27
std::true_type uniform_weight
Definition serdes_class.hpp:12
static KOKKOS_INLINE_FUNCTION double mass(std::size_t idx, const SelfParticle &arr)
Definition serdes_class.hpp:40
MODEL_CONSTANT FloatType a_i
Definition serdes_class.hpp:29