24#ifdef ESPRESSO_SHARED_MEMORY_PARALLELISM
32#include <Cabana_Core.hpp>
33#include <Cabana_NeighborList.hpp>
35#ifdef ESPRESSO_CALIPER
36#include <caliper/cali.h>
43template <
class KokkosRangePolicy = Kokkos::RangePolicy<>>
47 if (Kokkos::num_threads() > 1) {
49 Kokkos::parallel_for(name, policy, kernel);
62#ifdef ESPRESSO_ELECTROSTATICS
68#if defined(ESPRESSO_GAY_BERNE) or defined(ESPRESSO_DIPOLES)
72#ifdef ESPRESSO_DIPOLES
78 aosoa.
id(index) = p.
id();
83#ifdef ESPRESSO_EXCLUSIONS
86 aosoa.
flags(index) = 0;
104 auto &local_particles = cells[i]->particles();
105 for (
auto it = local_particles.begin();
it != local_particles.end(); ++
it) {
106 auto const &
p1 = *
it;
108 auto const ii = id_to_index(
p1.id());
111 for (
auto jt = std::next(
it);
jt != local_particles.end(); ++
jt) {
112 if ((*jt).id() <=
max_id) {
114 auto const jj = id_to_index((*jt).id());
128 auto &local_particles = cells[i]->particles();
129 for (
auto const &
p1 : local_particles) {
131 auto const ii = id_to_index(
p1.id());
134 for (
auto &
neighbor : cells[i]->neighbors().red()) {
135 for (
auto const &
p2 :
neighbor->particles()) {
138 auto const jj = id_to_index(
p2.id());
151 Kokkos::parallel_for(
"inter", cells.size(),
intra_kernel);
154 Kokkos::parallel_for(
"intra", cells.size(),
inter_kernel);
160 double const pair_cutoff,
auto const integ_switch) {
161#ifdef ESPRESSO_CALIPER
165 using policy_type = Kokkos::RangePolicy<execution_space>;
168 auto const n_part = unique_particles.size();
170 auto &aosoa = cell_structure.
get_aosoa();
178#ifdef ESPRESSO_CALIPER
182 "AoSoA write", std::size_t{0}, n_part,
183 [&unique_particles, &aosoa, &id_to_index](
int const index) {
184 auto const &p = *unique_particles.at(index);
186 id_to_index(p.id()) = index;
189#ifdef ESPRESSO_CALIPER
198#ifdef ESPRESSO_CALIPER
202 [&](std::span<Cell *const> cells,
BoxGeometry const &box,
206 [&](
const int i,
const int j) {
210 [&](
const int i,
const int j) {
218 <<
"Verlet list overflow detected: neighbor count exceeded "
219 "max_counts. Falling back to the link cell algorithm. "
221 << Cabana::NeighborList<CellStructure::ListType>::maxNeighbor(
226#ifdef ESPRESSO_CALIPER
233#ifdef ESPRESSO_CALIPER
237 "AoSoA write", std::size_t{0}, n_part,
238 [&unique_particles, &aosoa](
int const index) {
239 auto const &p = *unique_particles.at(index);
243#ifdef ESPRESSO_CALIPER
249#ifdef ESPRESSO_ELECTROSTATICS
253 using policy_type = Kokkos::RangePolicy<execution_space>;
255 auto const n_part = unique_particles.size();
256 auto &aosoa = cell_structure.
get_aosoa();
259 "Views update charges", std::size_t{0}, n_part,
260 [&unique_particles, &aosoa](std::size_t
const index) {
261 aosoa.charge(index) = unique_particles.at(index)->q();
269 auto const integ_switch) {
274#ifdef ESPRESSO_CALIPER
278#ifdef ESPRESSO_CALIPER
285#ifdef ESPRESSO_CALIPER
291 Kokkos::RangePolicy<execution_space> policy(
294 Cabana::FirstNeighborsTag(),
295 Cabana::SerialOpTag());
298 [&](std::span<Cell *const> cells,
BoxGeometry const &box) {
303 [&](
const int i,
const int j) {
307 [&](
const int i,
const int j) {
314#ifdef ESPRESSO_CALIPER
#define ESPRESSO_ATTR_ALWAYS_INLINE
@ INTEG_METHOD_STEEPEST_DESCENT
Describes a cell structure / cell system.
void rebuild_verlet_list_cabana(auto &&kernel, bool rebuild_verlet_list)
auto prepare_verlet_list_cabana(double cutoff)
Reset local properties of the Verlet list.
int get_cached_max_local_particle_id() const
auto const & get_unique_particles() const
unsigned get_resort_particles() const
Get the currently scheduled resort level.
void bond_loop(BondKernel const &bond_kernel)
Bonded pair loop.
void cell_list_loop(auto &&kernel)
auto const & get_verlet_list_cabana() const
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
#define runtimeWarningMsg()
Vector< T, 3 > convert_quaternion_to_director(Quaternion< T > const &quat)
Convert quaternion to director.
ESPRESSO_ATTR_ALWAYS_INLINE void update_cabana_state(CellStructure &cell_structure, auto const &verlet_criterion, double const pair_cutoff, auto const integ_switch)
ESPRESSO_ATTR_ALWAYS_INLINE void link_cell_kokkos(std::span< Cell *const > cells, BoxGeometry const &box_geo, auto const &verlet_criterion, Kokkos::View< int * > const &id_to_index, int const max_id, auto const &intra_operator, auto const &inter_operator)
ESPRESSO_ATTR_ALWAYS_INLINE void commit_particle(Particle const &p, auto const index, CellStructure::AoSoA_pack &aosoa, bool const rebuild)
void cabana_short_range(auto const &bond_kernel, auto const &forces_kernel, CellStructure &cell_structure, double pair_cutoff, double bond_cutoff, auto const &verlet_criterion, auto const integ_switch)
ESPRESSO_ATTR_ALWAYS_INLINE void update_aosoa_charges(CellStructure &cell_structure)
ESPRESSO_ATTR_ALWAYS_INLINE void kokkos_parallel_range_for(auto const &name, auto start, auto end, auto const &kernel)
void set_vector_at(Kokkos::View< double *[3], array_layout, Kokkos::HostSpace > &view, std::size_t i, Utils::Vector3d const &value)
PositionViewType position
void set_has_exclusion(std::size_t i, bool value)
DirectorViewType director
VelocityViewType velocity
Struct holding all information for one particle.
Utils::compact_vector< int > & exclusions()
auto const & quat() const
auto const & type() const
auto const & dipm() const