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