ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
for_each_particle.hpp
Go to the documentation of this file.
1
2
/*
3
* Copyright (C) 2010-2026 The ESPResSo project
4
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
5
* Max-Planck-Institute for Polymer Research, Theory Group
6
*
7
* This file is part of ESPResSo.
8
*
9
* ESPResSo is free software: you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation, either version 3 of the License, or
12
* (at your option) any later version.
13
*
14
* ESPResSo is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
*/
22
23
#pragma once
24
25
#include "
cell_system/CellStructure.hpp
"
26
27
#include <Kokkos_Core.hpp>
28
29
#include <span>
30
31
template
<
typename
Callable>
32
inline
void
33
CellStructure::parallel_for_each_particle_impl(std::span<Cell *const> cells,
34
Callable &f)
const
{
35
if
(cells.size() > 1) {
36
Kokkos::parallel_for(
// loop over cells
37
"for_each_local_particle"
, cells.size(), [&](
auto
cell_idx) {
38
for (auto &p : cells[cell_idx]->particles())
39
f(p);
40
});
41
}
else
if
(cells.size() == 1) {
42
auto
&
particles
= cells.front()->particles();
43
Kokkos::parallel_for(
// loop over particles
44
"for_each_local_particle"
,
particles
.
size
(),
45
[&](
auto
part_idx) { f(*(particles.begin() + part_idx)); });
46
}
47
}
CellStructure.hpp
ParticleRange::size
base_type::size_type size() const
Definition
ParticleRange.hpp:44
Cells::particles
ParticleRange particles(std::span< Cell *const > cells)
Definition
CellStructure.hpp:111
src
core
cell_system
for_each_particle.hpp
Generated on Mon May 25 2026 01:34:52 for ESPResSo by
1.9.8