ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
cells.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22/**
23 * @file
24 * This file contains everything related to the global cell structure / cell
25 * system.
26 *
27 * The cell system (@ref CellStructure) describes how particles are
28 * distributed on the cells and how particles of different cells
29 * (regardless if they reside on the same or different nodes)
30 * interact with each other. The following cell systems are implemented:
31 *
32 * - regular decomposition: The simulation box is divided spatially
33 * into cells (see @ref RegularDecomposition.hpp). This is suitable for
34 * short-range interactions.
35 * - N-square: The particles are distributed equally on all nodes
36 * regardless their spatial position (see @ref AtomDecomposition.hpp).
37 * This is suitable for long-range interactions that cannot be treated
38 * by a special method like P3M.
39 * - hybrid decomposition: Initializes both regular decomposition
40 * and N-square at the same time and is given a set of particle types
41 * @c n_square_types (see @ref HybridDecomposition.hpp). By default,
42 * particles will be distributed using the regular decomposition.
43 * For particles of the types defined as @c n_square_types the N-square
44 * method is used. This is suitable for systems containing lots of small
45 * particles with short-range interactions mixed with a few large
46 * particles with long-range interactions. There, the large particles
47 * should be treated using N-square.
48 */
49
50#pragma once
51
52#include "cell_system/Cell.hpp"
55
56#include "BoxGeometry.hpp"
57#include "Particle.hpp"
58#include "system/System.hpp"
59
60#include <utils/Vector.hpp>
61
62#include <boost/optional.hpp>
63
64#include <utility>
65#include <vector>
66
67/**
68 * @brief Get pairs closer than @p distance from the cells.
69 *
70 * Pairs are sorted so that first.id < second.id
71 */
72std::vector<std::pair<int, int>> get_pairs(System::System const &system,
73 double distance);
74
75/**
76 * @brief Get pairs closer than @p distance if both their types are in @p types
77 *
78 * Pairs are sorted so that first.id < second.id
79 */
80std::vector<std::pair<int, int>>
81get_pairs_of_types(System::System const &system, double distance,
82 std::vector<int> const &types);
83
84/**
85 * @brief Get ids of particles that are within a certain distance
86 * of another particle.
87 */
88boost::optional<std::vector<int>>
89get_short_range_neighbors(System::System const &system, int pid,
90 double distance);
91
93 NeighborPIDs() = default;
94 NeighborPIDs(int _pid, std::vector<int> _neighbor_pids)
95 : pid{_pid}, neighbor_pids{std::move(_neighbor_pids)} {}
96
97 int pid;
98 std::vector<int> neighbor_pids;
99};
100
101namespace boost {
102namespace serialization {
103template <class Archive>
104void serialize(Archive &ar, NeighborPIDs &n, unsigned int const /* version */) {
105 ar & n.pid;
106 ar & n.neighbor_pids;
107}
108} // namespace serialization
109} // namespace boost
110
111/**
112 * @brief Returns pairs of particle ids and neighbor particle id lists.
113 */
114std::vector<NeighborPIDs> get_neighbor_pids(System::System const &system);
115
116class PairInfo {
117public:
118 PairInfo() = default;
119 PairInfo(int _id1, int _id2, Utils::Vector3d _pos1, Utils::Vector3d _pos2,
120 Utils::Vector3d _vec21, int _node)
121 : id1(_id1), id2(_id2), pos1(_pos1), pos2(_pos2), vec21(_vec21),
122 node(_node) {}
123 int id1;
124 int id2;
128 int node;
129};
130
131namespace boost {
132namespace serialization {
133template <class Archive>
134void serialize(Archive &ar, PairInfo &p, unsigned int const /* version */) {
135 ar & p.id1;
136 ar & p.id2;
137 ar & p.pos1;
138 ar & p.pos2;
139 ar & p.vec21;
140 ar & p.node;
141}
142} // namespace serialization
143} // namespace boost
144
145/**
146 * @brief Returns pairs of particle ids, positions and distance as seen by the
147 * non-bonded loop.
148 */
149std::vector<PairInfo> non_bonded_loop_trace(System::System const &system,
150 int rank);
Vector implementation and trait types for boost qvm interoperability.
std::vector< std::pair< int, int > > get_pairs(System::System const &system, double distance)
Get pairs closer than distance from the cells.
Definition cells.cpp:159
std::vector< std::pair< int, int > > get_pairs_of_types(System::System const &system, double distance, std::vector< int > const &types)
Get pairs closer than distance if both their types are in types.
Definition cells.cpp:167
boost::optional< std::vector< int > > get_short_range_neighbors(System::System const &system, int pid, double distance)
Get ids of particles that are within a certain distance of another particle.
Definition cells.cpp:119
std::vector< NeighborPIDs > get_neighbor_pids(System::System const &system)
Returns pairs of particle ids and neighbor particle id lists.
Definition cells.cpp:189
std::vector< PairInfo > non_bonded_loop_trace(System::System const &system, int rank)
Returns pairs of particle ids, positions and distance as seen by the non-bonded loop.
Definition cells.cpp:177
PairInfo(int _id1, int _id2, Utils::Vector3d _pos1, Utils::Vector3d _pos2, Utils::Vector3d _vec21, int _node)
Definition cells.hpp:119
int id1
Definition cells.hpp:123
Utils::Vector3d vec21
Definition cells.hpp:127
PairInfo()=default
Utils::Vector3d pos2
Definition cells.hpp:126
Utils::Vector3d pos1
Definition cells.hpp:125
int node
Definition cells.hpp:128
int id2
Definition cells.hpp:124
Main system class.
void serialize(Archive &ar, std::tuple< T... > &pack, unsigned int const)
Serialize std::tuple.
std::vector< int > neighbor_pids
Definition cells.hpp:98
NeighborPIDs()=default
NeighborPIDs(int _pid, std::vector< int > _neighbor_pids)
Definition cells.hpp:94