16#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
40 SUBCASE(
"write and read via operator()")
51 SUBCASE(
"operator[] pointer access")
66 SUBCASE(
"DataSize and DataSizeBytes")
93 CHECK(
b.DataSize() == 8 * 5);
162 SUBCASE(
"Resize with lambda and compress round-trip")
186 SUBCASE(
"Decompress, modify, re-Compress")
240 SUBCASE(
"clone produces identical independent copy")
253 CHECK(dst(0, 0) != -999.0);
256 SUBCASE(
"CopyData produces identical copy")
267 SUBCASE(
"copy constructor")
278 SUBCASE(
"SwapData exchanges contents")
291 CHECK(src(0, 0) == other_0_0);
292 CHECK(other(0, 0) == src_0_0);
301 SUBCASE(
"zero-size TABLE_StaticFixed")
307 CHECK(
z.DataSizeBytes() == 0);
310 SUBCASE(
"single element TABLE_StaticFixed")
317 CHECK(s(0, 0) == 42.0);
318 CHECK(s(0, 1) == 43.0);
321 SUBCASE(
"CSR with lambda returning 0 for some rows")
325 {
return (
i % 2 == 0) ? 0 : 3; });
345 SUBCASE(
"zero-size TABLE_Fixed")
360 const std::string tmpFile =
"__test_array_ser_tmp.json";
363 std::filesystem::remove(tmpFile);
366 SUBCASE(
"TABLE_Fixed round-trip")
376 auto ser = std::make_shared<S::SerializerJSON>();
377 ser->OpenFile(tmpFile,
false);
386 auto ser = std::make_shared<S::SerializerJSON>();
387 ser->OpenFile(tmpFile,
true);
401 SUBCASE(
"CSR round-trip")
413 auto ser = std::make_shared<S::SerializerJSON>();
414 ser->OpenFile(tmpFile,
false);
427 auto ser = std::make_shared<S::SerializerJSON>();
428 ser->OpenFile(tmpFile,
true);
444 SUBCASE(
"TABLE_StaticFixed round-trip")
454 auto ser = std::make_shared<S::SerializerJSON>();
455 ser->OpenFile(tmpFile,
false);
464 auto ser = std::make_shared<S::SerializerJSON>();
465 ser->OpenFile(tmpFile,
true);
485 SUBCASE(
"GetArraySignature returns non-empty string")
488 CHECK_FALSE(sig.empty());
489 CHECK(sig.find(
"TABLE_StaticFixed") != std::string::npos);
492 SUBCASE(
"ParseArraySignatureTuple round-trips")
502 SUBCASE(
"ArraySignatureIsCompatible for matching type")
508 SUBCASE(
"ArraySignatureIsCompatible accepts DynamicSize reading static")
516 SUBCASE(
"ArraySignatureIsCompatible rejects mismatched sizes")
523 SUBCASE(
"CSR signature")
526 CHECK(sig.find(
"CSR") != std::string::npos);
535 SUBCASE(
"identical arrays have the same hash")
550 SUBCASE(
"modified array has different hash")
575template <
class T,
class Layout, DNDS::rowsize RS>
584#define ARRAY_TAG_STR(T, L, RS) TYPE_TO_STRING(ArrayTag<T, L, RS>)
630#define ARRAY_ALL_TAGS \
632 ArrayTag<DNDS::real, LayoutStaticFixed, 1>, \
633 ArrayTag<DNDS::real, LayoutStaticFixed, 3>, \
634 ArrayTag<DNDS::real, LayoutStaticFixed, 7>, \
636 ArrayTag<DNDS::real, LayoutDynamic, 1>, \
637 ArrayTag<DNDS::real, LayoutDynamic, 3>, \
638 ArrayTag<DNDS::real, LayoutDynamic, 7>, \
640 ArrayTag<DNDS::real, LayoutCSR, 0>, \
642 ArrayTag<DNDS::index, LayoutStaticFixed, 1>, \
643 ArrayTag<DNDS::index, LayoutStaticFixed, 3>, \
644 ArrayTag<DNDS::index, LayoutStaticFixed, 7>, \
645 ArrayTag<DNDS::index, LayoutDynamic, 1>, \
646 ArrayTag<DNDS::index, LayoutDynamic, 3>, \
647 ArrayTag<DNDS::index, LayoutDynamic, 7>, \
648 ArrayTag<DNDS::index, LayoutCSR, 0>, \
650 ArrayTag<uint16_t, LayoutStaticFixed, 1>, \
651 ArrayTag<uint16_t, LayoutStaticFixed, 3>, \
652 ArrayTag<uint16_t, LayoutStaticFixed, 7>, \
653 ArrayTag<uint16_t, LayoutDynamic, 1>, \
654 ArrayTag<uint16_t, LayoutDynamic, 3>, \
655 ArrayTag<uint16_t, LayoutDynamic, 7>, \
656 ArrayTag<uint16_t, LayoutCSR, 0>, \
658 ArrayTag<int32_t, LayoutStaticFixed, 1>, \
659 ArrayTag<int32_t, LayoutStaticFixed, 3>, \
660 ArrayTag<int32_t, LayoutStaticFixed, 7>, \
661 ArrayTag<int32_t, LayoutDynamic, 1>, \
662 ArrayTag<int32_t, LayoutDynamic, 3>, \
663 ArrayTag<int32_t, LayoutDynamic, 7>, \
664 ArrayTag<int32_t, LayoutCSR, 0>, \
666 ArrayTag<uint8_t, LayoutStaticFixed, 1>, \
667 ArrayTag<uint8_t, LayoutStaticFixed, 3>, \
668 ArrayTag<uint8_t, LayoutStaticFixed, 7>, \
669 ArrayTag<uint8_t, LayoutDynamic, 1>, \
670 ArrayTag<uint8_t, LayoutDynamic, 3>, \
671 ArrayTag<uint8_t, LayoutDynamic, 7>, \
672 ArrayTag<uint8_t, LayoutCSR, 0>
676 using T =
typename Tag::type;
677 using L =
typename Tag::layout;
684 if constexpr (std::is_same_v<L, LayoutStaticFixed>)
694 a(
i,
j) =
static_cast<T
>(
i * 100 +
j * 3 + 7);
698 CHECK(a(
i,
j) ==
static_cast<T
>(
i * 100 +
j * 3 + 7));
700 else if constexpr (std::is_same_v<L, LayoutDynamic>)
710 a(
i,
j) =
static_cast<T
>(
i * 100 +
j * 3 + 7);
714 CHECK(a(
i,
j) ==
static_cast<T
>(
i * 100 +
j * 3 + 7));
733 a(
i,
j) =
static_cast<T
>(
i * 100 +
j * 3 + 7);
740 CHECK(a(
i,
j) ==
static_cast<T
>(
i * 100 +
j * 3 + 7));
Core 2D variable-length array container with five data layouts.
Core 2D variable-length array container, the storage foundation of DNDSR.
std::size_t hash()
Combined hash of size, structural arrays, and data.
void Resize(index nSize, rowsize nRow_size_dynamic)
Resize the array, setting a uniform or maximum row width.
void CopyData(const self_type &R)
Deep copy alias. Currently delegates to clone; kept for API compatibility and to allow a future true ...
void Decompress()
Layout-polymorphic decompress: no-op for non-CSR, calls CSRDecompress for CSR.
rowsize RowSize() const
Uniform row width for fixed layouts (no row index needed).
void WriteSerializer(Serializer::SerializerBaseSSP serializerP, const std::string &name, Serializer::ArrayGlobalOffset offset, Serializer::ArrayGlobalOffset dataOffset=Serializer::ArrayGlobalOffset_Unknown)
Serialize (write) array data to a serializer.
bool IfCompressed() const
(CSR only) Whether the array is in packed / flat form.
void SwapData(self_type &R)
Swap the storage of two arrays in-place.
size_t DataSizeBytes() const
Flat buffer size in bytes (= DataSize() * sizeof(T)).
void ResizeRow(index iRow, rowsize nRowSize)
Change the width of a single row.
size_t DataSize() const
Total number of T elements currently stored in the flat buffer.
void Compress()
Layout-polymorphic compress: no-op for non-CSR, calls CSRCompress for CSR.
rowsize RowSizeMax() const
Maximum allowed row width for TABLE_Max / TABLE_StaticMax.
index Size() const
Number of rows currently stored. O(1).
void clone(const self_type &R)
Shallow clone: copies all metadata and shares structural/data storage.
void ReadSerializer(Serializer::SerializerBaseSSP serializerP, const std::string &name, Serializer::ArrayGlobalOffset &offset)
Convenience overload that discards the dataOffset output.
constexpr DataLayout GetDataLayout()
Runtime accessor for the layout tag (constexpr-folded).
Describes one rank's window into a globally-distributed dataset.
the host side operators are provided as implemented
int32_t rowsize
Row-width / per-row element-count type (signed 32-bit).
DNDS_CONSTANT const rowsize DynamicSize
Template parameter flag: "row width is set at runtime but uniform".
@ TABLE_StaticFixed
Fixed row width, known at compile time.
@ TABLE_Max
Padded variable rows; max width set at runtime.
@ CSR
Compressed Sparse Row (flat buffer + row-start index).
@ TABLE_StaticMax
Padded variable rows; max width fixed at compile time.
@ TABLE_Fixed
Fixed row width, set at runtime (uniform across rows).
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
static constexpr DNDS::rowsize rs
#define ARRAY_TAG_STR(T, L, RS)
TEST_CASE_TEMPLATE("Array resize-write-read", Tag, ARRAY_ALL_TAGS)
REQUIRE(bool(result.parent2entityPbi.father))
TEST_CASE("3D: VFV P2 HQM error < P1 on sinCos3D")