From b737809be626e54d00e418c9b7a94ba245d37171 Mon Sep 17 00:00:00 2001 From: wiltonloch Date: Tue, 9 Jul 2024 13:58:50 +0200 Subject: [PATCH] feat: added serialization/deserialization subroutines to superdrop data structure --- libs/superdrops/superdrop.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libs/superdrops/superdrop.hpp b/libs/superdrops/superdrop.hpp index 6e4702a5..1ad7afb9 100644 --- a/libs/superdrops/superdrop.hpp +++ b/libs/superdrops/superdrop.hpp @@ -289,6 +289,40 @@ class Superdrop { coord1 += delta1; coord2 += delta2; } + + KOKKOS_INLINE_FUNCTION + void serialize_double_components(std::vector::iterator target) const { + *target++ = coord3; + *target++ = coord1; + *target++ = coord2; + *target++ = attrs.radius; + *target = attrs.msol; + } + + KOKKOS_INLINE_FUNCTION + void serialize_uint_components(std::vector::iterator target) { + *target = sdgbxindex; + } + + KOKKOS_INLINE_FUNCTION + void serialize_uint64_components(std::vector::iterator target) { + *target = attrs.xi; + } + + KOKKOS_INLINE_FUNCTION + void deserialize_components(std::vector::iterator uint_source, + std::vector::iterator uint64_source, + std::vector::iterator double_source) { + sdgbxindex = *uint_source; + + attrs.xi = *uint64_source; + + coord3 = *double_source++; + coord1 = *double_source++; + coord2 = *double_source++; + attrs.radius = *double_source++; + attrs.msol = *double_source; + } }; #endif // LIBS_SUPERDROPS_SUPERDROP_HPP_