ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
link_cell.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010-2026 The ESPResSo project
3
*
4
* This file is part of ESPResSo.
5
*
6
* ESPResSo is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* ESPResSo is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <iterator>
23
24
namespace
Algorithm
{
25
26
/**
27
* @brief Iterates over all particles in the cell range,
28
* and over all pairs within the cells and with
29
* their neighbors.
30
*/
31
template
<
typename
CellIterator,
typename
PairKernel>
32
void
link_cell
(
CellIterator
first
,
CellIterator
last
,
33
PairKernel
&&
pair_kernel
) {
34
for
(
auto
cell =
first
; cell !=
last
; ++cell) {
35
auto
&local_particles = cell->particles();
36
for
(
auto
it
= local_particles.begin();
it
!= local_particles.end(); ++
it
) {
37
auto
&
p1
= *
it
;
38
39
/* Pairs in this cell */
40
for
(
auto
jt
= std::next(
it
);
jt
!= local_particles.end(); ++
jt
) {
41
pair_kernel
(
p1
, *
jt
);
42
}
43
44
/* Pairs with neighbors */
45
for
(
auto
&
neighbor
: cell->neighbors().red()) {
46
for
(
auto
&
p2
:
neighbor
->particles()) {
47
pair_kernel
(
p1
,
p2
);
48
}
49
}
50
}
51
}
52
}
53
54
}
// namespace Algorithm
stream
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Definition
common_cuda.cu:34
Algorithm
Definition
link_cell.hpp:24
Algorithm::link_cell
void link_cell(CellIterator first, CellIterator last, PairKernel &&pair_kernel)
Iterates over all particles in the cell range, and over all pairs within the cells and with their nei...
Definition
link_cell.hpp:32
src
core
algorithm
link_cell.hpp
Generated on Thu Mar 5 2026 02:40:45 for ESPResSo by
1.9.8