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

Merge branch 'sync_vr_velocities' into 'master'

Sync velocities to output time when calling Velociraptor

See merge request !1129
parents 2d16547e 130a1749
...@@ -31,9 +31,13 @@ ...@@ -31,9 +31,13 @@
#include "velociraptor_interface.h" #include "velociraptor_interface.h"
/* Local includes. */ /* Local includes. */
#include "black_holes_io.h"
#include "cooling.h" #include "cooling.h"
#include "engine.h" #include "engine.h"
#include "gravity_io.h"
#include "hydro.h" #include "hydro.h"
#include "hydro_io.h"
#include "stars_io.h"
#include "swift_velociraptor_part.h" #include "swift_velociraptor_part.h"
#include "threadpool.h" #include "threadpool.h"
#include "velociraptor_struct.h" #include "velociraptor_struct.h"
...@@ -247,12 +251,6 @@ void velociraptor_convert_particles_mapper(void *map_data, int nr_gparts, ...@@ -247,12 +251,6 @@ void velociraptor_convert_particles_mapper(void *map_data, int nr_gparts,
const struct phys_const *phys_const = e->physical_constants; const struct phys_const *phys_const = e->physical_constants;
const struct cooling_function_data *cool_func = e->cooling_func; const struct cooling_function_data *cool_func = e->cooling_func;
const float a_inv = e->cosmology->a_inv;
const int periodic = s->periodic;
const double dim[3] = {s->dim[0], s->dim[1], s->dim[2]};
const double pos_dithering[3] = {s->pos_dithering[0], s->pos_dithering[1],
s->pos_dithering[2]};
/* Convert particle properties into VELOCIraptor units. /* Convert particle properties into VELOCIraptor units.
* VELOCIraptor wants: * VELOCIraptor wants:
* - Un-dithered co-moving positions, * - Un-dithered co-moving positions,
...@@ -263,23 +261,6 @@ void velociraptor_convert_particles_mapper(void *map_data, int nr_gparts, ...@@ -263,23 +261,6 @@ void velociraptor_convert_particles_mapper(void *map_data, int nr_gparts,
*/ */
for (int i = 0; i < nr_gparts; i++) { for (int i = 0; i < nr_gparts; i++) {
if (periodic) {
swift_parts[i].x[0] =
box_wrap(gparts[i].x[0] - pos_dithering[0], 0.0, dim[0]);
swift_parts[i].x[1] =
box_wrap(gparts[i].x[1] - pos_dithering[1], 0.0, dim[1]);
swift_parts[i].x[2] =
box_wrap(gparts[i].x[2] - pos_dithering[2], 0.0, dim[2]);
} else {
swift_parts[i].x[0] = gparts[i].x[0];
swift_parts[i].x[1] = gparts[i].x[1];
swift_parts[i].x[2] = gparts[i].x[2];
}
swift_parts[i].v[0] = gparts[i].v_full[0] * a_inv;
swift_parts[i].v[1] = gparts[i].v_full[1] * a_inv;
swift_parts[i].v[2] = gparts[i].v_full[2] * a_inv;
#ifndef HAVE_VELOCIRAPTOR_WITH_NOMASS #ifndef HAVE_VELOCIRAPTOR_WITH_NOMASS
swift_parts[i].mass = gravity_get_mass(&gparts[i]); swift_parts[i].mass = gravity_get_mass(&gparts[i]);
#endif #endif
...@@ -303,28 +284,38 @@ void velociraptor_convert_particles_mapper(void *map_data, int nr_gparts, ...@@ -303,28 +284,38 @@ void velociraptor_convert_particles_mapper(void *map_data, int nr_gparts,
const struct part *p = &parts[-gparts[i].id_or_neg_offset]; const struct part *p = &parts[-gparts[i].id_or_neg_offset];
const struct xpart *xp = &xparts[-gparts[i].id_or_neg_offset]; const struct xpart *xp = &xparts[-gparts[i].id_or_neg_offset];
convert_part_pos(e, p, xp, swift_parts[i].x);
convert_part_vel(e, p, xp, swift_parts[i].v);
swift_parts[i].id = parts[-gparts[i].id_or_neg_offset].id; swift_parts[i].id = parts[-gparts[i].id_or_neg_offset].id;
swift_parts[i].u = hydro_get_drifted_physical_internal_energy(p, cosmo); swift_parts[i].u = hydro_get_drifted_physical_internal_energy(p, cosmo);
swift_parts[i].T = cooling_get_temperature(phys_const, hydro_props, us, swift_parts[i].T = cooling_get_temperature(phys_const, hydro_props, us,
cosmo, cool_func, p, xp); cosmo, cool_func, p, xp);
} break; } break;
case swift_type_stars: case swift_type_stars: {
const struct spart *sp = &sparts[-gparts[i].id_or_neg_offset];
convert_spart_pos(e, sp, swift_parts[i].x);
convert_spart_vel(e, sp, swift_parts[i].v);
swift_parts[i].id = sparts[-gparts[i].id_or_neg_offset].id; swift_parts[i].id = sparts[-gparts[i].id_or_neg_offset].id;
swift_parts[i].u = 0.f; swift_parts[i].u = 0.f;
swift_parts[i].T = 0.f; swift_parts[i].T = 0.f;
break; } break;
case swift_type_black_hole: case swift_type_black_hole: {
const struct bpart *bp = &bparts[-gparts[i].id_or_neg_offset];
convert_bpart_pos(e, bp, swift_parts[i].x);
convert_bpart_vel(e, bp, swift_parts[i].v);
swift_parts[i].id = bparts[-gparts[i].id_or_neg_offset].id; swift_parts[i].id = bparts[-gparts[i].id_or_neg_offset].id;
swift_parts[i].u = 0.f; swift_parts[i].u = 0.f;
swift_parts[i].T = 0.f; swift_parts[i].T = 0.f;
break; } break;
case swift_type_dark_matter: case swift_type_dark_matter:
convert_gpart_pos(e, &(gparts[i]), swift_parts[i].x);
convert_gpart_vel(e, &(gparts[i]), swift_parts[i].v);
swift_parts[i].id = gparts[i].id_or_neg_offset; swift_parts[i].id = gparts[i].id_or_neg_offset;
swift_parts[i].u = 0.f; swift_parts[i].u = 0.f;
swift_parts[i].T = 0.f; swift_parts[i].T = 0.f;
...@@ -332,6 +323,8 @@ void velociraptor_convert_particles_mapper(void *map_data, int nr_gparts, ...@@ -332,6 +323,8 @@ void velociraptor_convert_particles_mapper(void *map_data, int nr_gparts,
case swift_type_dark_matter_background: case swift_type_dark_matter_background:
convert_gpart_pos(e, &(gparts[i]), swift_parts[i].x);
convert_gpart_vel(e, &(gparts[i]), swift_parts[i].v);
swift_parts[i].id = gparts[i].id_or_neg_offset; swift_parts[i].id = gparts[i].id_or_neg_offset;
swift_parts[i].u = 0.f; swift_parts[i].u = 0.f;
swift_parts[i].T = 0.f; swift_parts[i].T = 0.f;
......
Markdown is supported
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