ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
particle_node.hpp File Reference

Particles creation and deletion. More...

#include "Particle.hpp"
#include <utils/Vector.hpp>
#include <cstddef>
#include <span>
#include <vector>
+ Include dependency graph for particle_node.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  type_tracking
 

Functions

const Particleget_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.
 
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
 

Detailed Description

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.

Function Documentation

◆ clear_particle_node()

void clear_particle_node ( )

Invalidate particle_node.

This has to be done at the beginning of the integration.

Definition at line 329 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 CellStructure::remove_all_particles().

◆ fetch_cache_max_size()

std::size_t fetch_cache_max_size ( )

Return the maximal number of particles that are kept in the fetch cache.

Definition at line 90 of file particle_node.cpp.

References anonymous_namespace{particle_node.cpp}::particle_fetch_cache.

◆ get_maximal_particle_id()

int get_maximal_particle_id ( )

◆ get_n_part()

int get_n_part ( )

Get number of particles.

Definition at line 479 of file particle_node.cpp.

References build_particle_node(), and particle_node.

Referenced by ScriptInterface::Particles::ParticleList::do_call_method().

◆ get_particle_data()

◆ get_particle_ids()

std::vector< int > get_particle_ids ( )

◆ get_particle_ids_parallel()

std::vector< int > get_particle_ids_parallel ( )

◆ get_particle_node()

int get_particle_node ( int  p_id)

Get the MPI rank which owns the a specific particle.

Parameters
p_ididentity of the particle
Returns
The MPI rank the particle is on.

Definition at line 288 of file particle_node.cpp.

References build_particle_node(), and particle_node.

Referenced by get_particle_data(), mpi_get_particles(), ScriptInterface::Particles::ParticleHandle::ParticleHandle(), and prefetch_particle_data().

◆ get_particle_node_parallel()

int get_particle_node_parallel ( int  p_id)

◆ invalidate_fetch_cache()

void invalidate_fetch_cache ( )

Invalidate the fetch cache for get_particle_data.

Definition at line 89 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().

◆ make_new_particle()

void make_new_particle ( int  p_id,
Utils::Vector3d const &  pos 
)

Create a new particle and attach it to a cell.

Parameters
p_idThe identity of the particle to create.
posThe particle position.

Definition at line 413 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.

Referenced by ScriptInterface::Particles::ParticleHandle::do_construct().

◆ particle_exists()

bool particle_exists ( int  p_id)

Check if particle exists.

Parameters
p_ididentity of the particle
Returns
True iff the particle exists.

Definition at line 444 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().

◆ prefetch_particle_data()

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.

Parameters
idsIds of the particles that should be fetched.

Definition at line 190 of file particle_node.cpp.

References comm_cart, get_particle_node(), mpi_get_particles(), anonymous_namespace{particle_node.cpp}::particle_fetch_cache, and this_node.

Referenced by ScriptInterface::Particles::ParticleSlice::do_call_method().

◆ remove_particle()

void remove_particle ( int  p_id)

Remove particle with a given identity.

Also removes all bonds to the particle.

Parameters
p_ididentity of the particle to remove

Definition at line 390 of file particle_node.cpp.

References calculate_max_seen_id(), get_cell_structure(), System::get_system(), max_seen_pid, mpi_synchronize_max_seen_pid_local(), System::System::on_particle_change(), particle_node, and this_node.

Referenced by ScriptInterface::Particles::ParticleHandle::do_call_method(), and ScriptInterface::Particles::ParticleHandle::do_construct().

◆ set_particle_pos()

void set_particle_pos ( int  p_id,
Utils::Vector3d const &  pos 
)

Move particle to a new position.

Parameters
p_idThe identity of the particle to move.
posThe new particle position.

Definition at line 431 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 ScriptInterface::Particles::ParticleHandle::ParticleHandle(), and ScriptInterface::Particles::set_particles_positions().