From 391444ed6e4f9ccbaa20c35a26e5f9f2f191a726 Mon Sep 17 00:00:00 2001 From: Sam Reeve <6740307+streeve@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:29:56 -0500 Subject: [PATCH] Clarify offset vs number of each type of particles --- examples/mechanics/fragmenting_cylinder.cpp | 2 +- src/CabanaPD_BodyTerm.hpp | 4 +- src/CabanaPD_Boundary.hpp | 4 +- src/CabanaPD_Comm.hpp | 6 +- src/CabanaPD_DisplacementProfile.hpp | 3 +- src/CabanaPD_Force.hpp | 4 + src/CabanaPD_HeatTransfer.hpp | 8 +- src/CabanaPD_Integrate.hpp | 6 +- src/CabanaPD_Particles.hpp | 118 ++++++++++---------- src/CabanaPD_Prenotch.hpp | 3 +- src/CabanaPD_Solver.hpp | 3 +- src/force/CabanaPD_Force_Contact.hpp | 4 +- src/force/CabanaPD_Force_LPS.hpp | 40 +++---- src/force/CabanaPD_Force_PMB.hpp | 24 ++-- unit_test/tstComm.hpp | 20 ++-- 15 files changed, 126 insertions(+), 123 deletions(-) diff --git a/examples/mechanics/fragmenting_cylinder.cpp b/examples/mechanics/fragmenting_cylinder.cpp index 94dfaa28..dfd270e1 100644 --- a/examples/mechanics/fragmenting_cylinder.cpp +++ b/examples/mechanics/fragmenting_cylinder.cpp @@ -110,7 +110,7 @@ void fragmentingCylinderExample( const std::string filename ) using random_type = Kokkos::Random_XorShift64; pool_type pool; int seed = 456854; - pool.init( seed, particles->n_local ); + pool.init( seed, particles->localOffset() ); auto init_functor = KOKKOS_LAMBDA( const int pid ) { // Density diff --git a/src/CabanaPD_BodyTerm.hpp b/src/CabanaPD_BodyTerm.hpp index f2844775..3af7ff62 100644 --- a/src/CabanaPD_BodyTerm.hpp +++ b/src/CabanaPD_BodyTerm.hpp @@ -41,8 +41,8 @@ struct BodyTerm void apply( ExecSpace, ParticleType& particles, const double time ) { _timer.start(); - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); auto user = _user_functor; Kokkos::parallel_for( "CabanaPD::BodyTerm::apply", policy, diff --git a/src/CabanaPD_Boundary.hpp b/src/CabanaPD_Boundary.hpp index 3d0c4638..6ab5cf03 100644 --- a/src/CabanaPD_Boundary.hpp +++ b/src/CabanaPD_Boundary.hpp @@ -140,7 +140,7 @@ struct BoundaryIndexSpace> _timer.start(); _view = index_view_type( "boundary_indices", - particles.numLocal() * initial_guess ); + particles.localOffset() * initial_guess ); _count = index_view_type( "count", 1 ); for ( RegionBoundary plane : planes ) @@ -169,7 +169,7 @@ struct BoundaryIndexSpace> auto index_space = _view; auto count = _count; auto x = particles.sliceReferencePosition(); - Kokkos::RangePolicy policy( 0, particles.numLocal() ); + Kokkos::RangePolicy policy( 0, particles.localOffset() ); auto index_functor = KOKKOS_LAMBDA( const std::size_t pid ) { if ( region.inside( x, pid ) ) diff --git a/src/CabanaPD_Comm.hpp b/src/CabanaPD_Comm.hpp index c51eb85d..1a7269f0 100644 --- a/src/CabanaPD_Comm.hpp +++ b/src/CabanaPD_Comm.hpp @@ -270,9 +270,9 @@ class Comm halo_ids.rebuild( positions ); // Create the Cabana Halo. - halo = std::make_shared( local_grid->globalGrid().comm(), - particles.numLocal(), halo_ids._ids, - halo_ids._destinations, topology ); + halo = std::make_shared( + local_grid->globalGrid().comm(), particles.localOffset(), + halo_ids._ids, halo_ids._destinations, topology ); particles.resize( halo->numLocal(), halo->numGhost() ); diff --git a/src/CabanaPD_DisplacementProfile.hpp b/src/CabanaPD_DisplacementProfile.hpp index 0339f77a..0c9ecb6b 100644 --- a/src/CabanaPD_DisplacementProfile.hpp +++ b/src/CabanaPD_DisplacementProfile.hpp @@ -56,8 +56,9 @@ void createOutputProfile( MPI_Comm comm, const int num_cell, profile( c, 1 ) = user( pid ); } }; + // TODO: enable ignoring frozen particles. Kokkos::RangePolicy policy( - 0, particles.numLocal() ); + 0, particles.localOffset() ); Kokkos::parallel_for( "displacement_profile", policy, measure_profile ); auto count_host = Kokkos::create_mirror_view_and_copy( Kokkos::HostSpace{}, count ); diff --git a/src/CabanaPD_Force.hpp b/src/CabanaPD_Force.hpp index b8b3085f..7fc958d3 100644 --- a/src/CabanaPD_Force.hpp +++ b/src/CabanaPD_Force.hpp @@ -149,6 +149,8 @@ class Force Force( const bool half_neigh, const double delta, const ParticleType& particles, const double tol = 1e-14 ) : _half_neigh( half_neigh ) + // Note: this construction must always include frozen particles as + // potential neighbors, so we start at zero. , _neigh_list( neighbor_list_type( particles.sliceReferencePosition(), 0, particles.numLocal(), delta + tol, 1.0, particles.ghost_mesh_lo, @@ -164,6 +166,8 @@ class Force const double mesh_min[3], const double mesh_max[3], const double tol = 1e-14 ) : _half_neigh( half_neigh ) + // Note: this construction must always include frozen particles as + // potential neighbors, so we start at zero. , _neigh_list( neighbor_list_type( positions, 0, num_local, delta + tol, 1.0, mesh_min, mesh_max ) ) { diff --git a/src/CabanaPD_HeatTransfer.hpp b/src/CabanaPD_HeatTransfer.hpp index e678ae9d..9b1e7ad9 100644 --- a/src/CabanaPD_HeatTransfer.hpp +++ b/src/CabanaPD_HeatTransfer.hpp @@ -70,8 +70,8 @@ class HeatTransfer : public Force coeff * ( temp( j ) - temp( i ) ) / xi / xi * vol( j ); }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_for( policy, temp_func, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::HeatTransfer::computeFull" ); @@ -91,8 +91,8 @@ class HeatTransfer : public Force { temp( i ) += dt / rho( i ) / model.cp * conduction( i ); }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Kokkos::parallel_for( "CabanaPD::HeatTransfer::forwardEuler", policy, euler_func ); _euler_timer.stop(); diff --git a/src/CabanaPD_Integrate.hpp b/src/CabanaPD_Integrate.hpp index 44abd3ee..a0190878 100644 --- a/src/CabanaPD_Integrate.hpp +++ b/src/CabanaPD_Integrate.hpp @@ -106,7 +106,8 @@ class Integrator u( i, 1 ) += dt * v( i, 1 ); u( i, 2 ) += dt * v( i, 2 ); }; - Kokkos::RangePolicy policy( p.numFrozen(), p.numLocal() ); + Kokkos::RangePolicy policy( p.frozenOffset(), + p.localOffset() ); Kokkos::parallel_for( "CabanaPD::Integrator::Initial", policy, init_func ); @@ -130,7 +131,8 @@ class Integrator v( i, 1 ) += half_dt_m * f( i, 1 ); v( i, 2 ) += half_dt_m * f( i, 2 ); }; - Kokkos::RangePolicy policy( p.numFrozen(), p.numLocal() ); + Kokkos::RangePolicy policy( p.frozenOffset(), + p.localOffset() ); Kokkos::parallel_for( "CabanaPD::Integrator::Final", policy, final_func ); diff --git a/src/CabanaPD_Particles.hpp b/src/CabanaPD_Particles.hpp index 1c105c81..7f83025f 100644 --- a/src/CabanaPD_Particles.hpp +++ b/src/CabanaPD_Particles.hpp @@ -95,10 +95,10 @@ class Particles static constexpr int dim = Dimension; // Per particle. - unsigned long long int n_global = 0; - std::size_t n_local = 0; - std::size_t n_frozen = 0; - std::size_t n_ghost = 0; + unsigned long long int num_global = 0; + std::size_t frozen_offset = 0; + std::size_t local_offset = 0; + std::size_t num_ghost = 0; std::size_t size = 0; // x, u, f (vector matching system dimension). @@ -239,7 +239,7 @@ class Particles { return true; }; - createParticles( exec_space, empty ); + createParticles( exec_space, empty, create_frozen ); } template @@ -297,20 +297,21 @@ class Particles return create; }; - n_local = Cabana::Grid::createParticles( Cabana::InitUniform{}, - exec_space, create_functor, - _plist_x, 1, *local_grid ); - resize( n_local, 0 ); + local_offset = Cabana::Grid::createParticles( + Cabana::InitUniform{}, exec_space, create_functor, _plist_x, 1, + *local_grid ); + resize( local_offset, 0 ); size = _plist_x.size(); // Only set this value if this generation of particles should be frozen. if ( create_frozen ) - n_frozen = size; + frozen_offset = size; // Not using Allreduce because global count is only used for printing. - auto n_local_mpi = static_cast( n_local ); - MPI_Reduce( &n_local_mpi, &n_global, 1, MPI_UNSIGNED_LONG_LONG, MPI_SUM, - 0, MPI_COMM_WORLD ); + auto local_offset_mpi = + static_cast( local_offset ); + MPI_Reduce( &local_offset_mpi, &num_global, 1, MPI_UNSIGNED_LONG_LONG, + MPI_SUM, 0, MPI_COMM_WORLD ); _init_timer.stop(); } @@ -318,18 +319,22 @@ class Particles void updateParticles( const ExecSpace, const FunctorType init_functor ) { _timer.start(); - Kokkos::RangePolicy policy( 0, n_local ); + Kokkos::RangePolicy policy( 0, local_offset ); Kokkos::parallel_for( "CabanaPD::Particles::update_particles", policy, KOKKOS_LAMBDA( const int pid ) { init_functor( pid ); } ); _timer.stop(); } - auto numFrozen() const { return n_frozen; } - auto numLocal() const { return n_local; } - auto numGhost() const { return n_ghost; } - auto numReference() const { return size; } - auto numGlobal() const { return n_global; } + // Particles are always in order frozen, local, ghost. + // Values for offsets are distinguished from separate (num) values. + auto numFrozen() const { return frozen_offset; } + auto frozenOffset() const { return frozen_offset; } + auto numLocal() const { return local_offset - frozen_offset; } + auto localOffset() const { return local_offset; } + auto numGhost() const { return num_ghost; } + auto referenceOffset() const { return size; } + auto numGlobal() const { return num_global; } auto sliceReferencePosition() { @@ -408,7 +413,8 @@ class Particles auto y = Cabana::slice<0>( _aosoa_y, "current_positions" ); auto x = sliceReferencePosition(); auto u = sliceDisplacement(); - Kokkos::RangePolicy policy( 0, n_local + n_ghost ); + Kokkos::RangePolicy policy( frozenOffset(), + referenceOffset() ); auto sum_x_u = KOKKOS_LAMBDA( const std::size_t pid ) { for ( int d = 0; d < 3; d++ ) @@ -422,16 +428,17 @@ class Particles void resize( int new_local, int new_ghost ) { _timer.start(); - n_local = new_local; - n_ghost = new_ghost; - - _plist_x.aosoa().resize( new_local + new_ghost ); - _aosoa_u.resize( new_local + new_ghost ); - _aosoa_y.resize( new_local + new_ghost ); - _aosoa_vol.resize( new_local + new_ghost ); - _plist_f.aosoa().resize( new_local ); - _aosoa_other.resize( new_local ); - _aosoa_nofail.resize( new_local + new_ghost ); + local_offset = new_local; + num_ghost = new_ghost; + size = new_local + new_ghost; + + _plist_x.aosoa().resize( referenceOffset() ); + _aosoa_u.resize( referenceOffset() ); + _aosoa_y.resize( referenceOffset() ); + _aosoa_vol.resize( referenceOffset() ); + _plist_f.aosoa().resize( localOffset() ); + _aosoa_other.resize( localOffset() ); + _aosoa_nofail.resize( referenceOffset() ); size = _plist_x.size(); _timer.stop(); }; @@ -444,6 +451,7 @@ class Particles return sliceCurrentPosition(); } + // TODO: enable ignoring frozen particles. template void output( [[maybe_unused]] const int output_step, [[maybe_unused]] const double output_time, @@ -455,7 +463,7 @@ class Particles #ifdef Cabana_ENABLE_HDF5 Cabana::Experimental::HDF5ParticleOutput::writeTimeStep( h5_config, "particles", MPI_COMM_WORLD, output_step, output_time, - n_local, getPosition( use_reference ), sliceForce(), + local_offset, getPosition( use_reference ), sliceForce(), sliceDisplacement(), sliceVelocity(), std::forward( other )... ); #else @@ -463,7 +471,7 @@ class Particles Cabana::Grid::Experimental::SiloParticleOutput:: writePartialRangeTimeStep( "particles", local_grid->globalGrid(), output_step, output_time, - 0, n_local, getPosition( use_reference ), sliceForce(), + 0, local_offset, getPosition( use_reference ), sliceForce(), sliceDisplacement(), sliceVelocity(), std::forward( other )... ); @@ -516,12 +524,6 @@ class Particles using memory_space = typename base_type::memory_space; using base_type::dim; - // Per particle. - using base_type::n_ghost; - using base_type::n_global; - using base_type::n_local; - using base_type::size; - // These are split since weighted volume only needs to be communicated once // and dilatation only needs to be communicated for LPS. using scalar_type = typename base_type::scalar_type; @@ -565,8 +567,10 @@ class Particles max_halo_width ) { _init_timer.start(); - _aosoa_m = aosoa_m_type( "Particle Weighted Volumes", n_local ); - _aosoa_theta = aosoa_theta_type( "Particle Dilatations", n_local ); + _aosoa_m = aosoa_m_type( "Particle Weighted Volumes", + base_type::localOffset() ); + _aosoa_theta = aosoa_theta_type( "Particle Dilatations", + base_type::localOffset() ); init_lps(); _init_timer.stop(); } @@ -577,8 +581,8 @@ class Particles // Forward arguments to standard or custom particle creation. base_type::createParticles( std::forward( args )... ); _init_timer.start(); - _aosoa_m.resize( n_local ); - _aosoa_theta.resize( n_local ); + _aosoa_m.resize( base_type::localOffset() ); + _aosoa_theta.resize( base_type::localOffset() ); _init_timer.stop(); } @@ -603,8 +607,8 @@ class Particles { base_type::resize( new_local, new_ghost ); _timer.start(); - _aosoa_theta.resize( new_local + new_ghost ); - _aosoa_m.resize( new_local + new_ghost ); + _aosoa_theta.resize( base_type::referenceOffset() ); + _aosoa_m.resize( base_type::referenceOffset() ); _timer.stop(); } @@ -651,12 +655,6 @@ class Particles using memory_space = typename base_type::memory_space; using base_type::dim; - // Per particle. - using base_type::n_ghost; - using base_type::n_global; - using base_type::n_local; - using base_type::size; - // These are split since weighted volume only needs to be communicated once // and dilatation only needs to be communicated for LPS. using temp_types = Cabana::MemberTypes; @@ -695,7 +693,8 @@ class Particles : base_type( exec_space, low_corner, high_corner, num_cells, max_halo_width ) { - _aosoa_temp = aosoa_temp_type( "Particle Temperature", n_local ); + _aosoa_temp = + aosoa_temp_type( "Particle Temperature", base_type::localOffset() ); init_temp(); } @@ -704,7 +703,7 @@ class Particles { // Forward arguments to standard or custom particle creation. base_type::createParticles( std::forward( args )... ); - _aosoa_temp.resize( n_local ); + _aosoa_temp.resize( base_type::localOffset() ); } auto sliceTemperature() @@ -735,7 +734,7 @@ class Particles void resize( int new_local, int new_ghost ) { base_type::resize( new_local, new_ghost ); - _aosoa_temp.resize( new_local + new_ghost ); + _aosoa_temp.resize( base_type::referenceOffset() ); } template @@ -777,12 +776,6 @@ class Particles using memory_space = typename base_type::memory_space; using base_type::dim; - // Per particle. - using base_type::n_ghost; - using base_type::n_global; - using base_type::n_local; - using base_type::size; - // energy, damage using output_types = Cabana::MemberTypes; using aosoa_output_type = Cabana::AoSoA; @@ -820,7 +813,8 @@ class Particles : base_type( exec_space, low_corner, high_corner, num_cells, max_halo_width ) { - _aosoa_output = aosoa_output_type( "Particle Output Fields", n_local ); + _aosoa_output = aosoa_output_type( "Particle Output Fields", + base_type::localOffset() ); init_output(); } @@ -829,7 +823,7 @@ class Particles { // Forward arguments to standard or custom particle creation. base_type::createParticles( std::forward( args )... ); - _aosoa_output.resize( n_local ); + _aosoa_output.resize( base_type::localOffset() ); } auto sliceStrainEnergy() @@ -849,7 +843,7 @@ class Particles void resize( int new_local, int new_ghost ) { base_type::resize( new_local, new_ghost ); - _aosoa_output.resize( new_local + new_ghost ); + _aosoa_output.resize( base_type::localOffset() ); } template diff --git a/src/CabanaPD_Prenotch.hpp b/src/CabanaPD_Prenotch.hpp index 142b8acf..b147513e 100644 --- a/src/CabanaPD_Prenotch.hpp +++ b/src/CabanaPD_Prenotch.hpp @@ -222,7 +222,8 @@ struct Prenotch _timer.start(); auto x = particles.sliceReferencePosition(); - Kokkos::RangePolicy policy( 0, particles.n_local ); + // TODO: decide whether to disallow prenotches in frozen particles. + Kokkos::RangePolicy policy( 0, particles.localOffset() ); auto v1 = _v1; auto v2 = _v2; diff --git a/src/CabanaPD_Solver.hpp b/src/CabanaPD_Solver.hpp index 3d40bc33..af642f53 100644 --- a/src/CabanaPD_Solver.hpp +++ b/src/CabanaPD_Solver.hpp @@ -529,9 +529,10 @@ class SolverFracture _init_timer.start(); // Create View to track broken bonds. auto max_neighbors = force->getMaxLocalNeighbors(); + // TODO: this could be optimized to ignore frozen particle bonds. mu = NeighborView( Kokkos::ViewAllocateWithoutInitializing( "broken_bonds" ), - particles->numLocal(), max_neighbors ); + particles->localOffset(), max_neighbors ); Kokkos::deep_copy( mu, 1 ); _init_timer.stop(); } diff --git a/src/force/CabanaPD_Force_Contact.hpp b/src/force/CabanaPD_Force_Contact.hpp index 8221bbd4..49a7e022 100644 --- a/src/force/CabanaPD_Force_Contact.hpp +++ b/src/force/CabanaPD_Force_Contact.hpp @@ -35,7 +35,7 @@ class Force Force( const bool half_neigh, const ParticleType& particles, const NormalRepulsionModel model ) : base_type( half_neigh, model.Rc, particles.sliceCurrentPosition(), - particles.numLocal(), particles.ghost_mesh_lo, + particles.localOffset(), particles.ghost_mesh_lo, particles.ghost_mesh_hi ) , _model( model ) { @@ -57,7 +57,7 @@ class Force auto c = _model.c; const auto vol = particles.sliceVolume(); const auto y = particles.sliceCurrentPosition(); - const int n_local = particles.numLocal(); + const int n_local = particles.localOffset(); _neigh_timer.start(); _neigh_list.build( y, 0, n_local, Rc, 1.0, mesh_min, mesh_max ); diff --git a/src/force/CabanaPD_Force_LPS.hpp b/src/force/CabanaPD_Force_LPS.hpp index f4a7245b..90916153 100644 --- a/src/force/CabanaPD_Force_LPS.hpp +++ b/src/force/CabanaPD_Force_LPS.hpp @@ -117,8 +117,8 @@ class Force> m( i ) += m_j; }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_for( policy, weighted_volume, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForceLPS::computeWeightedVolume" ); @@ -150,8 +150,8 @@ class Force> theta( i ) += 3.0 * theta_i / m( i ); }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_for( policy, dilatation, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForceLPS::computeDilatation" ); @@ -196,8 +196,8 @@ class Force> f( i, 2 ) += fz_i; }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_for( policy, force_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForceLPS::computeFull" ); @@ -243,8 +243,8 @@ class Force> double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_reduce( policy, energy_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, strain_energy, @@ -318,8 +318,8 @@ class Force> } }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Kokkos::parallel_for( "CabanaPD::ForceLPSDamage::computeWeightedVolume", policy, weighted_volume ); @@ -365,8 +365,8 @@ class Force> } }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Kokkos::parallel_for( "CabanaPD::ForceLPSDamage::computeDilatation", policy, dilatation ); @@ -439,8 +439,8 @@ class Force> } }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Kokkos::parallel_for( "CabanaPD::ForceLPSDamage::computeFull", policy, force_full ); @@ -500,8 +500,8 @@ class Force> }; double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Kokkos::parallel_reduce( "CabanaPD::ForceLPSDamage::computeEnergyFull", policy, energy_full, strain_energy ); @@ -578,8 +578,8 @@ class Force> f( i, 2 ) += fz_i; }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_for( policy, force_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForceLPS::computeFull" ); @@ -627,8 +627,8 @@ class Force> double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_reduce( policy, energy_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, strain_energy, diff --git a/src/force/CabanaPD_Force_PMB.hpp b/src/force/CabanaPD_Force_PMB.hpp index e7a29288..5d6cd2a4 100644 --- a/src/force/CabanaPD_Force_PMB.hpp +++ b/src/force/CabanaPD_Force_PMB.hpp @@ -131,8 +131,8 @@ class Force> f( i, 2 ) += fz_i; }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_for( policy, force_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForcePMB::computeFull" ); @@ -168,8 +168,8 @@ class Force> }; double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_reduce( policy, energy_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, strain_energy, @@ -266,8 +266,8 @@ class Force> } }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Kokkos::parallel_for( "CabanaPD::ForcePMBDamage::computeFull", policy, force_full ); @@ -317,8 +317,8 @@ class Force> }; double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Kokkos::parallel_reduce( "CabanaPD::ForcePMBDamage::computeEnergyFull", policy, energy_full, strain_energy ); @@ -389,8 +389,8 @@ class Force> f( i, 2 ) += fz_i; }; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_for( policy, force_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForceLinearPMB::computeFull" ); @@ -426,8 +426,8 @@ class Force> }; double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.numFrozen(), - particles.numLocal() ); + Kokkos::RangePolicy policy( particles.frozenOffset(), + particles.localOffset() ); Cabana::neighbor_parallel_reduce( policy, energy_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, strain_energy, diff --git a/unit_test/tstComm.hpp b/unit_test/tstComm.hpp index bfc76522..95760534 100644 --- a/unit_test/tstComm.hpp +++ b/unit_test/tstComm.hpp @@ -67,7 +67,7 @@ void testHalo() }; particles.updateParticles( exec_space{}, init_functor ); - int init_num_particles = particles.numLocal(); + int init_num_particles = particles.localOffset(); using HostAoSoA = Cabana::AoSoA, Kokkos::HostSpace>; HostAoSoA aosoa_init_host( "host_aosoa", init_num_particles ); @@ -81,7 +81,7 @@ void testHalo() CabanaPD::TemperatureIndependent> comm( particles ); - HostAoSoA aosoa_host( "host_aosoa", particles.numReference() ); + HostAoSoA aosoa_host( "host_aosoa", particles.referenceOffset() ); x = particles.sliceReferencePosition(); rank = particles.sliceVolume(); auto x_host = Cabana::slice<0>( aosoa_host ); @@ -89,10 +89,10 @@ void testHalo() Cabana::deep_copy( x_host, x ); Cabana::deep_copy( rank_host, rank ); - EXPECT_EQ( particles.numLocal(), init_num_particles ); + EXPECT_EQ( particles.localOffset(), init_num_particles ); // Check all local particles unchanged. - for ( std::size_t p = 0; p < particles.numLocal(); ++p ) + for ( std::size_t p = 0; p < particles.localOffset(); ++p ) { for ( int d = 0; d < 3; ++d ) { @@ -109,8 +109,8 @@ void testHalo() EXPECT_GT( particles.numGhost(), 0 ); } // Check all ghost particles in the halo region. - for ( std::size_t p = particles.numLocal(); p < particles.numReference(); - ++p ) + for ( std::size_t p = particles.localOffset(); + p < particles.referenceOffset(); ++p ) { for ( int d = 0; d < 3; ++d ) { @@ -129,13 +129,13 @@ void testHalo() using NeighListType = Cabana::VerletList; - NeighListType nlist( x, 0, particles.numLocal(), delta, 1.0, mesh_min, + NeighListType nlist( x, 0, particles.localOffset(), delta, 1.0, mesh_min, mesh_max ); // Copy neighbors per particle to host. Kokkos::View num_neigh( "num_neighbors", - particles.numLocal() ); - Kokkos::RangePolicy policy( 0, particles.numLocal() ); + particles.localOffset() ); + Kokkos::RangePolicy policy( 0, particles.localOffset() ); Kokkos::parallel_for( "num_neighbors", policy, KOKKOS_LAMBDA( const int p ) { auto n = @@ -149,7 +149,7 @@ void testHalo() // boundaries (less than internal particles). auto num_neigh_host = Kokkos::create_mirror_view_and_copy( Kokkos::HostSpace{}, num_neigh ); - for ( std::size_t p = 0; p < particles.numLocal(); ++p ) + for ( std::size_t p = 0; p < particles.localOffset(); ++p ) { if ( x_host( p, 0 ) > box_min[0] + delta * 1.01 && x_host( p, 0 ) < box_max[0] - delta * 1.01 &&