Skip to content
Snippets Groups Projects
Commit 06c31aa4 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Box-wrap the stars and black holes in the snapshots.

parent 2009adb1
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,20 @@ ...@@ -22,6 +22,20 @@
#include "black_holes_part.h" #include "black_holes_part.h"
#include "io_properties.h" #include "io_properties.h"
INLINE static void convert_bpart_pos(const struct engine *e,
const struct bpart *bp, double *ret) {
if (e->s->periodic) {
ret[0] = box_wrap(bp->x[0], 0.0, e->s->dim[0]);
ret[1] = box_wrap(bp->x[1], 0.0, e->s->dim[1]);
ret[2] = box_wrap(bp->x[2], 0.0, e->s->dim[2]);
} else {
ret[0] = bp->x[0];
ret[1] = bp->x[1];
ret[2] = bp->x[2];
}
}
/** /**
* @brief Specifies which b-particle fields to read from a dataset * @brief Specifies which b-particle fields to read from a dataset
* *
...@@ -37,8 +51,9 @@ INLINE static void black_holes_read_particles(struct bpart *bparts, ...@@ -37,8 +51,9 @@ INLINE static void black_holes_read_particles(struct bpart *bparts,
*num_fields = 5; *num_fields = 5;
/* List what we want to read */ /* List what we want to read */
list[0] = io_make_input_field("Coordinates", DOUBLE, 3, COMPULSORY, list[0] = io_make_output_field_convert_bpart(
UNIT_CONV_LENGTH, bparts, x); "Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, bparts, convert_bpart_pos);
list[1] = io_make_input_field("Velocities", FLOAT, 3, COMPULSORY, list[1] = io_make_input_field("Velocities", FLOAT, 3, COMPULSORY,
UNIT_CONV_SPEED, bparts, v); UNIT_CONV_SPEED, bparts, v);
list[2] = io_make_input_field("Masses", FLOAT, 1, COMPULSORY, UNIT_CONV_MASS, list[2] = io_make_input_field("Masses", FLOAT, 1, COMPULSORY, UNIT_CONV_MASS,
......
...@@ -22,6 +22,20 @@ ...@@ -22,6 +22,20 @@
#include "black_holes_part.h" #include "black_holes_part.h"
#include "io_properties.h" #include "io_properties.h"
INLINE static void convert_bpart_pos(const struct engine *e,
const struct bpart *bp, double *ret) {
if (e->s->periodic) {
ret[0] = box_wrap(bp->x[0], 0.0, e->s->dim[0]);
ret[1] = box_wrap(bp->x[1], 0.0, e->s->dim[1]);
ret[2] = box_wrap(bp->x[2], 0.0, e->s->dim[2]);
} else {
ret[0] = bp->x[0];
ret[1] = bp->x[1];
ret[2] = bp->x[2];
}
}
/** /**
* @brief Specifies which b-particle fields to read from a dataset * @brief Specifies which b-particle fields to read from a dataset
* *
...@@ -66,8 +80,8 @@ INLINE static void black_holes_write_particles(const struct bpart *bparts, ...@@ -66,8 +80,8 @@ INLINE static void black_holes_write_particles(const struct bpart *bparts,
*num_fields = 12; *num_fields = 12;
/* List what we want to write */ /* List what we want to write */
list[0] = io_make_output_field("Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, list[0] = io_make_output_field_convert_bpart(
bparts, x); "Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, bparts, convert_bpart_pos);
list[1] = list[1] =
io_make_output_field("Velocities", FLOAT, 3, UNIT_CONV_SPEED, bparts, v); io_make_output_field("Velocities", FLOAT, 3, UNIT_CONV_SPEED, bparts, v);
list[2] = list[2] =
......
...@@ -22,6 +22,20 @@ ...@@ -22,6 +22,20 @@
#include "io_properties.h" #include "io_properties.h"
#include "stars_part.h" #include "stars_part.h"
INLINE static void convert_spart_pos(const struct engine *e,
const struct spart *sp, double *ret) {
if (e->s->periodic) {
ret[0] = box_wrap(sp->x[0], 0.0, e->s->dim[0]);
ret[1] = box_wrap(sp->x[1], 0.0, e->s->dim[1]);
ret[2] = box_wrap(sp->x[2], 0.0, e->s->dim[2]);
} else {
ret[0] = sp->x[0];
ret[1] = sp->x[1];
ret[2] = sp->x[2];
}
}
/** /**
* @brief Specifies which s-particle fields to read from a dataset * @brief Specifies which s-particle fields to read from a dataset
* *
...@@ -64,8 +78,8 @@ INLINE static void stars_write_particles(const struct spart *sparts, ...@@ -64,8 +78,8 @@ INLINE static void stars_write_particles(const struct spart *sparts,
*num_fields = 5; *num_fields = 5;
/* List what we want to write */ /* List what we want to write */
list[0] = io_make_output_field("Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, list[0] = io_make_output_field_convert_spart(
sparts, x); "Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, sparts, convert_spart_pos);
list[1] = list[1] =
io_make_output_field("Velocities", FLOAT, 3, UNIT_CONV_SPEED, sparts, v); io_make_output_field("Velocities", FLOAT, 3, UNIT_CONV_SPEED, sparts, v);
list[2] = list[2] =
......
...@@ -23,6 +23,20 @@ ...@@ -23,6 +23,20 @@
#include "io_properties.h" #include "io_properties.h"
#include "stars_part.h" #include "stars_part.h"
INLINE static void convert_spart_pos(const struct engine *e,
const struct spart *sp, double *ret) {
if (e->s->periodic) {
ret[0] = box_wrap(sp->x[0], 0.0, e->s->dim[0]);
ret[1] = box_wrap(sp->x[1], 0.0, e->s->dim[1]);
ret[2] = box_wrap(sp->x[2], 0.0, e->s->dim[2]);
} else {
ret[0] = sp->x[0];
ret[1] = sp->x[1];
ret[2] = sp->x[2];
}
}
/** /**
* @brief Specifies which s-particle fields to read from a dataset * @brief Specifies which s-particle fields to read from a dataset
* *
...@@ -67,8 +81,8 @@ INLINE static void stars_write_particles(const struct spart *sparts, ...@@ -67,8 +81,8 @@ INLINE static void stars_write_particles(const struct spart *sparts,
*num_fields = 10; *num_fields = 10;
/* List what we want to write */ /* List what we want to write */
list[0] = io_make_output_field("Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, list[0] = io_make_output_field_convert_spart(
sparts, x); "Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH, sparts, convert_spart_pos);
list[1] = list[1] =
io_make_output_field("Velocities", FLOAT, 3, UNIT_CONV_SPEED, sparts, v); io_make_output_field("Velocities", FLOAT, 3, UNIT_CONV_SPEED, sparts, v);
list[2] = list[2] =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment