From b263b6b4cda560a1fe079fac6e4cc826fc6af218 Mon Sep 17 00:00:00 2001 From: Sam Reeve <6740307+streeve@users.noreply.github.com> Date: Fri, 13 Dec 2024 21:13:49 -0500 Subject: [PATCH] Add particle class methods for sizes --- src/CabanaPD_BodyTerm.hpp | 4 +-- src/CabanaPD_Boundary.hpp | 4 +-- src/CabanaPD_Comm.hpp | 2 +- src/CabanaPD_DisplacementProfile.hpp | 2 +- src/CabanaPD_Force.hpp | 28 +++++++---------- src/CabanaPD_HeatTransfer.hpp | 20 ++++++------ src/CabanaPD_Integrate.hpp | 4 +-- src/CabanaPD_Particles.hpp | 6 ++++ src/CabanaPD_Solver.hpp | 22 ++++++------- src/force/CabanaPD_Force_Contact.hpp | 5 +-- src/force/CabanaPD_Force_LPS.hpp | 46 ++++++++++++++++------------ src/force/CabanaPD_Force_PMB.hpp | 31 +++++++++++-------- unit_test/tstComm.hpp | 21 +++++++------ unit_test/tstForce.hpp | 4 +-- 14 files changed, 106 insertions(+), 93 deletions(-) diff --git a/src/CabanaPD_BodyTerm.hpp b/src/CabanaPD_BodyTerm.hpp index 14b199c3..f2844775 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.n_frozen, - particles.n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); auto user = _user_functor; Kokkos::parallel_for( "CabanaPD::BodyTerm::apply", policy, diff --git a/src/CabanaPD_Boundary.hpp b/src/CabanaPD_Boundary.hpp index c1a3057c..3d0c4638 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.n_local * initial_guess ); + particles.numLocal() * 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.n_local ); + Kokkos::RangePolicy policy( 0, particles.numLocal() ); 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 5ee56eb3..c51eb85d 100644 --- a/src/CabanaPD_Comm.hpp +++ b/src/CabanaPD_Comm.hpp @@ -271,7 +271,7 @@ class Comm // Create the Cabana Halo. halo = std::make_shared( local_grid->globalGrid().comm(), - particles.n_local, halo_ids._ids, + particles.numLocal(), 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 be5ca283..0339f77a 100644 --- a/src/CabanaPD_DisplacementProfile.hpp +++ b/src/CabanaPD_DisplacementProfile.hpp @@ -57,7 +57,7 @@ void createOutputProfile( MPI_Comm comm, const int num_cell, } }; Kokkos::RangePolicy policy( - 0, particles.n_local ); + 0, particles.numLocal() ); 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 96ae381f..b8b3085f 100644 --- a/src/CabanaPD_Force.hpp +++ b/src/CabanaPD_Force.hpp @@ -150,7 +150,7 @@ class Force const ParticleType& particles, const double tol = 1e-14 ) : _half_neigh( half_neigh ) , _neigh_list( neighbor_list_type( particles.sliceReferencePosition(), - 0, particles.n_local, delta + tol, + 0, particles.numLocal(), delta + tol, 1.0, particles.ghost_mesh_lo, particles.ghost_mesh_hi ) ) { @@ -239,7 +239,6 @@ template void computeForce( ForceType& force, ParticleType& particles, const ParallelType& neigh_op_tag, const bool reset = true ) { - auto n_local = particles.n_local; auto x = particles.sliceReferencePosition(); auto u = particles.sliceDisplacement(); auto f = particles.sliceForce(); @@ -251,14 +250,14 @@ void computeForce( ForceType& force, ParticleType& particles, // if ( half_neigh ) // Forces must be atomic for half list - // computeForce_half( f_a, x, u, n_local, + // computeForce_half( f_a, x, u, // neigh_op_tag ); // Forces only atomic if using team threading. if ( std::is_same::value ) - force.computeForceFull( f_a, x, u, particles, n_local, neigh_op_tag ); + force.computeForceFull( f_a, x, u, particles, neigh_op_tag ); else - force.computeForceFull( f, x, u, particles, n_local, neigh_op_tag ); + force.computeForceFull( f, x, u, particles, neigh_op_tag ); Kokkos::fence(); } @@ -269,7 +268,6 @@ double computeEnergy( ForceType& force, ParticleType& particles, double energy = 0.0; if constexpr ( is_energy_output::value ) { - auto n_local = particles.n_local; auto x = particles.sliceReferencePosition(); auto u = particles.sliceDisplacement(); auto f = particles.sliceForce(); @@ -281,10 +279,9 @@ double computeEnergy( ForceType& force, ParticleType& particles, // if ( _half_neigh ) // energy = computeEnergy_half( force, x, u, - // n_local, neigh_op_tag ); + // neigh_op_tag ); // else - energy = force.computeEnergyFull( W, x, u, particles, n_local, - neigh_op_tag ); + energy = force.computeEnergyFull( W, x, u, particles, neigh_op_tag ); Kokkos::fence(); } return energy; @@ -296,7 +293,6 @@ template ::value ) - force.computeForceFull( f_a, x, u, particles, mu, n_local, - neigh_op_tag ); + force.computeForceFull( f_a, x, u, particles, mu, neigh_op_tag ); else - force.computeForceFull( f, x, u, particles, mu, n_local, neigh_op_tag ); + force.computeForceFull( f, x, u, particles, mu, neigh_op_tag ); Kokkos::fence(); } @@ -328,7 +323,6 @@ double computeEnergy( ForceType& force, ParticleType& particles, double energy = 0.0; if constexpr ( is_energy_output::value ) { - auto n_local = particles.n_local; auto x = particles.sliceReferencePosition(); auto u = particles.sliceDisplacement(); auto f = particles.sliceForce(); @@ -340,9 +334,9 @@ double computeEnergy( ForceType& force, ParticleType& particles, // if ( _half_neigh ) // energy = computeEnergy_half( force, x, u, - // n_local, neigh_op_tag ); + // neigh_op_tag ); // else - energy = force.computeEnergyFull( W, x, u, phi, particles, mu, n_local, + energy = force.computeEnergyFull( W, x, u, phi, particles, mu, neigh_op_tag ); Kokkos::fence(); } diff --git a/src/CabanaPD_HeatTransfer.hpp b/src/CabanaPD_HeatTransfer.hpp index 7d7e0fe4..e678ae9d 100644 --- a/src/CabanaPD_HeatTransfer.hpp +++ b/src/CabanaPD_HeatTransfer.hpp @@ -49,10 +49,10 @@ class HeatTransfer : public Force template - void - computeHeatTransferFull( TemperatureType& conduction, const PosType& x, - const PosType& u, const ParticleType& particles, - const int n_local, ParallelType& neigh_op_tag ) + void computeHeatTransferFull( TemperatureType& conduction, const PosType& x, + const PosType& u, + const ParticleType& particles, + ParallelType& neigh_op_tag ) { _timer.start(); @@ -70,7 +70,8 @@ class HeatTransfer : public Force coeff * ( temp( j ) - temp( i ) ) / xi / xi * vol( j ); }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Cabana::neighbor_parallel_for( policy, temp_func, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::HeatTransfer::computeFull" ); @@ -86,12 +87,12 @@ class HeatTransfer : public Force const auto rho = particles.sliceDensity(); const auto conduction = particles.sliceTemperatureConduction(); auto temp = particles.sliceTemperature(); - auto n_local = particles.n_local; auto euler_func = KOKKOS_LAMBDA( const int i ) { temp( i ) += dt / rho( i ) / model.cp * conduction( i ); }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Kokkos::parallel_for( "CabanaPD::HeatTransfer::forwardEuler", policy, euler_func ); _euler_timer.stop(); @@ -104,7 +105,6 @@ void computeHeatTransfer( HeatTransferType& heat_transfer, ParticleType& particles, const ParallelType& neigh_op_tag, const double dt ) { - auto n_local = particles.n_local; auto x = particles.sliceReferencePosition(); auto u = particles.sliceDisplacement(); auto conduction = particles.sliceTemperatureConduction(); @@ -116,10 +116,10 @@ void computeHeatTransfer( HeatTransferType& heat_transfer, // Temperature only needs to be atomic if using team threading. if ( std::is_same::value ) heat_transfer.computeHeatTransferFull( conduction_a, x, u, particles, - n_local, neigh_op_tag ); + neigh_op_tag ); else heat_transfer.computeHeatTransferFull( conduction, x, u, particles, - n_local, neigh_op_tag ); + neigh_op_tag ); Kokkos::fence(); heat_transfer.forwardEuler( particles, dt ); diff --git a/src/CabanaPD_Integrate.hpp b/src/CabanaPD_Integrate.hpp index 80e1308c..44abd3ee 100644 --- a/src/CabanaPD_Integrate.hpp +++ b/src/CabanaPD_Integrate.hpp @@ -106,7 +106,7 @@ class Integrator u( i, 1 ) += dt * v( i, 1 ); u( i, 2 ) += dt * v( i, 2 ); }; - Kokkos::RangePolicy policy( p.n_frozen, p.n_local ); + Kokkos::RangePolicy policy( p.numFrozen(), p.numLocal() ); Kokkos::parallel_for( "CabanaPD::Integrator::Initial", policy, init_func ); @@ -130,7 +130,7 @@ class Integrator v( i, 1 ) += half_dt_m * f( i, 1 ); v( i, 2 ) += half_dt_m * f( i, 2 ); }; - Kokkos::RangePolicy policy( p.n_frozen, p.n_local ); + Kokkos::RangePolicy policy( p.numFrozen(), p.numLocal() ); Kokkos::parallel_for( "CabanaPD::Integrator::Final", policy, final_func ); diff --git a/src/CabanaPD_Particles.hpp b/src/CabanaPD_Particles.hpp index 59638efb..1c105c81 100644 --- a/src/CabanaPD_Particles.hpp +++ b/src/CabanaPD_Particles.hpp @@ -325,6 +325,12 @@ class Particles _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; } + auto sliceReferencePosition() { return _plist_x.slice( CabanaPD::Field::ReferencePosition() ); diff --git a/src/CabanaPD_Solver.hpp b/src/CabanaPD_Solver.hpp index 6625086a..3d40bc33 100644 --- a/src/CabanaPD_Solver.hpp +++ b/src/CabanaPD_Solver.hpp @@ -197,7 +197,7 @@ class SolverElastic print = print_rank(); if ( print ) { - log( std::cout, "Local particles: ", particles->n_local, + log( std::cout, "Local particles: ", particles->numLocal(), ", Maximum neighbors: ", max_neighbors ); log( std::cout, "#Timestep/Total-steps Simulation-time" ); @@ -212,8 +212,8 @@ class SolverElastic exec_space().print_configuration( out ); log( out, "Local particles, Ghosted particles, Global particles\n", - particles->n_local, ", ", particles->n_ghost, ", ", - particles->n_global ); + particles->numLocal(), ", ", particles->numGhost(), ", ", + particles->numGlobal() ); log( out, "Maximum neighbors: ", max_neighbors, ", Total neighbors: ", total_neighbors, "\n" ); out.close(); @@ -407,7 +407,7 @@ class SolverElastic double energy_time = force->timeEnergy(); double output_time = particles->timeOutput(); _total_time += step_time; - auto rate = static_cast( particles->n_global * + auto rate = static_cast( particles->numGlobal() * output_frequency / ( step_time ) ); _step_timer.reset(); log( out, std::fixed, std::setprecision( 6 ), step, "/", num_steps, @@ -434,15 +434,15 @@ class SolverElastic energy_time + output_time + particles->time(); double steps_per_sec = 1.0 * num_steps / _total_time; - double p_steps_per_sec = particles->n_global * steps_per_sec; + double p_steps_per_sec = particles->numGlobal() * steps_per_sec; log( out, std::fixed, std::setprecision( 2 ), "\n#Procs Particles | Total Force Comm Integrate Energy " "Output Init Init_Neighbor |\n", - comm->mpi_size, " ", particles->n_global, " | \t", _total_time, - " ", force_time, " ", comm_time, " ", integrate_time, " ", - energy_time, " ", output_time, " ", _init_time, " ", - neighbor_time, " | PERFORMANCE\n", std::fixed, comm->mpi_size, - " ", particles->n_global, " | \t", 1.0, " ", + comm->mpi_size, " ", particles->numGlobal(), " | \t", + _total_time, " ", force_time, " ", comm_time, " ", + integrate_time, " ", energy_time, " ", output_time, " ", + _init_time, " ", neighbor_time, " | PERFORMANCE\n", std::fixed, + comm->mpi_size, " ", particles->numGlobal(), " | \t", 1.0, " ", force_time / _total_time, " ", comm_time / _total_time, " ", integrate_time / _total_time, " ", energy_time / _total_time, " ", output_time / _total_time, " ", _init_time / _total_time, @@ -531,7 +531,7 @@ class SolverFracture auto max_neighbors = force->getMaxLocalNeighbors(); mu = NeighborView( Kokkos::ViewAllocateWithoutInitializing( "broken_bonds" ), - particles->n_local, max_neighbors ); + particles->numLocal(), 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 f3b389ef..8221bbd4 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.n_local, particles.ghost_mesh_lo, + particles.numLocal(), particles.ghost_mesh_lo, particles.ghost_mesh_hi ) , _model( model ) { @@ -49,7 +49,7 @@ class Force template void computeForceFull( ForceType& fc, const PosType& x, const PosType& u, - const ParticleType& particles, const int n_local, + const ParticleType& particles, ParallelType& neigh_op_tag ) { auto delta = _model.delta; @@ -57,6 +57,7 @@ class Force auto c = _model.c; const auto vol = particles.sliceVolume(); const auto y = particles.sliceCurrentPosition(); + const int n_local = particles.numLocal(); _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 d6f2a543..f4a7245b 100644 --- a/src/force/CabanaPD_Force_LPS.hpp +++ b/src/force/CabanaPD_Force_LPS.hpp @@ -101,7 +101,6 @@ class Force> { _timer.start(); - auto n_local = particles.n_local; auto x = particles.sliceReferencePosition(); auto u = particles.sliceDisplacement(); const auto vol = particles.sliceVolume(); @@ -118,7 +117,8 @@ class Force> m( i ) += m_j; }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Cabana::neighbor_parallel_for( policy, weighted_volume, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForceLPS::computeWeightedVolume" ); @@ -132,7 +132,6 @@ class Force> { _timer.start(); - auto n_local = particles.n_local; const auto x = particles.sliceReferencePosition(); auto u = particles.sliceDisplacement(); const auto vol = particles.sliceVolume(); @@ -151,7 +150,8 @@ class Force> theta( i ) += 3.0 * theta_i / m( i ); }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Cabana::neighbor_parallel_for( policy, dilatation, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForceLPS::computeDilatation" ); @@ -162,7 +162,7 @@ class Force> template void computeForceFull( ForceType& f, const PosType& x, const PosType& u, - const ParticleType& particles, const int n_local, + const ParticleType& particles, ParallelType& neigh_op_tag ) { _timer.start(); @@ -196,7 +196,8 @@ class Force> f( i, 2 ) += fz_i; }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Cabana::neighbor_parallel_for( policy, force_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForceLPS::computeFull" ); @@ -207,7 +208,7 @@ class Force> template double computeEnergyFull( WType& W, const PosType& x, const PosType& u, - const ParticleType& particles, const int n_local, + const ParticleType& particles, ParallelType& neigh_op_tag ) { _energy_timer.start(); @@ -242,7 +243,8 @@ class Force> double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Cabana::neighbor_parallel_reduce( policy, energy_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, strain_energy, @@ -287,7 +289,6 @@ class Force> { _timer.start(); - auto n_local = particles.n_local; auto x = particles.sliceReferencePosition(); auto u = particles.sliceDisplacement(); const auto vol = particles.sliceVolume(); @@ -317,7 +318,8 @@ class Force> } }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Kokkos::parallel_for( "CabanaPD::ForceLPSDamage::computeWeightedVolume", policy, weighted_volume ); @@ -329,7 +331,6 @@ class Force> { _timer.start(); - auto n_local = particles.n_local; const auto x = particles.sliceReferencePosition(); auto u = particles.sliceDisplacement(); const auto vol = particles.sliceVolume(); @@ -364,7 +365,8 @@ class Force> } }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Kokkos::parallel_for( "CabanaPD::ForceLPSDamage::computeDilatation", policy, dilatation ); @@ -375,7 +377,7 @@ class Force> class ParallelType> void computeForceFull( ForceType& f, const PosType& x, const PosType& u, const ParticleType& particles, MuView& mu, - const int n_local, ParallelType& ) + ParallelType& ) { _timer.start(); @@ -437,7 +439,8 @@ class Force> } }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Kokkos::parallel_for( "CabanaPD::ForceLPSDamage::computeFull", policy, force_full ); @@ -448,7 +451,7 @@ class Force> class MuView, class ParallelType> double computeEnergyFull( WType& W, const PosType& x, const PosType& u, DamageType& phi, const ParticleType& particles, - MuView& mu, const int n_local, ParallelType& ) + MuView& mu, ParallelType& ) { _energy_timer.start(); @@ -497,7 +500,8 @@ class Force> }; double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Kokkos::parallel_reduce( "CabanaPD::ForceLPSDamage::computeEnergyFull", policy, energy_full, strain_energy ); @@ -534,7 +538,7 @@ class Force> template void computeForceFull( ForceType& f, const PosType& x, const PosType& u, - const ParticleType& particles, const int n_local, + const ParticleType& particles, ParallelType& neigh_op_tag ) { _timer.start(); @@ -574,7 +578,8 @@ class Force> f( i, 2 ) += fz_i; }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Cabana::neighbor_parallel_for( policy, force_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForceLPS::computeFull" ); @@ -585,7 +590,7 @@ class Force> template double computeEnergyFull( WType& W, const PosType& x, const PosType& u, - const ParticleType& particles, const int n_local, + const ParticleType& particles, ParallelType& neigh_op_tag ) { _energy_timer.start(); @@ -622,7 +627,8 @@ class Force> double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); 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 9e39b847..e7a29288 100644 --- a/src/force/CabanaPD_Force_PMB.hpp +++ b/src/force/CabanaPD_Force_PMB.hpp @@ -101,7 +101,7 @@ class Force> template void computeForceFull( ForceType& f, const PosType& x, const PosType& u, - const ParticleType& particles, const int n_local, + const ParticleType& particles, ParallelType& neigh_op_tag ) { _timer.start(); @@ -131,7 +131,8 @@ class Force> f( i, 2 ) += fz_i; }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Cabana::neighbor_parallel_for( policy, force_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForcePMB::computeFull" ); @@ -142,7 +143,7 @@ class Force> template double computeEnergyFull( WType& W, const PosType& x, const PosType& u, - const ParticleType& particles, const int n_local, + const ParticleType& particles, ParallelType& neigh_op_tag ) { _energy_timer.start(); @@ -167,7 +168,8 @@ class Force> }; double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Cabana::neighbor_parallel_reduce( policy, energy_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, strain_energy, @@ -211,7 +213,7 @@ class Force> class ParallelType> void computeForceFull( ForceType& f, const PosType& x, const PosType& u, const ParticleType& particles, MuView& mu, - const int n_local, ParallelType& ) + ParallelType& ) { _timer.start(); @@ -264,7 +266,8 @@ class Force> } }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Kokkos::parallel_for( "CabanaPD::ForcePMBDamage::computeFull", policy, force_full ); @@ -275,7 +278,7 @@ class Force> class MuView, class ParallelType> double computeEnergyFull( WType& W, const PosType& x, const PosType& u, DamageType& phi, const ParticleType& particles, - MuView& mu, const int n_local, ParallelType& ) + MuView& mu, ParallelType& ) { _energy_timer.start(); @@ -314,7 +317,8 @@ class Force> }; double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Kokkos::parallel_reduce( "CabanaPD::ForcePMBDamage::computeEnergyFull", policy, energy_full, strain_energy ); @@ -354,8 +358,7 @@ class Force> template void computeForceFull( ForceType& f, const PosType& x, const PosType& u, - ParticleType& particles, const int n_local, - ParallelType& neigh_op_tag ) + ParticleType& particles, ParallelType& neigh_op_tag ) { _timer.start(); @@ -386,7 +389,8 @@ class Force> f( i, 2 ) += fz_i; }; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); Cabana::neighbor_parallel_for( policy, force_full, _neigh_list, Cabana::FirstNeighborsTag(), neigh_op_tag, "CabanaPD::ForceLinearPMB::computeFull" ); @@ -397,7 +401,7 @@ class Force> template double computeEnergyFull( WType& W, const PosType& x, const PosType& u, - ParticleType& particles, const int n_local, + ParticleType& particles, ParallelType& neigh_op_tag ) { _energy_timer.start(); @@ -422,7 +426,8 @@ class Force> }; double strain_energy = 0.0; - Kokkos::RangePolicy policy( particles.n_frozen, n_local ); + Kokkos::RangePolicy policy( particles.numFrozen(), + particles.numLocal() ); 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 bcbbceea..bfc76522 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.n_local; + int init_num_particles = particles.numLocal(); 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.size ); + HostAoSoA aosoa_host( "host_aosoa", particles.numReference() ); 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.n_local, init_num_particles ); + EXPECT_EQ( particles.numLocal(), init_num_particles ); // Check all local particles unchanged. - for ( std::size_t p = 0; p < particles.n_local; ++p ) + for ( std::size_t p = 0; p < particles.numLocal(); ++p ) { for ( int d = 0; d < 3; ++d ) { @@ -106,10 +106,11 @@ void testHalo() // Ghosts should have been created for all but single rank systems. if ( current_size > 1 ) { - EXPECT_GT( particles.n_ghost, 0 ); + EXPECT_GT( particles.numGhost(), 0 ); } // Check all ghost particles in the halo region. - for ( std::size_t p = particles.n_local; p < particles.size; ++p ) + for ( std::size_t p = particles.numLocal(); p < particles.numReference(); + ++p ) { for ( int d = 0; d < 3; ++d ) { @@ -128,13 +129,13 @@ void testHalo() using NeighListType = Cabana::VerletList; - NeighListType nlist( x, 0, particles.n_local, delta, 1.0, mesh_min, + NeighListType nlist( x, 0, particles.numLocal(), delta, 1.0, mesh_min, mesh_max ); // Copy neighbors per particle to host. Kokkos::View num_neigh( "num_neighbors", - particles.n_local ); - Kokkos::RangePolicy policy( 0, particles.n_local ); + particles.numLocal() ); + Kokkos::RangePolicy policy( 0, particles.numLocal() ); Kokkos::parallel_for( "num_neighbors", policy, KOKKOS_LAMBDA( const int p ) { auto n = @@ -148,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.n_local; ++p ) + for ( std::size_t p = 0; p < particles.numLocal(); ++p ) { if ( x_host( p, 0 ) > box_min[0] + delta * 1.01 && x_host( p, 0 ) < box_max[0] - delta * 1.01 && diff --git a/unit_test/tstForce.hpp b/unit_test/tstForce.hpp index be6babd7..0d57e5ea 100644 --- a/unit_test/tstForce.hpp +++ b/unit_test/tstForce.hpp @@ -639,7 +639,7 @@ double computeEnergyAndForce( DamageTag, ForceType force, { Kokkos::View mu( Kokkos::ViewAllocateWithoutInitializing( "broken_bonds" ), - particles.n_local, max_neighbors ); + particles.numLocal(), max_neighbors ); Kokkos::deep_copy( mu, 1 ); computeForce( force, particles, mu, Cabana::SerialOpTag() ); double Phi = computeEnergy( force, particles, mu, Cabana::SerialOpTag() ); @@ -658,7 +658,7 @@ void initializeForce( CabanaPD::ForceModel, ForceType& force, ParticleType& particles ) { auto max_neighbors = force.getMaxLocalNeighbors(); - Kokkos::View mu( "broken_bonds", particles.n_local, + Kokkos::View mu( "broken_bonds", particles.numLocal(), max_neighbors ); Kokkos::deep_copy( mu, 1 ); force.computeWeightedVolume( particles, mu );