Commit eec60d76 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added functions to remove a part/gpart/spart from a cell.

parent 91b56f3b
......@@ -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?
*
......
......@@ -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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment