MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / unpack_surface

Function unpack_surface

src/SBTL/SVDSurfaceSerializer.cpp:382–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382SVDSurface unpack_surface(const std::string& fluid_name, const msgpack::object& o) {
383 check_array(o, 4, "surface");
384 const auto input_pair = static_cast<::CoolProp::input_pairs>(as<std::int32_t>(o.via.array.ptr[0]));
385
386 const auto& props_obj = o.via.array.ptr[1];
387 check_array(props_obj, 0, "properties");
388 std::vector<::CoolProp::parameters> properties;
389 properties.reserve(props_obj.via.array.size);
390 for (std::uint32_t i = 0; i < props_obj.via.array.size; ++i) {
391 const auto& pe = props_obj.via.array.ptr[i];
392 check_array(pe, 1, "property entry");
393 properties.push_back(static_cast<::CoolProp::parameters>(as<std::int32_t>(pe.via.array.ptr[0])));
394 }
395
396 SVDSurface surface(fluid_name, input_pair, properties);
397
398 // Acquire SA handle once per surface load — passed into unpack_region
399 // → unpack_curve so the SUPERANCILLARY arm can rehydrate without
400 // re-constructing the HEOS state for every region.
401 const auto sa = acquire_superanc_for(fluid_name);
402
403 const auto& regions_obj = o.via.array.ptr[2];
404 check_array(regions_obj, 0, "regions");
405 for (std::uint32_t i = 0; i < regions_obj.via.array.size; ++i) {
406 surface.add_region(unpack_region(regions_obj.via.array.ptr[i], sa));
407 }
408
409 const auto& decomps_obj = o.via.array.ptr[3];
410 check_array(decomps_obj, 0, "decomps");
411 for (std::uint32_t i = 0; i < decomps_obj.via.array.size; ++i) {
412 std::size_t r_idx = 0;
413 ::CoolProp::parameters prop{};
414 auto decomp = unpack_decomp(decomps_obj.via.array.ptr[i], &r_idx, &prop);
415 surface.add_region_property_svd(r_idx, prop, std::move(decomp));
416 }
417
418 surface.seal();
419 return surface;
420}
421
422// ---------- compression / decompression -------------------------------
423

Callers 1

loadMethod · 0.85

Calls 7

check_arrayFunction · 0.85
acquire_superanc_forFunction · 0.85
unpack_regionFunction · 0.85
unpack_decompFunction · 0.85
add_regionMethod · 0.80
sealMethod · 0.80

Tested by

no test coverage detected