mesh-sieve 4.0.1

Modular, high-performance Rust library for mesh and data management, designed for scientific computing and PDE codes.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
//! MeshSieveError: Unified error type for mesh-sieve public APIs
//!
//! This error type is used throughout the mesh-sieve library to provide robust,
//! non-panicking error handling for all public APIs.

use std::fmt::Debug;
use thiserror::Error;

/// Unified error type for mesh-sieve operations.
#[derive(Debug, Error)]
pub enum MeshSieveError {
    /// Error indicating that the overlap graph is missing required neighbor links.
    #[error("Missing overlap: {source}")]
    MissingOverlap {
        source: Box<dyn std::error::Error + Send + Sync>,
    },
    /// Generic mesh error (for internal use, e.g. error propagation)
    #[error("mesh error: {0}")]
    MeshError(Box<MeshSieveError>),
    /// Renumbering permutation was invalid.
    #[error("Invalid renumbering permutation: {0}")]
    InvalidPermutation(String),
    /// GPU buffer mapping failed.
    #[error("GPU buffer mapping failed")]
    GpuMappingFailed,
    /// Attempted to construct a PointId with a zero value (invalid).
    #[error("PointId must be non-zero (0 is reserved as invalid/sentinel)")]
    InvalidPointId,
    /// Vertical arrow references a point missing from the base or cap sieve.
    #[error("stack arrow references missing point in {role}: {point}")]
    StackMissingPoint { role: &'static str, point: String },
    /// Mutation on a read-only stack (e.g., `ComposedStack`) is not allowed.
    #[error("Unsupported stack operation: {0}")]
    UnsupportedStackOperation(&'static str),
    /// A point appeared in a cone but wasn’t in the initial point set.
    #[error("Topology error: point `{0}` found in cone but not in point set")]
    MissingPointInCone(String),
    /// Attempted to access a point that is not present in the CSR chart.
    #[error("Topology error: point `{0}` not present in chart")]
    UnknownPoint(String),
    /// The mesh topology contains a cycle; expected a DAG.
    #[error("Topology error: cycle detected in mesh (expected DAG)")]
    CycleDetected,
    /// Attempt to insert a zero-length slice, which is invalid.
    #[error("Atlas error: zero-length slice is not allowed")]
    ZeroLengthSlice,
    /// Attempt to insert a point that’s already in the atlas.
    #[error("Atlas error: point {0:?} already present")]
    DuplicatePoint(crate::topology::point::PointId),
    /// Internal invariant broken: point in order but missing from map.
    #[error("Atlas internal error: missing length for point {0:?}")]
    MissingAtlasPoint(crate::topology::point::PointId),
    /// Attempt to access data for a point not in the atlas.
    #[error("Section error: point {0:?} not found in atlas")]
    PointNotInAtlas(crate::topology::point::PointId),
    /// Attempt to access a point not in the atlas.
    #[error("SievedArray error: point {0:?} not found in atlas")]
    SievedArrayPointNotInAtlas(crate::topology::point::PointId),

    /// Mismatch between expected and provided slice length for a point.
    #[error("Section error: slice length mismatch for {point:?}: expected {expected}, got {found}")]
    SliceLengthMismatch {
        point: crate::topology::point::PointId,
        expected: usize,
        found: usize,
    },
    /// Slice length changed for a point during atlas mutation.
    #[deprecated(note = "Use AtlasPointLengthChanged")]
    #[error("atlas slice length changed for {point:?}: {old} -> {new}")]
    AtlasSliceLengthChanged {
        point: crate::topology::point::PointId,
        old: usize,
        new: usize,
    },
    /// Mismatch between expected and provided slice length for a point (SievedArray).
    #[error(
        "SievedArray error: slice length mismatch at {point:?}: expected {expected}, got {found}"
    )]
    SievedArraySliceLengthMismatch {
        point: crate::topology::point::PointId,
        expected: usize,
        found: usize,
    },

