SpECTRE Documentation Coverage Report
Current view: top level - Utilities/Serialization - PupBoost.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 100.0 % 1 1
Test Date: 2026-10-22 17:29:42
Legend: Lines:     hit not hit

            Line data    Source code
       1            1 : // Distributed under the MIT License.
       2              : // See LICENSE.txt for details.
       3              : 
       4              : /// \file
       5              : /// Defines helper functions for working with boost.
       6              : 
       7              : #pragma once
       8              : 
       9              : #include <boost/container/small_vector.hpp>
      10              : #include <boost/container/static_vector.hpp>
      11              : #include <boost/math/quaternion.hpp>
      12              : #include <boost/rational.hpp>
      13              : #include <pup.h>
      14              : 
      15              : namespace PUP {
      16              : /// @{
      17              : /// \ingroup ParallelGroup
      18              : /// Serialization of boost::rational for Charm++
      19              : template <class T>
      20              : void pup(PUP::er& p, boost::rational<T>& var) {  // NOLINT
      21              :   if (p.isUnpacking()) {
      22              :     typename boost::rational<T>::int_type n, d;
      23              :     p | n;
      24              :     p | d;
      25              :     var.assign(n, d);
      26              :   } else {
      27              :     typename boost::rational<T>::int_type n = var.numerator();
      28              :     typename boost::rational<T>::int_type d = var.denominator();
      29              :     p | n;
      30              :     p | d;
      31              :   }
      32              : }
      33              : 
      34              : template <typename T>
      35              : inline void operator|(PUP::er& p, boost::rational<T>& var) {  // NOLINT
      36              :   pup(p, var);
      37              : }
      38              : /// @}
      39              : 
      40              : template <class T, size_t N>
      41              : void pup(PUP::er& p, boost::container::static_vector<T, N>& v) {
      42              :   auto size = v.size();
      43              :   p | size;
      44              :   v.resize(size);
      45              :   if (PUP::as_bytes<T>::value) {
      46              :     PUParray(p, v.data(), size);
      47              :   } else {
      48              :     for (auto& x : v) {
      49              :       p | x;
      50              :     }
      51              :   }
      52              : }
      53              : 
      54              : template <class T, size_t N>
      55              : void operator|(PUP::er& p, boost::container::static_vector<T, N>& v) {
      56              :   pup(p, v);
      57              : }
      58              : 
      59              : template <class T, size_t N>
      60              : void pup(PUP::er& p, boost::container::small_vector<T, N>& v) {
      61              :   auto size = v.size();
      62              :   p | size;
      63              :   v.resize(size);
      64              :   if (PUP::as_bytes<T>::value) {
      65              :     PUParray(p, v.data(), size);
      66              :   } else {
      67              :     for (auto& x : v) {
      68              :       p | x;
      69              :     }
      70              :   }
      71              : }
      72              : 
      73              : template <class T, size_t N>
      74              : void operator|(PUP::er& p, boost::container::small_vector<T, N>& v) {
      75              :   pup(p, v);
      76              : }
      77              : 
      78              : template <typename T>
      79              : void pup(PUP::er& p, boost::math::quaternion<T>& quaternion) {
      80              :   T component_1 = quaternion.R_component_1();
      81              :   T component_2 = quaternion.R_component_2();
      82              :   T component_3 = quaternion.R_component_3();
      83              :   T component_4 = quaternion.R_component_4();
      84              :   p | component_1;
      85              :   p | component_2;
      86              :   p | component_3;
      87              :   p | component_4;
      88              :   if (p.isUnpacking()) {
      89              :     quaternion = boost::math::quaternion<T>(component_1, component_2,
      90              :                                             component_3, component_4);
      91              :   }
      92              : }
      93              : 
      94              : template <typename T>
      95              : void operator|(PUP::er& p, boost::math::quaternion<T>& quaternion) {
      96              :   pup(p, quaternion);
      97              : }
      98              : }  // namespace PUP
        

Generated by: LCOV version 2.0-1