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-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 "cell_system/Cell.hpp"
23
24#include "BoxGeometry.hpp"
25#include "ghosts/HaloPlan.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 Topology-agnostic halo-exchange plan.
78 *
79 * Returns a @ref GhostComm::HaloPlan describing the ghost communication for
80 * this decomposition. All decompositions implement this.
81 */
82 virtual GhostComm::HaloPlan const *halo_plan() const = 0;
83
84 /**
85 * @brief Get pointer to local cells.
86 *
87 * Local cells are cells that contain particles
88 * that are owned by this node.
89 *
90 * @return List of local cells.
91 */
92 virtual std::span<Cell *const> local_cells() const = 0;
93
94 /**
95 * @brief Get pointer to local cells.
96 *
97 * Ghost cells are cells that contain particles
98 * that are owned by different nodes but interact
99 * with particles on this node.
100 *
101 * @return List of ghost cells.
102 */
103 virtual std::span<Cell *const> ghost_cells() const = 0;
104
105 /**
106 * @brief Determine which cell a particle id belongs to.
107 *
108 * @param p Particle to find cell for.
109 * @return Pointer to cell or nullptr if not local.
110 */
111 virtual Cell *particle_to_cell(Particle const &p) = 0;
112 virtual Cell const *particle_to_cell(Particle const &p) const = 0;
113
114 /**
115 * @brief Maximum supported cutoff.
116 */
117 virtual Utils::Vector3d max_cutoff() const = 0;
118
119 /**
120 * @brief Range in which calculations are performed.
121 */
122 virtual Utils::Vector3d max_range() const = 0;
123
124 /**
125 * @brief Return the box geometry needed for distance calculation
126 * if minimum image convention should be used needed for
127 * distance calculation.
128 */
129 virtual std::optional<BoxGeometry> minimum_image_distance() const = 0;
130
131 virtual BoxGeometry const &box() const = 0;
132
133 virtual ~ParticleDecomposition() = default;
134};
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 GhostComm::HaloPlan const * halo_plan() const =0
Topology-agnostic halo-exchange plan.
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 std::span< Cell *const > ghost_cells() const =0
Get pointer to local cells.
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
Struct holding all information for one particle.
Definition Particle.hpp:436