Commit 96167fb9 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Update the gpart mass when synchronizing when the star or BH mass changes.

parent 5c66158b
......@@ -30,6 +30,7 @@
/* Local headers */
#include "error.h"
#include "hydro.h"
#include "part.h"
/**
......@@ -210,6 +211,13 @@ void part_verify_links(struct part *parts, struct gpart *gparts,
part->x[1], part->x[2], gparts[k].x[0] - part->x[0],
gparts[k].x[1] - part->x[1], gparts[k].x[2] - part->x[2]);
/* Check that the particles have the same mass */
if (gparts[k].mass != hydro_get_mass(part))
error(
"Linked particles do not have the same mass!\n"
"gp->m=%e p->m=%e",
gparts[k].mass, hydro_get_mass(part));
/* Check that the particles are at the same time */
if (gparts[k].time_bin != part->time_bin)
error("Linked particles are not at the same time !");
......@@ -237,6 +245,13 @@ void part_verify_links(struct part *parts, struct gpart *gparts,
spart->x[1], spart->x[2], gparts[k].x[0] - spart->x[0],
gparts[k].x[1] - spart->x[1], gparts[k].x[2] - spart->x[2]);
/* Check that the particles have the same mass */
if (gparts[k].mass != spart->mass)
error(
"Linked particles do not have the same mass!\n"
"gp->m=%e sp->m=%e",
gparts[k].mass, spart->mass);
/* Check that the particles are at the same time */
if (gparts[k].time_bin != spart->time_bin)
error("Linked particles are not at the same time !");
......@@ -264,6 +279,13 @@ void part_verify_links(struct part *parts, struct gpart *gparts,
bpart->x[1], bpart->x[2], gparts[k].x[0] - bpart->x[0],
gparts[k].x[1] - bpart->x[1], gparts[k].x[2] - bpart->x[2]);
/* Check that the particles have the same mass */
if (gparts[k].mass != bpart->mass)
error(
"Linked particles do not have the same mass!\n"
"gp->m=%e sp->m=%e",
gparts[k].mass, bpart->mass);
/* Check that the particles are at the same time */
if (gparts[k].time_bin != bpart->time_bin)
error("Linked particles are not at the same time !");
......@@ -287,6 +309,10 @@ void part_verify_links(struct part *parts, struct gpart *gparts,
parts[k].x[2] != parts[k].gpart->x[2])
error("Linked particles are not at the same position !");
/* Check that the particles have the same mass */
if (hydro_get_mass(&parts[k]) != parts[k].gpart->mass)
error("Linked particles do not have the same mass!\n");
/* Check that the particles are at the same time */
if (parts[k].time_bin != parts[k].gpart->time_bin)
error("Linked particles are not at the same time !");
......@@ -309,6 +335,10 @@ void part_verify_links(struct part *parts, struct gpart *gparts,
sparts[k].x[2] != sparts[k].gpart->x[2])
error("Linked particles are not at the same position !");
/* Check that the particles have the same mass */
if (sparts[k].mass != sparts[k].gpart->mass)
error("Linked particles do not have the same mass!\n");
/* Check that the particles are at the same time */
if (sparts[k].time_bin != sparts[k].gpart->time_bin)
error("Linked particles are not at the same time !");
......@@ -332,6 +362,10 @@ void part_verify_links(struct part *parts, struct gpart *gparts,
bparts[k].x[2] != bparts[k].gpart->x[2])
error("Linked particles are not at the same position !");
/* Check that the particles have the same mass */
if (bparts[k].mass != bparts[k].gpart->mass)
error("Linked particles do not have the same mass!\n");
/* Check that the particles are at the same time */
if (bparts[k].time_bin != bparts[k].gpart->time_bin)
error("Linked particles are not at the same time !");
......
......@@ -3934,7 +3934,7 @@ void space_synchronize_particle_positions_mapper(void *map_data, int nr_gparts,
for (int k = 0; k < nr_gparts; k++) {
/* Get the particle */
const struct gpart *restrict gp = &gparts[k];
struct gpart *restrict gp = &gparts[k];
if (gp->type == swift_type_dark_matter)
continue;
......@@ -3953,6 +3953,8 @@ void space_synchronize_particle_positions_mapper(void *map_data, int nr_gparts,
xp->v_full[0] = gp->v_full[0];
xp->v_full[1] = gp->v_full[1];
xp->v_full[2] = gp->v_full[2];
gp->mass = p->mass;
}
else if (gp->type == swift_type_stars) {
......@@ -3964,6 +3966,8 @@ void space_synchronize_particle_positions_mapper(void *map_data, int nr_gparts,
sp->x[0] = gp->x[0];
sp->x[1] = gp->x[1];
sp->x[2] = gp->x[2];
gp->mass = sp->mass;
}
else if (gp->type == swift_type_black_hole) {
......@@ -3975,6 +3979,8 @@ void space_synchronize_particle_positions_mapper(void *map_data, int nr_gparts,
bp->x[0] = gp->x[0];
bp->x[1] = gp->x[1];
bp->x[2] = gp->x[2];
gp->mass = bp->mass;
}
}
}
......
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