diff --git a/src/cell.c b/src/cell.c index 2f5dd3db170357e8bdd90daf645d640f3bf6110f..2c5fe71c317c808b4708f85df85a066ed0af5848 100644 --- a/src/cell.c +++ b/src/cell.c @@ -3202,6 +3202,69 @@ void cell_check_timesteps(struct cell *c) { #endif } +/** + * @brief "Remove" a gas particle from the calculation. + * + * The particle is inhibited and will officially be removed at the next rebuild. + * + * @param c The #cell from which to remove the particle. + * @param p The #part to remove. + * @param xp The extended data of the particle to remove. + */ +void cell_remove_part(const struct engine *e, struct cell *c, struct part *p, + struct xpart *xp) { + + /* Quick cross-check */ + if (c->nodeID != e->nodeID) + error("Can't remove a particle in a foreign cell."); + + /* Mark the particle as inhibited */ + p->time_bin = time_bin_inhibited; + if (p->gpart) p->gpart->time_bin = time_bin_inhibited; +} + +/** + * @brief "Remove" a gravity particle from the calculation. + * + * The particle is inhibited and will officially be removed at the next rebuild. + * + * @param c The #cell from which to remove the particle. + * @param gp The #gpart to remove. + */ +void cell_remove_gpart(const struct engine *e, struct cell *c, + struct gpart *gp) { + + /* Quick cross-check */ + if (c->nodeID != e->nodeID) + error("Can't remove a particle in a foreign cell."); + + if (gp->type != swift_type_dark_matter) + error("Trying to remove a non-dark matter gpart."); + + /* Mark the particle as inhibited */ + gp->time_bin = time_bin_inhibited; +} + +/** + * @brief "Remove" a star particle from the calculation. + * + * The particle is inhibited and will officially be removed at the next rebuild. + * + * @param c The #cell from which to remove the particle. + * @param sp The #spart to remove. + */ +void cell_remove_spart(const struct engine *e, struct cell *c, + struct spart *sp) { + + /* Quick cross-check */ + if (c->nodeID != e->nodeID) + error("Can't remove a particle in a foreign cell."); + + /* Mark the particle as inhibited */ + sp->time_bin = time_bin_inhibited; + if (sp->gpart) sp->gpart->time_bin = time_bin_inhibited; +} + /** * @brief Can we use the MM interactions fo a given pair of cells? * diff --git a/src/cell.h b/src/cell.h index 852a6e97936cf5b8755fe21e6d9e7bb899ae5312..13899e559cb3d056b0d80bab9a4a1abc4da5dc07 100644 --- a/src/cell.h +++ b/src/cell.h @@ -616,6 +616,10 @@ void cell_activate_sorts(struct cell *c, int sid, struct scheduler *s); void cell_clear_drift_flags(struct cell *c, void *data); void cell_set_super_mapper(void *map_data, int num_elements, void *extra_data); int cell_has_tasks(struct cell *c); +void cell_remove_part(const struct engine *e, struct cell *c, struct part *p, + struct xpart *xp); +void cell_remove_gpart(const struct engine *e, struct cell *c, struct gpart *gp); +void cell_remove_spart(const struct engine *e, struct cell *c, struct spart *sp); int cell_can_use_pair_mm(const struct cell *ci, const struct cell *cj, const struct engine *e, const struct space *s); int cell_can_use_pair_mm_rebuild(const struct cell *ci, const struct cell *cj,