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