Skip to content

Commit

Permalink
feat: added serialization/deserialization subroutines to superdrop da…
Browse files Browse the repository at this point in the history
…ta structure
  • Loading branch information
wiltonloch committed Aug 26, 2024
1 parent 527fa13 commit b737809
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions libs/superdrops/superdrop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,40 @@ class Superdrop {
coord1 += delta1;
coord2 += delta2;
}

KOKKOS_INLINE_FUNCTION
void serialize_double_components(std::vector<double>::iterator target) const {
*target++ = coord3;
*target++ = coord1;
*target++ = coord2;
*target++ = attrs.radius;
*target = attrs.msol;
}

KOKKOS_INLINE_FUNCTION
void serialize_uint_components(std::vector<unsigned int>::iterator target) {
*target = sdgbxindex;
}

KOKKOS_INLINE_FUNCTION
void serialize_uint64_components(std::vector<uint64_t>::iterator target) {
*target = attrs.xi;
}

KOKKOS_INLINE_FUNCTION
void deserialize_components(std::vector<unsigned int>::iterator uint_source,
std::vector<uint64_t>::iterator uint64_source,
std::vector<double>::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_

0 comments on commit b737809

Please sign in to comment.