| 56 | |
| 57 | template <typename Packer> |
| 58 | void pack_curve(Packer& pk, const region::BoundaryCurve& curve) { |
| 59 | // dynamic_cast probes for each known concrete type. Order is |
| 60 | // chosen so the cheapest cast (ConstantCurve) is tried first. |
| 61 | if (const auto* c = dynamic_cast<const region::ConstantCurve*>(&curve)) { |
| 62 | const auto s = c->state(); |
| 63 | pk.pack_array(4); |
| 64 | pk.pack(static_cast<std::uint8_t>(CurveKind::CONSTANT)); |
| 65 | pk.pack(s.a_lo); |
| 66 | pk.pack(s.a_hi); |
| 67 | pk.pack(s.b); |
| 68 | return; |
| 69 | } |
| 70 | if (const auto* c = dynamic_cast<const region::CubicSplineCurve*>(&curve)) { |
| 71 | const auto s = c->state(); |
| 72 | pk.pack_array(6); |
| 73 | pk.pack(static_cast<std::uint8_t>(CurveKind::CUBIC_SPLINE)); |
| 74 | pk.pack(s.a); |
| 75 | pk.pack(s.b); |
| 76 | pk.pack(s.M); |
| 77 | pk.pack(s.b_min); |
| 78 | pk.pack(s.b_max); |
| 79 | return; |
| 80 | } |
| 81 | if (const auto* c = dynamic_cast<const region::PiecewiseChebyshevCurve*>(&curve)) { |
| 82 | const auto s = c->state(); |
| 83 | pk.pack_array(7); |
| 84 | pk.pack(static_cast<std::uint8_t>(CurveKind::PIECEWISE_CHEBYSHEV)); |
| 85 | pk.pack(s.a_lo); |
| 86 | pk.pack(s.a_hi); |
| 87 | pk.pack(static_cast<std::uint8_t>(s.scale)); |
| 88 | pk.pack_array(s.pieces.size()); |
| 89 | for (const auto& p : s.pieces) { |
| 90 | pk.pack_array(6); |
| 91 | pk.pack(p.t_lo); |
| 92 | pk.pack(p.t_hi); |
| 93 | pk.pack(p.inv_half_span); |
| 94 | pk.pack(p.t_mid); |
| 95 | pk.pack(p.coeffs); |
| 96 | pk.pack(p.deriv_coeffs); |
| 97 | } |
| 98 | pk.pack(s.b_min); |
| 99 | pk.pack(s.b_max); |
| 100 | return; |
| 101 | } |
| 102 | if (const auto* c = dynamic_cast<const region::SuperancillaryBoundaryCurve*>(&curve)) { |
| 103 | const auto s = c->state(); |
| 104 | // Pack only the State POD scalars; the SuperAncillary handle |
| 105 | // itself isn't serialised (it's a per-fluid singleton lazily |
| 106 | // built by HelmholtzEOSMixtureBackend). On load, the handle |
| 107 | // is re-acquired from the fluid HEOS at unpack_surface entry. |
| 108 | pk.pack_array(8); |
| 109 | pk.pack(static_cast<std::uint8_t>(CurveKind::SUPERANCILLARY)); |
| 110 | pk.pack(s.p_min); |
| 111 | pk.pack(s.p_max); |
| 112 | pk.pack(static_cast<std::int8_t>(s.prop_key)); |
| 113 | pk.pack(static_cast<std::int16_t>(s.Q)); |
| 114 | pk.pack(s.output_scale); |
| 115 | pk.pack(s.b_min); |
no test coverage detected