Commit 24a488e authored Jan 26, 2025 · 7 / 7 · Verified
1 parent 482daf1 commit 24a488e Copy full SHA for 24a488e
File tree 3 files changed +32
-1
lines changed
3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use ndgrid::{
10
10
} ;
11
11
12
12
fn main ( ) {
13
- let n = 8 ;
13
+ let n = 100 ;
14
14
15
15
let mut b = SingleElementGridBuilder :: < f64 > :: new ( 2 , ( ReferenceCellType :: Quadrilateral , 1 ) ) ;
16
16
@@ -40,6 +40,28 @@ fn main() {
40
40
b. create_parallel_grid ( & comm, 0 )
41
41
} ;
42
42
43
+ // Check that owned cells are sorted ahead of ghost cells
44
+
45
+ let cell_count_owned = grid
46
+ . local_grid ( )
47
+ . cell_iter ( )
48
+ . filter ( |entity| entity. is_owned ( ) )
49
+ . count ( ) ;
50
+
51
+ // Now check that the first `cell_count_owned` entities are actually owned.
52
+ for cell in grid. local_grid ( ) . cell_iter ( ) . take ( cell_count_owned) {
53
+ assert ! ( cell. is_owned( ) )
54
+ }
55
+
56
+ // Now make sure that the indices of the global cells are in consecutive order
57
+
58
+ let mut cell_global_count = grid. cell_layout ( ) . local_range ( ) . 0 ;
59
+
60
+ for cell in grid. local_grid ( ) . cell_iter ( ) . take ( cell_count_owned) {
61
+ assert_eq ! ( cell. global_index( ) , cell_global_count) ;
62
+ cell_global_count += 1 ;
63
+ }
64
+
43
65
// Get the global indices.
44
66
45
67
let global_vertices = grid
Original file line number Diff line number Diff line change @@ -40,6 +40,11 @@ pub trait Entity {
40
40
/// The ownership of this entity
41
41
fn ownership ( & self ) -> Ownership ;
42
42
43
+ /// Return true if the entity is owned
44
+ fn is_owned ( & self ) -> bool {
45
+ matches ! ( self . ownership( ) , Ownership :: Owned )
46
+ }
47
+
43
48
/// The insertion id of this entity
44
49
fn id ( & self ) -> Option < usize > ;
45
50
}
Original file line number Diff line number Diff line change @@ -71,6 +71,10 @@ pub trait Grid {
71
71
fn entity_from_id ( & self , dim : usize , id : usize ) -> Option < Self :: Entity < ' _ > > ;
72
72
73
73
/// Iterator over all cells
74
+ ///
75
+ /// This iterator first iterates through owned cells
76
+ /// and then through ghosts. The owned cells are sorted
77
+ /// by global index.
74
78
fn cell_iter ( & self ) -> Self :: EntityIter < ' _ > {
75
79
let tdim = self . topology_dim ( ) ;
76
80
self . entity_iter ( tdim)
You can’t perform that action at this time.
0 commit comments