ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
|
Particles creation and deletion. More...
#include "Particle.hpp"
#include <utils/Vector.hpp>
#include <cstddef>
#include <span>
#include <vector>
Go to the source code of this file.
Namespaces | |
namespace | type_tracking |
Functions | |
const Particle & | get_particle_data (int p_id) |
Get particle data. | |
void | prefetch_particle_data (std::span< const int > ids) |
Fetch a range of particle into the fetch cache. | |
void | invalidate_fetch_cache () |
Invalidate the fetch cache for get_particle_data. | |
std::size_t | fetch_cache_max_size () |
Return the maximal number of particles that are kept in the fetch cache. | |
void | clear_particle_node () |
Invalidate particle_node. | |
void | make_new_particle (int p_id, Utils::Vector3d const &pos) |
Create a new particle and attach it to a cell. | |
void | set_particle_pos (int p_id, Utils::Vector3d const &pos) |
Move particle to a new position. | |
void | remove_particle (int p_id) |
Remove particle with a given identity. | |
void | remove_all_particles () |
Remove all particles. | |
void | init_type_map (int type) |
void | on_particle_type_change (int p_id, int old_type, int new_type) |
int | get_random_p_id (int type, int random_index_in_type_map) |
Find a particle of given type and return its id. | |
int | number_of_particles_with_type (int type) |
bool | particle_exists (int p_id) |
Check if particle exists. | |
int | get_particle_node (int p_id) |
Get the MPI rank which owns the a specific particle. | |
int | get_particle_node_parallel (int p_id) |
std::vector< int > | get_particle_ids () |
Get all particle ids. | |
std::vector< int > | get_particle_ids_parallel () |
int | get_maximal_particle_id () |
Get maximal particle id. | |
int | get_n_part () |
Get number of particles. | |
Variables | |
auto constexpr | type_tracking::any_type = -2 |
auto constexpr | type_tracking::new_part = -3 |
Particles creation and deletion.
This file contains everything related to particle storage and tracking.
Implementation in particle_node.cpp.
Definition in file particle_node.hpp.
void clear_particle_node | ( | ) |
Invalidate particle_node.
This has to be done at the beginning of the integration.
Definition at line 402 of file particle_node.cpp.
References max_seen_pid, and particle_node.
Referenced by System::System::on_cell_structure_change(), System::System::on_observable_calc(), and remove_all_particles().
std::size_t fetch_cache_max_size | ( | ) |
Return the maximal number of particles that are kept in the fetch cache.
Definition at line 157 of file particle_node.cpp.
References anonymous_namespace{particle_node.cpp}::particle_fetch_cache.
int get_maximal_particle_id | ( | ) |
Get maximal particle id.
Definition at line 599 of file particle_node.cpp.
References build_particle_node_parallel(), max_seen_pid, and rebuild_needed().
Referenced by ReactionMethods::ReactionAlgorithm::delete_particle(), ScriptInterface::Particles::ParticleList::do_call_method(), and ScriptInterface::Particles::ParticleHandle::do_construct().
int get_n_part | ( | ) |
Get number of particles.
Definition at line 607 of file particle_node.cpp.
References build_particle_node(), and particle_node.
Referenced by ScriptInterface::Particles::ParticleList::do_call_method().
const Particle & get_particle_data | ( | int | p_id | ) |
Get particle data.
p_id | the identity of the particle to fetch |
Definition at line 172 of file particle_node.cpp.
References Communication::MpiCallbacks::call_all(), comm_cart, get_cell_structure(), get_particle_node(), mpi_send_particle_data_local(), Communication::mpiCallbacks(), anonymous_namespace{particle_node.cpp}::particle_fetch_cache, and this_node.
Referenced by ClusterAnalysis::Cluster::center_of_mass_subcluster(), PairCriteria::PairCriterion::decide(), ScriptInterface::Particles::ParticleHandle::do_call_method(), ClusterAnalysis::Cluster::fractal_dimension(), ClusterAnalysis::Cluster::longest_distance(), ScriptInterface::Particles::ParticleHandle::ParticleHandle(), ClusterAnalysis::Cluster::radius_of_gyration_subcluster(), and ClusterAnalysis::ClusterStructure::run_for_bonded_particles().
std::vector< int > get_particle_ids | ( | ) |
Get all particle ids.
Definition at line 580 of file particle_node.cpp.
References build_particle_node(), Utils::keys(), and particle_node.
Referenced by ScriptInterface::Particles::ParticleList::do_call_method(), ScriptInterface::System::System::get_internal_state(), and ScriptInterface::System::System::set_internal_state().
std::vector< int > get_particle_ids_parallel | ( | ) |
Definition at line 590 of file particle_node.cpp.
References build_particle_node_parallel(), comm_cart, Utils::keys(), particle_node, and rebuild_needed().
Referenced by ReactionMethods::ReactionAlgorithm::setup_bookkeeping_of_empty_pids().
int get_particle_node | ( | int | p_id | ) |
Get the MPI rank which owns the a specific particle.
p_id | identity of the particle |
Definition at line 361 of file particle_node.cpp.
References build_particle_node(), and particle_node.
Referenced by get_particle_data(), mpi_get_particles(), and ScriptInterface::Particles::ParticleHandle::ParticleHandle().
int get_particle_node_parallel | ( | int | p_id | ) |
Definition at line 379 of file particle_node.cpp.
References build_particle_node_parallel(), particle_node, rebuild_needed(), and this_node.
int get_random_p_id | ( | int | type, |
int | random_index_in_type_map | ||
) |
Find a particle of given type and return its id.
Definition at line 546 of file particle_node.cpp.
References comm_cart, and particle_type_map.
Referenced by ReactionMethods::ReactionAlgorithm::displacement_mc_move(), and ReactionMethods::ReactionAlgorithm::make_reaction_attempt().
void init_type_map | ( | int | type | ) |
Definition at line 89 of file particle_node.cpp.
References comm_cart, get_cell_structure(), System::get_system(), System::System::nonbonded_ias, particle_type_map, and type_list_enable.
Referenced by ReactionMethods::ReactionAlgorithm::add_reaction(), ScriptInterface::System::System::do_call_method(), and ScriptInterface::ReactionMethods::ReactionAlgorithm::do_call_method().
void invalidate_fetch_cache | ( | ) |
Invalidate the fetch cache for get_particle_data.
Definition at line 156 of file particle_node.cpp.
References anonymous_namespace{particle_node.cpp}::particle_fetch_cache.
Referenced by System::System::on_integration_start(), and System::System::on_particle_change().
void make_new_particle | ( | int | p_id, |
Utils::Vector3d const & | pos | ||
) |
Create a new particle and attach it to a cell.
p_id | The identity of the particle to create. |
pos | The particle position. |
Definition at line 515 of file particle_node.cpp.
References build_particle_node_parallel(), comm_cart, System::get_system(), max_seen_pid, maybe_insert_particle(), mpi_synchronize_max_seen_pid_local(), System::System::on_particle_change(), particle_node, rebuild_needed(), and this_node.
int number_of_particles_with_type | ( | int | type | ) |
Definition at line 563 of file particle_node.cpp.
References particle_type_map.
Referenced by ReactionMethods::ReactionAlgorithm::all_reactant_particles_exist(), ReactionMethods::ReactionAlgorithm::displacement_mc_move(), ReactionMethods::ReactionAlgorithm::make_displacement_mc_move_attempt(), and ReactionMethods::ReactionAlgorithm::make_reaction_attempt().
void on_particle_type_change | ( | int | p_id, |
int | old_type, | ||
int | new_type | ||
) |
Definition at line 126 of file particle_node.cpp.
References add_id_to_type_map(), type_tracking::any_type, get_cell_structure(), type_tracking::new_part, particle_type_map, remove_id_from_map(), and type_list_enable.
Referenced by ReactionMethods::ReactionAlgorithm::make_reaction_attempt(), ScriptInterface::Particles::ParticleHandle::ParticleHandle(), and ReactionMethods::ReactionAlgorithm::restore_old_system_state().
bool particle_exists | ( | int | p_id | ) |
Check if particle exists.
p_id | identity of the particle |
Definition at line 574 of file particle_node.cpp.
References build_particle_node(), and particle_node.
Referenced by ScriptInterface::Particles::ParticleList::do_call_method(), and ScriptInterface::Particles::ParticleSlice::do_construct().
void prefetch_particle_data | ( | std::span< const int > | ids | ) |
Fetch a range of particle into the fetch cache.
If the range is larger than the cache size, only the particle that fit into the cache are fetched.
The particles have to exist, an exception it throw if one of the the particles can not be found.
ids | Ids of the particles that should be fetched. |
Definition at line 264 of file particle_node.cpp.
References comm_cart, mpi_get_particles(), and anonymous_namespace{particle_node.cpp}::particle_fetch_cache.
Referenced by ScriptInterface::Particles::ParticleSlice::do_call_method().
void remove_all_particles | ( | ) |
Remove all particles.
Definition at line 469 of file particle_node.cpp.
References clear_particle_node(), clear_particle_type_map(), get_cell_structure(), System::get_system(), and System::System::on_particle_change().
Referenced by ScriptInterface::Particles::ParticleList::do_call_method().
void remove_particle | ( | int | p_id | ) |
Remove particle with a given identity.
Also removes all bonds to the particle.
p_id | identity of the particle to remove |
Definition at line 476 of file particle_node.cpp.
References calculate_max_seen_id(), comm_cart, get_cell_structure(), System::get_system(), max_seen_pid, mpi_synchronize_max_seen_pid_local(), System::System::on_particle_change(), particle_node, remove_id_from_map(), this_node, and type_list_enable.
Referenced by ReactionMethods::ReactionAlgorithm::delete_particle(), and ScriptInterface::Particles::ParticleHandle::do_call_method().
void set_particle_pos | ( | int | p_id, |
Utils::Vector3d const & | pos | ||
) |
Move particle to a new position.
p_id | The identity of the particle to move. |
pos | The new particle position. |
Definition at line 533 of file particle_node.cpp.
References comm_cart, get_cell_structure(), System::get_system(), maybe_move_particle(), System::System::on_particle_change(), Cells::RESORT_GLOBAL, and this_node.
Referenced by ReactionMethods::ReactionAlgorithm::displacement_mc_move(), and ScriptInterface::Particles::ParticleHandle::ParticleHandle().