Commit 9610ab37 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Also write the gravitational potential of parts in the snapshots, not just the potential of gparts.

parent df10732a
......@@ -101,6 +101,15 @@ void convert_part_vel(const struct engine* e, const struct part* p,
ret[2] *= cosmo->a2_inv;
}
void convert_part_potential(const struct engine* e, const struct part* p,
const struct xpart* xp, float* ret) {
if (p->gpart != NULL)
ret[0] = gravity_get_comoving_potential(p->gpart);
else
ret[0] = 0.f;
}
/**
* @brief Specifies which particle fields to write to a dataset
*
......@@ -111,7 +120,7 @@ void convert_part_vel(const struct engine* e, const struct part* p,
void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
struct io_props* list, int* num_fields) {
*num_fields = 7;
*num_fields = 8;
/* List what we want to write */
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3,
......@@ -129,6 +138,9 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
UNIT_CONV_NO_UNITS, parts, id);
list[6] =
io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, parts, rho);
list[7] = io_make_output_field_convert_part("Potential", FLOAT, 1,
UNIT_CONV_POTENTIAL, parts,
xparts, convert_part_potential);
}
/**
......
......@@ -115,6 +115,15 @@ void convert_part_vel(const struct engine* e, const struct part* p,
ret[2] *= cosmo->a2_inv;
}
void convert_part_potential(const struct engine* e, const struct part* p,
const struct xpart* xp, float* ret) {
if (p->gpart != NULL)
ret[0] = gravity_get_comoving_potential(p->gpart);
else
ret[0] = 0.f;
}
/**
* @brief Specifies which particle fields to write to a dataset
*
......@@ -125,7 +134,7 @@ void convert_part_vel(const struct engine* e, const struct part* p,
void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
struct io_props* list, int* num_fields) {
*num_fields = 9;
*num_fields = 10;
/* List what we want to write */
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3,
......@@ -149,6 +158,10 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
list[8] = io_make_output_field_convert_part(
"Pressure", FLOAT, 1, UNIT_CONV_PRESSURE, parts, xparts, convert_part_P);
list[9] = io_make_output_field_convert_part("Potential", FLOAT, 1,
UNIT_CONV_POTENTIAL, parts,
xparts, convert_part_potential);
#ifdef DEBUG_INTERACTIONS_SPH
list += *num_fields;
......
......@@ -160,6 +160,15 @@ void convert_part_vel(const struct engine* e, const struct part* p,
ret[2] *= cosmo->a2_inv;
}
void convert_part_potential(const struct engine* e, const struct part* p,
const struct xpart* xp, float* ret) {
if (p->gpart != NULL)
ret[0] = gravity_get_comoving_potential(p->gpart);
else
ret[0] = 0.f;
}
/**
* @brief Specifies which particle fields to write to a dataset
*
......@@ -170,7 +179,7 @@ void convert_part_vel(const struct engine* e, const struct part* p,
void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
struct io_props* list, int* num_fields) {
*num_fields = 10;
*num_fields = 11;
/* List what we want to write */
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3,
......@@ -196,6 +205,10 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
parts, primitives.P);
list[9] = io_make_output_field_convert_part(
"TotEnergy", FLOAT, 1, UNIT_CONV_ENERGY, parts, xparts, convert_Etot);
list[10] = io_make_output_field_convert_part("Potential", FLOAT, 1,
UNIT_CONV_POTENTIAL, parts,
xparts, convert_part_potential);
}
/**
......
......@@ -129,6 +129,15 @@ void convert_part_vel(const struct engine* e, const struct part* p,
ret[2] *= cosmo->a2_inv;
}
void convert_part_potential(const struct engine* e, const struct part* p,
const struct xpart* xp, float* ret) {
if (p->gpart != NULL)
ret[0] = gravity_get_comoving_potential(p->gpart);
else
ret[0] = 0.f;
}
/**
* @brief Specifies which particle fields to write to a dataset
*
......@@ -140,7 +149,7 @@ void convert_part_vel(const struct engine* e, const struct part* p,
void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
struct io_props* list, int* num_fields) {
*num_fields = 9;
*num_fields = 10;
/* List what we want to write */
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3,
......@@ -163,6 +172,10 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
parts, xparts, convert_S);
list[8] = io_make_output_field_convert_part(
"Pressure", FLOAT, 1, UNIT_CONV_PRESSURE, parts, xparts, convert_P);
list[9] = io_make_output_field_convert_part("Potential", FLOAT, 1,
UNIT_CONV_POTENTIAL, parts,
xparts, convert_part_potential);
}
/**
......
......@@ -127,6 +127,15 @@ void convert_part_vel(const struct engine* e, const struct part* p,
ret[2] *= cosmo->a2_inv;
}
void convert_part_potential(const struct engine* e, const struct part* p,
const struct xpart* xp, float* ret) {
if (p->gpart != NULL)
ret[0] = gravity_get_comoving_potential(p->gpart);
else
ret[0] = 0.f;
}
/**
* @brief Specifies which particle fields to write to a dataset
*
......@@ -137,7 +146,7 @@ void convert_part_vel(const struct engine* e, const struct part* p,
void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
struct io_props* list, int* num_fields) {
*num_fields = 10;
*num_fields = 11;
/* List what we want to write */
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3,
......@@ -162,6 +171,9 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
"Pressure", FLOAT, 1, UNIT_CONV_PRESSURE, parts, xparts, convert_P);
list[9] = io_make_output_field("WeightedDensity", FLOAT, 1, UNIT_CONV_DENSITY,
parts, rho_bar);
list[10] = io_make_output_field_convert_part("Potential", FLOAT, 1,
UNIT_CONV_POTENTIAL, parts,
xparts, convert_part_potential);
}
/**
......
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