@@ -452,18 +452,7 @@ where
452
452
}
453
453
}
454
454
455
- // We want to get the counts of how much data there is for each process and then
456
- // convert the various `ghost_..` vec of vecs into flat buffers that can be communicated.
457
-
458
- let counts = ghost_indices. iter ( ) . map ( |dofs| dofs. len ( ) ) . collect_vec ( ) ;
459
-
460
- // We have the counts. Let's now flatten the ghost arrays.
461
-
462
- let ghost_indices = ghost_indices. into_iter ( ) . flatten ( ) . collect_vec ( ) ;
463
- let ghost_dims = ghost_dims. into_iter ( ) . flatten ( ) . collect_vec ( ) ;
464
- let ghost_entities = ghost_entities. into_iter ( ) . flatten ( ) . collect_vec ( ) ;
465
- let ghost_entity_dofs = ghost_entity_dofs. into_iter ( ) . flatten ( ) . collect_vec ( ) ;
466
-
455
+ // This is to make sure that `dof_n` agrees with the sum of the offset and number of owned dofs
467
456
assert_eq ! ( dof_n, local_offset + number_of_owned_dofs) ;
468
457
469
458
// We now communicate the global size back to all processes. The global size is the `dof_n` value
@@ -480,51 +469,68 @@ where
480
469
tmp
481
470
} ;
482
471
483
- // We now need to communicate all the data about ghosts across processes.
484
- // Each process needs to send to all other processes the ghost dofs it has from them.
485
- // We only need to get the `receive_count` once since it is identical for all calls.
472
+ // Everything below is only necessary if there is more than one process. Otherwise,
473
+ // ownership and `global_dof_numbers` are already correctly filled.
486
474
487
- let ( receive_count , received_ghost_dims ) = all_to_allv ( comm , & counts , & ghost_dims ) ;
488
- let ( _ , received_ghost_entities ) = all_to_allv ( comm , & counts, & ghost_entities ) ;
489
- let ( _ , received_ghost_entity_dofs ) = all_to_allv ( comm , & counts , & ghost_entity_dofs ) ;
475
+ if comm . size ( ) > 1 {
476
+ // We want to get the counts of how much data there is for each process and then
477
+ // convert the various `ghost_..` vec of vecs into flat buffers that can be communicated.
490
478
491
- // Each process has now received from all other processes the ghost elements that they have from them.
492
- // We now need to look up the actual entity dof numbers and send those back.
493
- // First store the entity dof numbers.
479
+ let counts = ghost_indices. iter ( ) . map ( |dofs| dofs. len ( ) ) . collect_vec ( ) ;
494
480
495
- let ( ghost_global_dofs, ghost_local_dofs) = {
496
- let mut ghost_global_dofs_to_send =
497
- Vec :: < usize > :: with_capacity ( receive_count. iter ( ) . sum ( ) ) ;
498
- let mut ghost_local_dofs_to_send =
499
- Vec :: < usize > :: with_capacity ( receive_count. iter ( ) . sum ( ) ) ;
481
+ // We have the counts. Let's now flatten the ghost arrays.
500
482
501
- for ( dim, entity, entity_dof) in izip ! (
502
- received_ghost_dims,
503
- received_ghost_entities,
504
- received_ghost_entity_dofs
505
- ) {
506
- let local_index = entity_dofs[ dim] [ entity] [ entity_dof] ;
507
- ghost_global_dofs_to_send. push ( global_dof_numbers[ local_index] ) ;
508
- ghost_local_dofs_to_send. push ( local_index) ;
509
- }
483
+ let ghost_indices = ghost_indices. into_iter ( ) . flatten ( ) . collect_vec ( ) ;
484
+ let ghost_dims = ghost_dims. into_iter ( ) . flatten ( ) . collect_vec ( ) ;
485
+ let ghost_entities = ghost_entities. into_iter ( ) . flatten ( ) . collect_vec ( ) ;
486
+ let ghost_entity_dofs = ghost_entity_dofs. into_iter ( ) . flatten ( ) . collect_vec ( ) ;
510
487
511
- (
512
- // Have a .1 at the end of both since we only want the data and not the counts
513
- all_to_allv ( comm, & receive_count, & ghost_global_dofs_to_send) . 1 ,
514
- all_to_allv ( comm, & receive_count, & ghost_local_dofs_to_send) . 1 ,
515
- )
516
- } ;
488
+ // We now need to communicate all the data about ghosts across processes.
489
+ // Each process needs to send to all other processes the ghost dofs it has from them.
490
+ // We only need to get the `receive_count` once since it is identical for all calls.
517
491
518
- // We have the global dofs of the ghosts now. We can finalise setting up the `ownership` and `ghobal_dof_numbers` arrays.
492
+ let ( receive_count, received_ghost_dims) = all_to_allv ( comm, & counts, & ghost_dims) ;
493
+ let ( _, received_ghost_entities) = all_to_allv ( comm, & counts, & ghost_entities) ;
494
+ let ( _, received_ghost_entity_dofs) = all_to_allv ( comm, & counts, & ghost_entity_dofs) ;
519
495
520
- for ( & index, & ghost_rank, & ghost_global_dof, & ghost_local_dof) in izip ! (
521
- ghost_indices. iter( ) ,
522
- ghost_ranks. iter( ) ,
523
- ghost_global_dofs. iter( ) ,
524
- ghost_local_dofs. iter( )
525
- ) {
526
- global_dof_numbers[ index] = ghost_global_dof;
527
- ownership[ index] = Ownership :: Ghost ( ghost_rank, ghost_local_dof) ;
496
+ // Each process has now received from all other processes the ghost elements that they have from them.
497
+ // We now need to look up the actual entity dof numbers and send those back.
498
+ // First store the entity dof numbers.
499
+
500
+ let ( ghost_global_dofs, ghost_local_dofs) = {
501
+ let mut ghost_global_dofs_to_send =
502
+ Vec :: < usize > :: with_capacity ( receive_count. iter ( ) . sum ( ) ) ;
503
+ let mut ghost_local_dofs_to_send =
504
+ Vec :: < usize > :: with_capacity ( receive_count. iter ( ) . sum ( ) ) ;
505
+
506
+ for ( dim, entity, entity_dof) in izip ! (
507
+ received_ghost_dims,
508
+ received_ghost_entities,
509
+ received_ghost_entity_dofs
510
+ ) {
511
+ let local_index = entity_dofs[ dim] [ entity] [ entity_dof] ;
512
+ ghost_global_dofs_to_send. push ( global_dof_numbers[ local_index] ) ;
513
+ ghost_local_dofs_to_send. push ( local_index) ;
514
+ }
515
+
516
+ (
517
+ // Have a .1 at the end of both since we only want the data and not the counts
518
+ all_to_allv ( comm, & receive_count, & ghost_global_dofs_to_send) . 1 ,
519
+ all_to_allv ( comm, & receive_count, & ghost_local_dofs_to_send) . 1 ,
520
+ )
521
+ } ;
522
+
523
+ // We have the global dofs of the ghosts now. We can finalise setting up the `ownership` and `ghobal_dof_numbers` arrays.
524
+
525
+ for ( & index, & ghost_rank, & ghost_global_dof, & ghost_local_dof) in izip ! (
526
+ ghost_indices. iter( ) ,
527
+ ghost_ranks. iter( ) ,
528
+ ghost_global_dofs. iter( ) ,
529
+ ghost_local_dofs. iter( )
530
+ ) {
531
+ global_dof_numbers[ index] = ghost_global_dof;
532
+ ownership[ index] = Ownership :: Ghost ( ghost_rank, ghost_local_dof) ;
533
+ }
528
534
}
529
535
530
536
Self {
0 commit comments