ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
ParticleDecomposition.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020-2022 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 "cell_system/Cell.hpp"
23
24#include "BoxGeometry.hpp"
25#include "ghosts.hpp"
26
27#include <utils/Span.hpp>
28#include <utils/Vector.hpp>
29
30#include <boost/optional.hpp>
31#include <boost/variant.hpp>
32
33#include <vector>
34
36 int id;
37};
38
42
43/**
44 * @brief Change of Particle Address.
45 */
46using ParticleChange = boost::variant<RemovedParticle, ModifiedList>;
47
48/**
49 * @brief A distributed particle decomposition.
50 *
51 * An implementation of this class organizes particles into cells.
52 * It owns the particles, and provides a way of restoring the order
53 * when it is disturbed, and provides a description of the neighborhood
54 * relations between the cells, by which pair interactions with particles
55 * near-by can be calculated. Related to this it provides descriptions
56 * of the ghost communications by which particles can be synchronized that
57 * are not owned locally, but interact with local particles.
58 */
60public:
61 /**
62 * @brief Resort particles.
63 *
64 * After calling this function, every particle is in its home cell.
65 * The output parameter is filled with the changes to the local
66 * particle content, which allows e.g. to keep particles indices
67 * in an efficient way.
68 *
69 * This is a collective call.
70 *
71 * @param[in] global_flag Expect particles to be displaced by more than a
72 * local box size.
73 * @param[out] diff Cells that have been touched.
74 */
75 virtual void resort(bool global_flag, std::vector<ParticleChange> &diff) = 0;
76
77 /**
78 * @brief Communicator for updating ghosts from the real particles.
79 */
80 virtual GhostCommunicator const &exchange_ghosts_comm() const = 0;
81 /**
82 * @brief Communicator for force reduction.
83 */
84 virtual GhostCommunicator const &collect_ghost_force_comm() const = 0;
85
86 /**
87 * @brief Get pointer to local cells.
88 *
89 * Local cells are cells that contain particles
90 * that are owned by this node.
91 *
92 * @return List of local cells.
93 */
95
96 /**
97 * @brief Get pointer to local cells.
98 *
99 * Ghost cells are cells that contain particles
100 * that are owned by different nodes but interact
101 * with particles on this node.
102 *
103 * @return List of ghost cells.
104 */
106
107 /**
108 * @brief Determine which cell a particle id belongs to.
109 *
110 * @param p Particle to find cell for.
111 * @return Pointer to cell or nullptr if not local.
112 */
113 virtual Cell *particle_to_cell(Particle const &p) = 0;
114 virtual Cell const *particle_to_cell(Particle const &p) const = 0;
115
116 /**
117 * @brief Maximum supported cutoff.
118 */
119 virtual Utils::Vector3d max_cutoff() const = 0;
120
121 /**
122 * @brief Range in which calculations are performed.
123 */
124 virtual Utils::Vector3d max_range() const = 0;
125
126 /**
127 * @brief Return the box geometry needed for distance calculation
128 * if minimum image convention should be used needed for
129 * distance calculation.
130 */
131 virtual boost::optional<BoxGeometry> minimum_image_distance() const = 0;
132
133 virtual BoxGeometry const &box() const = 0;
134
135 virtual ~ParticleDecomposition() = default;
136};
boost::variant< RemovedParticle, ModifiedList > ParticleChange
Change of Particle Address.
Vector implementation and trait types for boost qvm interoperability.
Definition Cell.hpp:98
A distributed particle decomposition.
virtual Utils::Span< Cell *const > local_cells() const =0
Get pointer to local cells.
virtual Utils::Vector3d max_cutoff() const =0
Maximum supported cutoff.
virtual Cell const * particle_to_cell(Particle const &p) const =0
virtual ~ParticleDecomposition()=default
virtual void resort(bool global_flag, std::vector< ParticleChange > &diff)=0
Resort particles.
virtual Cell * particle_to_cell(Particle const &p)=0
Determine which cell a particle id belongs to.
virtual Utils::Vector3d max_range() const =0
Range in which calculations are performed.
virtual Utils::Span< Cell *const > ghost_cells() const =0
Get pointer to local cells.
virtual GhostCommunicator const & collect_ghost_force_comm() const =0
Communicator for force reduction.
virtual GhostCommunicator const & exchange_ghosts_comm() const =0
Communicator for updating ghosts from the real particles.
virtual BoxGeometry const & box() const =0
virtual boost::optional< BoxGeometry > minimum_image_distance() const =0
Return the box geometry needed for distance calculation if minimum image convention should be used ne...
A stripped-down version of std::span from C++17.
Definition Span.hpp:38
Ghost particles and particle exchange.
Properties for a ghost communication.
Definition ghosts.hpp:157
Struct holding all information for one particle.
Definition Particle.hpp:393