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

Add function to convert a spart to a gpart.

parent d3f2df49
......@@ -3291,8 +3291,8 @@ void cell_remove_spart(const struct engine *e, struct cell *c,
* @param p The #part to remove.
* @param xp The extended data of the particle to remove.
*/
void cell_convert_part_to_dark_matter(const struct engine *e, struct cell *c,
struct part *p, struct xpart *xp) {
void cell_convert_part_to_gpart(const struct engine *e, struct cell *c,
struct part *p, struct xpart *xp) {
/* Quick cross-check */
if (c->nodeID != e->nodeID)
......@@ -3309,6 +3309,34 @@ void cell_convert_part_to_dark_matter(const struct engine *e, struct cell *c,
}
}
/**
* @brief "Remove" a spart particle from the calculation and convert its gpart
* friend to a dark matter particle.
*
* The particle is inhibited and will officially be removed at the next rebuild.
*
* @param e The #engine running on this node.
* @param c The #cell from which to remove the particle.
* @param sp The #spart to remove.
*/
void cell_convert_spart_to_gpart(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->type = swift_type_dark_matter;
sp->gpart->id_or_neg_offset = sp->id;
} else {
error("Trying to convert part without gpart friend to dark matter!");
}
}
/**
* @brief Can we use the MM interactions fo a given pair of cells?
*
......
......@@ -622,6 +622,10 @@ 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);
void cell_convert_part_to_gpart(const struct engine *e, struct cell *c,
struct part *p, struct xpart *xp);
void cell_convert_spart_to_gpart(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,
......
......@@ -2052,7 +2052,7 @@ void runner_do_end_force(struct runner *r, struct cell *c, int timer) {
if (p->rho > 1.5e7 && e->step > 2) {
message("Removing particle id=%lld rho=%e", p->id, p->rho);
cell_remove_part(e, c, p, xp);
cell_convert_part_to_gpart(e, c, p, xp);
}
}
}
......
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