    /// Refinement attempted to map multiple coarse points into the same fine point.
    #[error("Refinement maps more than one coarse point into the same fine point {fine:?}")]
    DuplicateRefinementTarget {
        fine: crate::topology::point::PointId,
    },

    /// Attempt to add a point to the section failed at atlas insertion.
    #[error("Section error: failed to add point {0:?} to atlas: {1}")]
    AtlasInsertionFailed(
        crate::topology::point::PointId,
        #[source] Box<MeshSieveError>,
    ),
    /// Attempt to remove or copy data for a point that disappeared.
    #[error("Section internal error: missing data for point {0:?}")]
    MissingSectionPoint(crate::topology::point::PointId),
    /// Bulk scatter mismatch between total lengths.
    #[error("scatter total length mismatch (expected={expected}, found={found})")]
    ScatterLengthMismatch { expected: usize, found: usize },
    /// One of the scatter chunks did not fit.
    #[error("scatter chunk out of bounds or overflow (offset={offset}, len={len})")]
    ScatterChunkMismatch { offset: usize, len: usize },
    /// Attempted to use a scatter plan built from an outdated atlas.
    #[error("plan stale: built for atlas version {expected}, current {found}")]
    AtlasPlanStale { expected: u64, found: u64 },
    /// Missing section name in a multi/mixed scatter operation.
    #[error("Missing section name {name}")]
    MissingSectionName { name: String },
    /// A DM vector is associated with a different section than the requested operation.
    #[error("vector section mismatch: expected {expected}, found {found:?}")]
    VectorSectionMismatch {
        expected: String,
        found: Option<String>,
    },
    /// Tagged section buffer type mismatch.
    #[error("Tagged section type mismatch (expected {expected:?}, found {found:?})")]
    TaggedSectionTypeMismatch {
        expected: crate::data::mixed_section::ScalarType,
        found: crate::data::mixed_section::ScalarType,
    },
    /// Missing ownership metadata for a point.
    #[error("Ownership missing for point {0:?}")]
    MissingOwnership(crate::topology::point::PointId),
    /// Point's slice length changed across atlas rebuild.
    #[error("atlas point length changed for {point:?} (expected={expected}, found={found})")]
    AtlasPointLengthChanged {
        point: crate::topology::point::PointId,
        expected: usize,
        found: usize,
    },
    /// Reducer or path length mismatch when no concrete point exists.
    #[error("reduction length mismatch (expected={expected}, found={found})")]
    ReducerLengthMismatch { expected: usize, found: usize },
    /// Atlas slices are not contiguous as expected.
    #[error(
        "atlas contiguity mismatch for {point:?} (expected_offset={expected}, found_offset={found})"
    )]
    AtlasContiguityMismatch {
        point: crate::topology::point::PointId,
        expected: usize,
        found: usize,
    },
    /// Failure converting count to primitive (should never happen if FromPrimitive is well-behaved).
    #[error("SievedArray error: cannot convert count {0} via FromPrimitive")]
    SievedArrayPrimitiveConversionFailure(usize),
    /// Delta application failed because source and dest slices had different lengths.
    #[error("Delta error: slice length mismatch (src.len={expected}, dest.len={found})")]
    DeltaLengthMismatch { expected: usize, found: usize },
    /// Constraint index is out of bounds for a point slice.
    #[error("Constraint error at point {point:?}: DOF index {index} out of bounds (len={len})")]
    ConstraintIndexOutOfBounds {
        point: crate::topology::point::PointId,
        index: usize,
        len: usize,
    },
    /// Refinement template did not match the cell cone size.
    #[error(
        "Refinement topology mismatch for cell {cell:?}: template {template} expects {expected} vertices, found {found}"
    )]
    RefinementTopologyMismatch {
        cell: crate::topology::point::PointId,
        template: &'static str,
        expected: usize,
        found: usize,
    },
    /// Unsupported cell type encountered during refinement.
    #[error("Unsupported refinement cell type {cell_type:?} at cell {cell:?}")]
    UnsupportedRefinementCellType {
        cell: crate::topology::point::PointId,
        cell_type: crate::topology::cell_type::CellType,
    },
    /// Partition‐point computation overflowed to zero (invalid owner).
    #[error("Invalid partition owner: computed raw ID = 0")]
    PartitionPointOverflow,
    /// The `parts` slice is missing an entry for point `{0}`.
    #[error("No partition mapping for point ID {0}")]
    PartitionIndexOutOfBounds(usize),
    /// Error sending or receiving data over the wire.
    #[error("communication error: {0}")]
    Communication(#[from] CommError),

    /// Missing expected recv count for a neighbor during data exchange.
    #[error("Missing recv count for neighbor {neighbor}")]
    MissingRecvCount { neighbor: usize },
    /// Error accessing a section for a given point.
    #[error("Section access error at point {point:?}: {source}")]
    SectionAccess {
        point: crate::topology::point::PointId,
        #[source]
        source: Box<dyn std::error::Error + Send + Sync>,
    },
    /// Communication error for a specific neighbor.
    #[error("Communication error with neighbor {neighbor}: {source}")]
    CommError {
        neighbor: usize,
        #[source]
        source: Box<dyn std::error::Error + Send + Sync>,
    },
    /// Buffer size mismatch during data exchange.
    #[error("Buffer size mismatch for neighbor {neighbor}: expected {expected}, got {got}")]
    BufferSizeMismatch {
        neighbor: usize,
        expected: usize,
        got: usize,
    },
    /// Part count mismatch during data exchange.
    #[error("Part count mismatch for neighbor {neighbor}: expected {expected}, got {got}")]
    PartCountMismatch {
        neighbor: usize,
        expected: usize,
        got: usize,
    },
    /// Lengths array count mismatch during data exchange.
    #[error("Lengths count mismatch for neighbor {neighbor}: expected {expected}, got {got}")]
    LengthsCountMismatch {
        neighbor: usize,
        expected: usize,
        got: usize,
    },
    /// Payload element count mismatch during data exchange.
    #[error("Payload count mismatch for neighbor {neighbor}: expected {expected}, got {got}")]
    PayloadCountMismatch {
        neighbor: usize,
        expected: usize,
        got: usize,
    },

    #[error("Overlap link not found for (local={0}, rank={1})")]
    OverlapLinkMissing(crate::topology::point::PointId, usize),

    #[error("Overlap: edge must be Local->Part, found {src:?} -> {dst:?}")]
    OverlapNonBipartite {
        src: crate::overlap::overlap::OvlId,
        dst: crate::overlap::overlap::OvlId,
    },
    #[error("expected Local(_), found {found:?}")]
    OverlapExpectedLocal {
        found: crate::overlap::overlap::OvlId,
    },
    #[error("expected Part(_), found {found:?}")]
    OverlapExpectedPart {
        found: crate::overlap::overlap::OvlId,
    },

    /// Generic I/O error for mesh readers/writers.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),
    /// HDF5 error for mesh readers/writers.
    #[error("HDF5 error: {0}")]
    Hdf5(#[from] hdf5::Error),
    /// Invalid or inverted geometry detected.
    #[error("Geometry error: {0}")]
    InvalidGeometry(String),
    /// Parse error while reading mesh formats.
    #[error("Mesh I/O parse error: {0}")]
    MeshIoParse(String),
    /// Duplicate arrow detected in topology.
    #[error("Topology error: duplicate arrow {src:?} -> {dst:?}")]
    DuplicateArrow {
        src: crate::topology::point::PointId,
        dst: crate::topology::point::PointId,
    },
    /// Cell cone size did not match the expected number of vertices.
    #[error(
        "Topology error: cell {cell:?} of type {cell_type:?} expects cone size {expected}, found {found}"
    )]
    ConeSizeMismatch {
        cell: crate::topology::point::PointId,
        cell_type: crate::topology::cell_type::CellType,
        expected: usize,
        found: usize,
    },
    /// Closure vertex count did not match the expected number of vertices.
    #[error(
        "Topology error: cell {cell:?} of type {cell_type:?} expects {expected} vertices in closure, found {found}"
    )]
    ClosureVertexCountMismatch {
        cell: crate::topology::point::PointId,
        cell_type: crate::topology::cell_type::CellType,
        expected: usize,
        found: usize,
    },
    /// Non-manifold entity detected by counting incident cells.
    #[error(
        "Topology error: non-manifold entity {point:?} (dim={dimension}) has {incident_cells} incident cells"
    )]
    NonManifoldIncidentCells {
        point: crate::topology::point::PointId,
        dimension: u32,
        incident_cells: usize,
    },
    #[error("Overlap: payload.rank {found} != Part({expected})")]
    OverlapRankMismatch { expected: usize, found: usize },
    /// Periodic mapping for a slave point conflicted with existing entry.
    #[error(
        "Periodic mapping conflict for slave {slave:?}: existing master {existing:?}, new master {new:?}"
    )]
    PeriodicMappingConflict {
        slave: crate::topology::point::PointId,
        existing: crate::topology::point::PointId,
        new: crate::topology::point::PointId,
    },
    #[error("Overlap: Part node found in base_points()")]
    OverlapPartInBasePoints,
    #[error("Overlap: Local node found in cap_points()")]
    OverlapLocalInCapPoints,
    #[error("Overlap: duplicate edge {src:?} -> {dst:?}")]
    OverlapDuplicateEdge {
        src: crate::overlap::overlap::OvlId,
        dst: crate::overlap::overlap::OvlId,
    },
    #[error("Overlap: empty Part({rank}) node (no incoming edges)")]
    OverlapEmptyPart { rank: usize },

    /// Local topology contains a point without ownership metadata.
    #[error("Topology point {point:?} missing ownership metadata")]
    TopologyPointMissingOwnership {
        point: crate::topology::point::PointId,
    },
    /// Ownership metadata references a point missing from the local topology.
    #[error("Ownership entry for point {point:?} missing from local topology")]
    OwnershipPointMissingTopology {
        point: crate::topology::point::PointId,
    },
    /// Ownership ghost flag conflicts with the owning rank.
    #[error("Ownership ghost flag mismatch for point {point:?}: owner={owner}, my_rank={my_rank}")]
    OwnershipGhostMismatch {
        point: crate::topology::point::PointId,
        owner: usize,
        my_rank: usize,
    },
    /// Ghost point is missing a required overlap link to its owning rank.
    #[error("Ghost point {point:?} owned by rank {owner} missing overlap link")]
    GhostPointMissingOverlapLink {
        point: crate::topology::point::PointId,
        owner: usize,
    },
    /// Overlap references a point absent from the local topology.
    #[error("Overlap link references point {point:?} missing from local topology")]
    OverlapPointMissingTopology {
        point: crate::topology::point::PointId,
    },
    /// Overlap references a point missing ownership metadata.
    #[error("Overlap link references point {point:?} missing ownership metadata")]
    OverlapPointMissingOwnership {
        point: crate::topology::point::PointId,
    },

    /// Out edge exists but its mirrored in edge is missing.
    #[error("overlap in/out mirror missing: {src:?} -> {dst:?}")]
    OverlapInOutMirrorMissing {
        src: crate::overlap::overlap::OvlId,
        dst: crate::overlap::overlap::OvlId,
    },

    /// Out/in edges exist but payloads differ (rank/remote_point mismatch).
    #[error("overlap in/out payload mismatch on {src:?} -> {dst:?}: out={out:?} in={inn:?}")]
    OverlapInOutPayloadMismatch {
        src: crate::overlap::overlap::OvlId,
        dst: crate::overlap::overlap::OvlId,
        out: crate::overlap::overlap::Remote,
        inn: crate::overlap::overlap::Remote,
    },

    /// Counts of edges in out vs. in adjacency differ.
    #[error("overlap in/out edge count mismatch: out={out_edges}, in={in_edges}")]
    OverlapInOutEdgeCountMismatch { out_edges: usize, in_edges: usize },

    #[error(
        "Overlap resolution conflict for (local={local}, rank={rank}): existing={existing:?}, new={new:?}"
    )]
    OverlapResolutionConflict {
        local: crate::topology::point::PointId,
        rank: usize,
        existing: Option<crate::topology::point::PointId>,
        new: crate::topology::point::PointId,
    },
}

impl PartialEq for MeshSieveError {
    fn eq(&self, other: &MeshSieveError) -> bool {
        use MeshSieveError::*;
        match (self, other) {
            (InvalidPointId, InvalidPointId)
            | (CycleDetected, CycleDetected)
            | (ZeroLengthSlice, ZeroLengthSlice)
            | (PartitionPointOverflow, PartitionPointOverflow)
            | (GpuMappingFailed, GpuMappingFailed) => true,
            (InvalidGeometry(a), InvalidGeometry(b)) => a == b,
            (DuplicateArrow { src: s1, dst: d1 }, DuplicateArrow { src: s2, dst: d2 }) => {
                s1 == s2 && d1 == d2
            }
            (
                ConeSizeMismatch {
                    cell: c1,
                    cell_type: t1,
                    expected: e1,
                    found: f1,
                },
                ConeSizeMismatch {
                    cell: c2,
                    cell_type: t2,
                    expected: e2,
                    found: f2,
                },
            ) => c1 == c2 && t1 == t2 && e1 == e2 && f1 == f2,
            (
                ClosureVertexCountMismatch {
                    cell: c1,
                    cell_type: t1,
                    expected: e1,
                    found: f1,
                },
                ClosureVertexCountMismatch {
                    cell: c2,
                    cell_type: t2,
                    expected: e2,
                    found: f2,
                },
            ) => c1 == c2 && t1 == t2 && e1 == e2 && f1 == f2,
            (
                NonManifoldIncidentCells {
                    point: p1,
                    dimension: d1,
                    incident_cells: c1,
                },
                NonManifoldIncidentCells {
                    point: p2,
                    dimension: d2,
                    incident_cells: c2,
                },
            ) => p1 == p2 && d1 == d2 && c1 == c2,
            (UnsupportedStackOperation(a), UnsupportedStackOperation(b)) => a == b,
            (
                VectorSectionMismatch {
                    expected: e1,
                    found: f1,
                },
                VectorSectionMismatch {
                    expected: e2,
                    found: f2,
                },
            ) => e1 == e2 && f1 == f2,
            (MissingPointInCone(a), MissingPointInCone(b)) => a == b,
            (UnknownPoint(a), UnknownPoint(b)) => a == b,
            (DuplicatePoint(a), DuplicatePoint(b)) => a == b,
            (MissingAtlasPoint(a), MissingAtlasPoint(b)) => a == b,
            (PointNotInAtlas(a), PointNotInAtlas(b)) => a == b,
            (SievedArrayPointNotInAtlas(a), SievedArrayPointNotInAtlas(b)) => a == b,
            (
                SliceLengthMismatch {
                    point: p1,
                    expected: e1,
                    found: f1,
                },
                SliceLengthMismatch {
                    point: p2,
                    expected: e2,
                    found: f2,
                },
            ) => p1 == p2 && e1 == e2 && f1 == f2,
            (
                AtlasSliceLengthChanged {
                    point: p1,
                    old: o1,
                    new: n1,
                },
                AtlasSliceLengthChanged {
                    point: p2,
                    old: o2,
                    new: n2,
                },
            ) => p1 == p2 && o1 == o2 && n1 == n2,
            (
                AtlasPointLengthChanged {
                    point: p1,
                    expected: e1,
                    found: f1,
                },
                AtlasPointLengthChanged {
                    point: p2,
                    expected: e2,
                    found: f2,
                },
            ) => p1 == p2 && e1 == e2 && f1 == f2,
            (
                SievedArraySliceLengthMismatch {
                    point: p1,
                    expected: e1,
                    found: f1,
                },
                SievedArraySliceLengthMismatch {
                    point: p2,
                    expected: e2,
                    found: f2,
                },
            ) => p1 == p2 && e1 == e2 && f1 == f2,
            (DuplicateRefinementTarget { fine: f1 }, DuplicateRefinementTarget { fine: f2 }) => {
                f1 == f2
            }
            (AtlasInsertionFailed(p1, _), AtlasInsertionFailed(p2, _)) => p1 == p2,
            (MissingSectionPoint(a), MissingSectionPoint(b)) => a == b,
            (
                ScatterLengthMismatch {
                    expected: e1,
                    found: f1,
                },
                ScatterLengthMismatch {
                    expected: e2,
                    found: f2,
                },
            ) => e1 == e2 && f1 == f2,
            (
                ReducerLengthMismatch {
                    expected: e1,
                    found: f1,
                },
                ReducerLengthMismatch {
                    expected: e2,
                    found: f2,
                },
            ) => e1 == e2 && f1 == f2,
            (
                ScatterChunkMismatch {
                    offset: o1,
                    len: l1,
                },
                ScatterChunkMismatch {
                    offset: o2,
                    len: l2,
                },
            ) => o1 == o2 && l1 == l2,
            (
                AtlasContiguityMismatch {
                    point: p1,
                    expected: e1,
                    found: f1,
                },
                AtlasContiguityMismatch {
                    point: p2,
                    expected: e2,
                    found: f2,
                },
            ) => p1 == p2 && e1 == e2 && f1 == f2,
            (
                AtlasPlanStale {
                    expected: e1,
                    found: f1,
                },
                AtlasPlanStale {
                    expected: e2,
                    found: f2,
                },
            ) => e1 == e2 && f1 == f2,
            (MissingSectionName { name: n1 }, MissingSectionName { name: n2 }) => n1 == n2,
            (
                TaggedSectionTypeMismatch {
                    expected: e1,
                    found: f1,
                },
                TaggedSectionTypeMismatch {
                    expected: e2,
                    found: f2,
                },
            ) => e1 == e2 && f1 == f2,
            (MissingOwnership(a), MissingOwnership(b)) => a == b,
            (
                SievedArrayPrimitiveConversionFailure(a),
                SievedArrayPrimitiveConversionFailure(b),
            ) => a == b,
            (
                DeltaLengthMismatch {
                    expected: e1,
                    found: f1,
                },
                DeltaLengthMismatch {
                    expected: e2,
                    found: f2,
                },
            ) => e1 == e2 && f1 == f2,
            (PartitionIndexOutOfBounds(a), PartitionIndexOutOfBounds(b)) => a == b,
            (MissingRecvCount { neighbor: n1 }, MissingRecvCount { neighbor: n2 }) => n1 == n2,
            (SectionAccess { point: p1, .. }, SectionAccess { point: p2, .. }) => p1 == p2,
            (CommError { neighbor: n1, .. }, CommError { neighbor: n2, .. }) => n1 == n2,
            (
                BufferSizeMismatch {
                    neighbor: n1,
                    expected: e1,
                    got: g1,
                },
                BufferSizeMismatch {
                    neighbor: n2,
                    expected: e2,
                    got: g2,
                },
            ) => n1 == n2 && e1 == e2 && g1 == g2,
            (
                PartCountMismatch {
                    neighbor: n1,
                    expected: e1,
                    got: g1,
                },
                PartCountMismatch {
                    neighbor: n2,
                    expected: e2,
                    got: g2,
                },
            ) => n1 == n2 && e1 == e2 && g1 == g2,
            (
                LengthsCountMismatch {
                    neighbor: n1,
                    expected: e1,
                    got: g1,
                },
                LengthsCountMismatch {
                    neighbor: n2,
                    expected: e2,
                    got: g2,
                },
            ) => n1 == n2 && e1 == e2 && g1 == g2,
            (
                PayloadCountMismatch {
                    neighbor: n1,
                    expected: e1,
                    got: g1,
                },
                PayloadCountMismatch {
                    neighbor: n2,
                    expected: e2,
                    got: g2,
                },
            ) => n1 == n2 && e1 == e2 && g1 == g2,
            (Communication(a), Communication(b)) => a == b,
            (OverlapLinkMissing(a1, b1), OverlapLinkMissing(a2, b2)) => a1 == a2 && b1 == b2,
            (
                OverlapNonBipartite { src: s1, dst: d1 },
                OverlapNonBipartite { src: s2, dst: d2 },
            ) => s1 == s2 && d1 == d2,
            (OverlapExpectedLocal { found: f1 }, OverlapExpectedLocal { found: f2 }) => f1 == f2,
            (OverlapExpectedPart { found: f1 }, OverlapExpectedPart { found: f2 }) => f1 == f2,
            (
                OverlapRankMismatch {
                    expected: e1,
                    found: f1,
                },
                OverlapRankMismatch {
                    expected: e2,
                    found: f2,
                },
            ) => e1 == e2 && f1 == f2,
            (OverlapPartInBasePoints, OverlapPartInBasePoints) => true,
            (OverlapLocalInCapPoints, OverlapLocalInCapPoints) => true,
            (
                OverlapDuplicateEdge { src: s1, dst: d1 },
                OverlapDuplicateEdge { src: s2, dst: d2 },
            ) => s1 == s2 && d1 == d2,
            (OverlapEmptyPart { rank: r1 }, OverlapEmptyPart { rank: r2 }) => r1 == r2,
            (
                TopologyPointMissingOwnership { point: p1 },
                TopologyPointMissingOwnership { point: p2 },
            ) => p1 == p2,
            (
                OwnershipPointMissingTopology { point: p1 },
                OwnershipPointMissingTopology { point: p2 },
            ) => p1 == p2,
            (
                OwnershipGhostMismatch {
                    point: p1,
                    owner: o1,
                    my_rank: m1,
                },
                OwnershipGhostMismatch {
                    point: p2,
                    owner: o2,
                    my_rank: m2,
                },
            ) => p1 == p2 && o1 == o2 && m1 == m2,
            (
                GhostPointMissingOverlapLink {
                    point: p1,
                    owner: o1,
                },
                GhostPointMissingOverlapLink {
                    point: p2,
                    owner: o2,
                },
            ) => p1 == p2 && o1 == o2,
            (
                OverlapPointMissingTopology { point: p1 },
                OverlapPointMissingTopology { point: p2 },
            ) => p1 == p2,
            (
                OverlapPointMissingOwnership { point: p1 },
                OverlapPointMissingOwnership { point: p2 },
            ) => p1 == p2,
            (
                OverlapInOutMirrorMissing { src: s1, dst: d1 },
                OverlapInOutMirrorMissing { src: s2, dst: d2 },
            ) => s1 == s2 && d1 == d2,
            (
                OverlapInOutPayloadMismatch {
                    src: s1,
                    dst: d1,
                    out: o1,
                    inn: i1,
                },
                OverlapInOutPayloadMismatch {
                    src: s2,
                    dst: d2,
                    out: o2,
                    inn: i2,
                },
            ) => s1 == s2 && d1 == d2 && o1 == o2 && i1 == i2,
            (
                OverlapInOutEdgeCountMismatch {
                    out_edges: o1,
                    in_edges: i1,
                },
                OverlapInOutEdgeCountMismatch {
                    out_edges: o2,
                    in_edges: i2,
                },
            ) => o1 == o2 && i1 == i2,
            (
                OverlapResolutionConflict {
                    local: l1,
                    rank: r1,
                    existing: ex1,
                    new: n1,
                },
                OverlapResolutionConflict {
                    local: l2,
                    rank: r2,
                    existing: ex2,
                    new: n2,
                },
            ) => l1 == l2 && r1 == r2 && ex1 == ex2 && n1 == n2,
            _ => false,
        }
    }
}
impl Eq for MeshSieveError {}

/// Low-level communicator failure.
#[derive(Debug, thiserror::Error, Clone)]
#[error("{0}")]
pub struct CommError(pub String);

impl PartialEq for CommError {
    fn eq(&self, other: &CommError) -> bool {
        self.0 == other.0
    }
}
impl Eq for CommError {}