ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
particle_node.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#ifndef CORE_PARTICLE_NODE_HPP
22#define CORE_PARTICLE_NODE_HPP
23/** \file
24 * Particles creation and deletion.
25 *
26 * This file contains everything related to particle storage and tracking.
27 *
28 * Implementation in particle_node.cpp.
29 */
30
31#include "Particle.hpp"
32
33#include <utils/Span.hpp>
34#include <utils/Vector.hpp>
35
36#include <cstddef>
37#include <vector>
38
39namespace type_tracking {
40auto constexpr any_type = -2;
41auto constexpr new_part = -3;
42} // namespace type_tracking
43
44/**
45 * @brief Get particle data.
46 *
47 * @param p_id the identity of the particle to fetch
48 */
49const Particle &get_particle_data(int p_id);
50
51/**
52 * @brief Fetch a range of particle into the fetch cache.
53 *
54 *
55 * If the range is larger than the cache size, only
56 * the particle that fit into the cache are fetched.
57 *
58 * The particles have to exist, an exception it throw
59 * if one of the the particles can not be found.
60 *
61 * @param ids Ids of the particles that should be fetched.
62 */
64
65/** @brief Invalidate the fetch cache for get_particle_data. */
67
68/** @brief Return the maximal number of particles that are
69 * kept in the fetch cache.
70 */
71std::size_t fetch_cache_max_size();
72
73/** Invalidate \ref particle_node. This has to be done
74 * at the beginning of the integration.
75 */
77
78/**
79 * @brief Create a new particle and attach it to a cell.
80 * @param p_id The identity of the particle to create.
81 * @param pos The particle position.
82 */
83void make_new_particle(int p_id, Utils::Vector3d const &pos);
84
85/**
86 * @brief Move particle to a new position.
87 * @param p_id The identity of the particle to move.
88 * @param pos The new particle position.
89 */
90void set_particle_pos(int p_id, Utils::Vector3d const &pos);
91
92/** Remove particle with a given identity. Also removes all bonds to the
93 * particle.
94 * @param p_id identity of the particle to remove
95 */
96void remove_particle(int p_id);
97
98/** Remove all particles. */
100
101void init_type_map(int type);
102void on_particle_type_change(int p_id, int old_type, int new_type);
103
104/** Find a particle of given type and return its id */
105int get_random_p_id(int type, int random_index_in_type_map);
107
108/**
109 * @brief Check if particle exists.
110 *
111 * @param p_id identity of the particle
112 * @return True iff the particle exists.
113 */
114bool particle_exists(int p_id);
115
116/**
117 * @brief Get the MPI rank which owns the a specific particle.
118 *
119 * @param p_id identity of the particle
120 * @return The MPI rank the particle is on.
121 */
122int get_particle_node(int p_id);
123int get_particle_node_parallel(int p_id);
124
125/**
126 * @brief Get all particle ids.
127 *
128 * @return Sorted ids of all existing particles.
129 */
130std::vector<int> get_particle_ids();
131std::vector<int> get_particle_ids_parallel();
132
133/**
134 * @brief Get maximal particle id.
135 */
137
138/**
139 * @brief Get number of particles.
140 */
141int get_n_part();
142
143#endif
Vector implementation and trait types for boost qvm interoperability.
__shared__ int pos[MAXDEPTH *THREADS5/WARPSIZE]
A stripped-down version of std::span from C++17.
Definition Span.hpp:38
auto constexpr new_part
auto constexpr any_type
std::vector< int > get_particle_ids_parallel()
void make_new_particle(int p_id, Utils::Vector3d const &pos)
Create a new particle and attach it to a cell.
const Particle & get_particle_data(int p_id)
Get particle data.
int get_particle_node(int p_id)
Get the MPI rank which owns the a specific particle.
int number_of_particles_with_type(int type)
void set_particle_pos(int p_id, Utils::Vector3d const &pos)
Move particle to a new position.
void init_type_map(int type)
void remove_all_particles()
Remove all particles.
int get_random_p_id(int type, int random_index_in_type_map)
Find a particle of given type and return its id.
void remove_particle(int p_id)
Remove particle with a given identity.
int get_maximal_particle_id()
Get maximal particle id.
int get_particle_node_parallel(int p_id)
void prefetch_particle_data(Utils::Span< const int > ids)
Fetch a range of particle into the fetch cache.
std::vector< int > get_particle_ids()
Get all particle ids.
std::size_t fetch_cache_max_size()
Return the maximal number of particles that are kept in the fetch cache.
void invalidate_fetch_cache()
Invalidate the fetch cache for get_particle_data.
void clear_particle_node()
Invalidate particle_node.
void on_particle_type_change(int p_id, int old_type, int new_type)
int get_n_part()
Get number of particles.
bool particle_exists(int p_id)
Check if particle exists.
Struct holding all information for one particle.
Definition Particle.hpp:393