@@ -118,7 +118,7 @@ dolfinx_mpc::mpc_data<T> compute_master_contributions(
118
118
std::vector<std::int64_t > global_blocks;
119
119
120
120
// Reuse num_masters_local for insertion
121
- std::fill (num_masters_local. begin (), num_masters_local. end () , 0 );
121
+ std::ranges:: fill (num_masters_local, 0 );
122
122
for (std::size_t i = 0 ; i < num_slaves_local; ++i)
123
123
{
124
124
if (const std::int32_t cell = local_colliding_cell[i]; cell != -1 )
@@ -241,7 +241,7 @@ dolfinx_mpc::mpc_data<T> compute_block_contributions(
241
241
masters_offsets.begin () + 1 );
242
242
243
243
// Reuse num masters as fill position array
244
- std::fill (num_masters_in_cell. begin (), num_masters_in_cell. end () , 0 );
244
+ std::ranges:: fill (num_masters_in_cell, 0 );
245
245
246
246
// Compute coeffs and owners for local cells
247
247
std::vector<std::int64_t > global_slave_blocks (local_slaves.size ());
@@ -308,7 +308,7 @@ dolfinx_mpc::mpc_data<T> concatenate(dolfinx_mpc::mpc_data<T>& mpc0,
308
308
num_masters_per_slave.end (), masters_offsets.begin () + 1 );
309
309
310
310
// Reuse num_masters_per_slave for indexing
311
- std::fill (num_masters_per_slave. begin (), num_masters_per_slave. end () , 0 );
311
+ std::ranges:: fill (num_masters_per_slave, 0 );
312
312
std::vector<std::int64_t > masters_out (masters_offsets.back ());
313
313
std::vector<T> coefficients_out (masters_offsets.back ());
314
314
std::vector<std::int32_t > owners_out (masters_offsets.back ());
@@ -389,14 +389,14 @@ mpc_data<T> create_contact_slip_condition(
389
389
= impl::locate_slave_dofs<U>(V, meshtags, slave_marker);
390
390
391
391
local_slave_blocks.reserve (slave_dofs.size ());
392
- std::for_each (slave_dofs. begin (), slave_dofs. end () ,
393
- [&local_slave_blocks, bs = block_size,
394
- sl = size_local](const std::int32_t dof)
395
- {
396
- std::div_t div = std::div (dof, bs);
397
- if (div .quot < sl)
398
- local_slave_blocks.push_back (div .quot );
399
- });
392
+ std::ranges:: for_each (slave_dofs,
393
+ [&local_slave_blocks, bs = block_size,
394
+ sl = size_local](const std::int32_t dof)
395
+ {
396
+ std::div_t div = std::div (dof, bs);
397
+ if (div .quot < sl)
398
+ local_slave_blocks.push_back (div .quot );
399
+ });
400
400
}
401
401
402
402
// Data structures to hold information about slave data local to process
@@ -424,12 +424,12 @@ mpc_data<T> create_contact_slip_condition(
424
424
normal [j] = std::real (normal_array[dofs[j]]);
425
425
U norm = std::sqrt (normal [0 ] * normal [0 ] + normal [1 ] * normal [1 ]
426
426
+ normal [2 ] * normal [2 ]);
427
- std::for_each (normal . begin (), normal . end () ,
428
- [norm](auto & n) { return std::abs (n / norm); });
427
+ std::ranges:: for_each (normal ,
428
+ [norm](auto & n) { return std::abs (n / norm); });
429
429
return std::distance (
430
430
normal .begin (),
431
- std::max_element (normal . begin (), normal . end (),
432
- [](T a, T b) { return std::norm (a) < std::norm (b); }));
431
+ std::ranges:: max_element (normal , [](T a, T b)
432
+ { return std::norm (a) < std::norm (b); }));
433
433
};
434
434
435
435
// Determine which dof in local slave block is the actual slave
@@ -532,10 +532,10 @@ mpc_data<T> create_contact_slip_condition(
532
532
{
533
533
const std::int32_t slave_idx = slave_indices_remote[i];
534
534
send_rems[i] = local_rems[slave_idx];
535
- std::copy_n (std::next (slave_coordinates.begin (), 3 * slave_idx), 3 ,
536
- std::next (coordinates_send.begin (), 3 * i));
537
- std::copy_n (std::next (normals.begin (), 3 * slave_idx), 3 ,
538
- std::next (normals_send.begin (), 3 * i));
535
+ std::ranges:: copy_n (std::next (slave_coordinates.begin (), 3 * slave_idx), 3 ,
536
+ std::next (coordinates_send.begin (), 3 * i));
537
+ std::ranges:: copy_n (std::next (normals.begin (), 3 * slave_idx), 3 ,
538
+ std::next (normals_send.begin (), 3 * i));
539
539
}
540
540
541
541
// Figure out how much data to receive from each neighbor
@@ -564,9 +564,9 @@ mpc_data<T> create_contact_slip_condition(
564
564
// function data
565
565
std::vector<std::int32_t > num_slaves_recv3;
566
566
num_slaves_recv3.reserve (indegree);
567
- std::transform (num_slaves_recv. begin (), num_slaves_recv. end ( ),
568
- std::back_inserter (num_slaves_recv3),
569
- [](std:: int32_t num_slaves) { return 3 * num_slaves; });
567
+ std::ranges:: transform (num_slaves_recv, std::back_inserter (num_slaves_recv3 ),
568
+ []( std::int32_t num_slaves)
569
+ { return 3 * num_slaves; });
570
570
std::vector<int > disp3 (indegree + 1 , 0 );
571
571
std::partial_sum (num_slaves_recv3.begin (), num_slaves_recv3.end (),
572
572
disp3.begin () + 1 );
@@ -612,9 +612,9 @@ mpc_data<T> create_contact_slip_condition(
612
612
std::vector<std::int32_t > num_collision_masters (indegree + 1 , 0 );
613
613
std::vector<int > num_out_offsets;
614
614
num_out_offsets.reserve (indegree);
615
- std::transform (num_slaves_recv. begin (), num_slaves_recv. end ( ),
616
- std::back_inserter (num_out_offsets),
617
- [](std:: int32_t num_slaves) { return num_slaves + 1 ; });
615
+ std::ranges:: transform (num_slaves_recv, std::back_inserter (num_out_offsets ),
616
+ []( std::int32_t num_slaves)
617
+ { return num_slaves + 1 ; });
618
618
const std::int32_t num_offsets
619
619
= std::accumulate (num_out_offsets.begin (), num_out_offsets.end (), 0 );
620
620
std::vector<std::int32_t > offsets_remote (num_offsets);
@@ -698,7 +698,7 @@ mpc_data<T> create_contact_slip_condition(
698
698
std::vector<MPI_Status> status (4 );
699
699
MPI_Wait (&requests[0 ], &status[0 ]);
700
700
701
- std::vector<bool > slave_found (slave_indices_remote.size (), false );
701
+ std::vector<std:: int8_t > slave_found (slave_indices_remote.size (), false );
702
702
std::vector<std::int32_t > num_inc_masters (slave_indices_remote.size ());
703
703
// Iterate through the processors and find one set of inputs per slave that
704
704
// was sent to the other processes
@@ -744,7 +744,7 @@ mpc_data<T> create_contact_slip_condition(
744
744
std::vector<T> offproc_coeffs (offproc_offsets.back ());
745
745
std::vector<std::int32_t > offproc_owners (offproc_offsets.back ());
746
746
747
- std::fill (slave_found. begin (), slave_found. end () , false );
747
+ std::ranges:: fill (slave_found, false );
748
748
for (std::size_t i = 0 ; i < src_ranks_rev.size (); ++i)
749
749
{
750
750
const std::int32_t proc_start = disp_inc_masters[i];
@@ -919,8 +919,8 @@ mpc_data<T> create_contact_inelastic_condition(
919
919
920
920
std::vector<std::int32_t > slave_blocks
921
921
= impl::locate_slave_dofs<U>(V, meshtags, slave_marker);
922
- std::for_each (slave_blocks. begin (), slave_blocks. end () ,
923
- [block_size](std::int32_t & d) { d /= block_size; });
922
+ std::ranges:: for_each (slave_blocks,
923
+ [block_size](std::int32_t & d) { d /= block_size; });
924
924
925
925
// Vector holding what blocks local to process are slaves
926
926
std::vector<std::int32_t > local_blocks;
@@ -930,8 +930,8 @@ mpc_data<T> create_contact_inelastic_condition(
930
930
std::vector<std::int32_t > ghost_blocks;
931
931
932
932
// Map slave blocks to arrays holding local bocks and ghost blocks
933
- std::for_each (
934
- slave_blocks. begin (), slave_blocks. end () ,
933
+ std::ranges:: for_each (
934
+ slave_blocks,
935
935
[size_local, &local_blocks, &ghost_blocks](const std::int32_t block)
936
936
{
937
937
if (block < size_local)
@@ -1069,8 +1069,9 @@ mpc_data<T> create_contact_inelastic_condition(
1069
1069
std::vector<U> distribute_coordinates (blocks_wo_local_collision.size () * 3 );
1070
1070
for (std::size_t i = 0 ; i < collision_to_local.size (); ++i)
1071
1071
{
1072
- std::copy_n (std::next (slave_coordinates.begin (), 3 * collision_to_local[i]),
1073
- 3 , std::next (distribute_coordinates.begin (), 3 * i));
1072
+ std::ranges::copy_n (
1073
+ std::next (slave_coordinates.begin (), 3 * collision_to_local[i]), 3 ,
1074
+ std::next (distribute_coordinates.begin (), 3 * i));
1074
1075
}
1075
1076
dolfinx_mpc::mpc_data<T> mpc;
1076
1077
@@ -1096,8 +1097,8 @@ mpc_data<T> create_contact_inelastic_condition(
1096
1097
// slaves)
1097
1098
std::vector<std::int32_t > slaves;
1098
1099
slaves.reserve (block_size * local_blocks.size ());
1099
- std::for_each (
1100
- local_blocks. begin (), local_blocks. end () ,
1100
+ std::ranges:: for_each (
1101
+ local_blocks,
1101
1102
[block_size, tdim, &masters_out, &local_masters, &coeffs_out,
1102
1103
&local_coeffs, &offsets_out, &slaves](const std::int32_t block)
1103
1104
{
@@ -1113,7 +1114,7 @@ mpc_data<T> create_contact_inelastic_condition(
1113
1114
}
1114
1115
});
1115
1116
std::vector<std::int32_t > owners (masters_out.size ());
1116
- std::fill (owners. begin (), owners. end () , 0 );
1117
+ std::ranges:: fill (owners, 0 );
1117
1118
mpc.slaves = slaves;
1118
1119
mpc.masters = masters_out;
1119
1120
mpc.offsets = offsets_out;
@@ -1478,17 +1479,18 @@ mpc_data<T> create_contact_inelastic_condition(
1478
1479
1479
1480
// Count number of incoming slaves
1480
1481
std::vector<std::int32_t > inc_num_slaves (src_ranks_ghost.size (), 0 );
1481
- std::for_each (ghost_slaves.begin (), ghost_slaves.end (),
1482
- [block_size, size_local, &ghost_owners, &inc_num_slaves,
1483
- &src_ranks_ghost](std::int32_t slave)
1484
- {
1485
- const std::int32_t owner
1486
- = ghost_owners[slave / block_size - size_local];
1487
- const auto it = std::find (src_ranks_ghost.begin (),
1488
- src_ranks_ghost.end (), owner);
1489
- const auto index = std::distance (src_ranks_ghost.begin (), it);
1490
- inc_num_slaves[index ]++;
1491
- });
1482
+ std::ranges::for_each (
1483
+ ghost_slaves,
1484
+ [block_size, size_local, &ghost_owners, &inc_num_slaves,
1485
+ &src_ranks_ghost](std::int32_t slave)
1486
+ {
1487
+ const std::int32_t owner
1488
+ = ghost_owners[slave / block_size - size_local];
1489
+ const auto it
1490
+ = std::find (src_ranks_ghost.begin (), src_ranks_ghost.end (), owner);
1491
+ const auto index = std::distance (src_ranks_ghost.begin (), it);
1492
+ inc_num_slaves[index ]++;
1493
+ });
1492
1494
// Count number of outgoing slaves and masters
1493
1495
dolfinx::graph::AdjacencyList<int > shared_indices
1494
1496
= slave_index_map->index_to_dest_ranks ();
@@ -1505,8 +1507,8 @@ mpc_data<T> create_contact_inelastic_condition(
1505
1507
std::vector<std::int32_t > loc_block (1 );
1506
1508
std::vector<std::int64_t > glob_block (1 );
1507
1509
1508
- std::for_each (
1509
- local_blocks. begin (), local_blocks. end () ,
1510
+ std::ranges:: for_each (
1511
+ local_blocks,
1510
1512
[block_size, &local_masters, &local_coeffs, &local_owners,
1511
1513
&shared_indices, &dest_ranks_ghost, &loc_block, &glob_block,
1512
1514
&out_num_masters, &out_num_slaves, &imap, &proc_to_ghost,
@@ -1663,8 +1665,8 @@ mpc_data<T> create_contact_inelastic_condition(
1663
1665
std::vector<std::int32_t > offsets = {0 };
1664
1666
offsets.reserve (slaves.size () + 1 );
1665
1667
1666
- std::for_each (
1667
- local_blocks. begin (), local_blocks. end () ,
1668
+ std::ranges:: for_each (
1669
+ local_blocks,
1668
1670
[block_size, tdim, &masters, &local_masters, &coeffs_out, &local_coeffs,
1669
1671
&owners_out, &local_owners, &offsets, &slaves](const std::int32_t block)
1670
1672
{
0 commit comments