gitlab is upgraded to version 13, please report any issues and enjoy

Commit 915667fb authored by lhausamm's avatar lhausamm
Browse files

Format and few fixes

parent 2d1eb581
......@@ -465,7 +465,7 @@ int main(int argc, char *argv[]) {
char outputFieldsFileName[200];
parser_get_param_string(params, "Snapshots:FieldsFilename",
outputFieldsFileName);
outputFieldsFileName);
if (myrank == 0) {
message("Reading runtime output fields from file '%s'",
outputFieldsFileName);
......
......@@ -49,49 +49,48 @@ int chemistry_write_particles(const struct part* parts, struct io_props* list) {
/* List what we want to write */
list[0] = io_make_output_field("ElementAbundance", FLOAT,
chemistry_element_count, UNIT_CONV_NO_UNITS,
parts, chemistry_data.metal_mass_fraction, 1);
parts, chemistry_data.metal_mass_fraction);
list[1] =
io_make_output_field("SmoothedElementAbundance", FLOAT,
chemistry_element_count, UNIT_CONV_NO_UNITS, parts,
chemistry_data.smoothed_metal_mass_fraction, 1);
list[1] = io_make_output_field(
"SmoothedElementAbundance", FLOAT, chemistry_element_count,
UNIT_CONV_NO_UNITS, parts, chemistry_data.smoothed_metal_mass_fraction);
list[2] =
io_make_output_field("Metallicity", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.metal_mass_fraction_total, 1);
chemistry_data.metal_mass_fraction_total);
list[3] = io_make_output_field(
"SmoothedMetallicity", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.smoothed_metal_mass_fraction_total, 1);
chemistry_data.smoothed_metal_mass_fraction_total);
list[4] = io_make_output_field("TotalMassFromSNIa", FLOAT, 1, UNIT_CONV_MASS,
parts, chemistry_data.mass_from_SNIa, 1);
parts, chemistry_data.mass_from_SNIa);
list[5] = io_make_output_field(
"MetalMassFracFromSNIa", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.metal_mass_fraction_from_SNIa, 1);
list[5] = io_make_output_field("MetalMassFracFromSNIa", FLOAT, 1,
UNIT_CONV_NO_UNITS, parts,
chemistry_data.metal_mass_fraction_from_SNIa);
list[6] = io_make_output_field("TotalMassFromAGB", FLOAT, 1, UNIT_CONV_MASS,
parts, chemistry_data.mass_from_AGB, 1);
parts, chemistry_data.mass_from_AGB);
list[7] = io_make_output_field(
"MetalMassFracFromAGB", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.metal_mass_fraction_from_AGB, 1);
list[7] =
io_make_output_field("MetalMassFracFromAGB", FLOAT, 1, UNIT_CONV_NO_UNITS,
parts, chemistry_data.metal_mass_fraction_from_AGB);
list[8] = io_make_output_field("TotalMassFromSNII", FLOAT, 1, UNIT_CONV_MASS,
parts, chemistry_data.mass_from_SNII, 1);
parts, chemistry_data.mass_from_SNII);
list[9] = io_make_output_field(
"MetalMassFracFromSNII", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.metal_mass_fraction_from_SNII, 1);
list[9] = io_make_output_field("MetalMassFracFromSNII", FLOAT, 1,
UNIT_CONV_NO_UNITS, parts,
chemistry_data.metal_mass_fraction_from_SNII);
list[10] = io_make_output_field(
"IronMassFracFromSNIa", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.iron_mass_fraction_from_SNIa, 1);
list[10] =
io_make_output_field("IronMassFracFromSNIa", FLOAT, 1, UNIT_CONV_NO_UNITS,
parts, chemistry_data.iron_mass_fraction_from_SNIa);
list[11] = io_make_output_field(
"SmoothedIronMassFracFromSNIa", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.smoothed_iron_mass_fraction_from_SNIa, 1);
chemistry_data.smoothed_iron_mass_fraction_from_SNIa);
return 12;
}
......
......@@ -82,7 +82,7 @@ __attribute__((always_inline)) INLINE static int chemistry_write_particles(
list[2] = io_make_output_field("ElementAbundance", FLOAT,
chemistry_element_count, UNIT_CONV_NO_UNITS,
parts, chemistry_data.metal_mass_fraction, 1);
parts, chemistry_data.metal_mass_fraction);
return 3;
}
......
......@@ -815,8 +815,8 @@ void io_collect_dm_gparts(const struct gpart* const gparts, size_t Ntot,
*
* @param e The #engine
*/
void io_check_output_fields(const struct swift_params *output_fields,
const struct engine *e) {
void io_check_output_fields(const struct swift_params* output_fields,
const struct engine* e) {
if (output_fields->paramCount == 0)
error("You need to provide an output field in %s", output_fields->fileName);
......@@ -837,7 +837,6 @@ void io_check_output_fields(const struct swift_params *output_fields,
long long N_total[swift_type_count] = {
(long long)Ngas, (long long)Ndm, 0, 0, (long long)Nstars, 0};
/* get all the possible outputs */
for (int ptype = 0; ptype < swift_type_count; ptype++) {
int num_fields = 0;
......@@ -849,46 +848,43 @@ void io_check_output_fields(const struct swift_params *output_fields,
/* Write particle fields from the particle structure */
switch (ptype) {
case swift_type_gas:
hydro_write_particles(parts, xparts, list, &num_fields);
num_fields += chemistry_write_particles(parts, list + num_fields);
break;
case swift_type_gas:
hydro_write_particles(parts, xparts, list, &num_fields);
num_fields += chemistry_write_particles(parts, list + num_fields);
break;
case swift_type_dark_matter:
darkmatter_write_particles(gparts, list, &num_fields);
break;
case swift_type_dark_matter:
darkmatter_write_particles(gparts, list, &num_fields);
break;
case swift_type_star:
star_write_particles(sparts, list, &num_fields);
break;
case swift_type_star:
star_write_particles(sparts, list, &num_fields);
break;
default:
error("Particle Type %d not yet supported. Aborting", ptype);
}
default:
error("Particle Type %d not yet supported. Aborting", ptype);
}
/* loop over each parameter */
for (int param_id = 0; param_id < output_fields->paramCount; param_id++) {
const char *param_name = output_fields->data[param_id].name;
const char* param_name = output_fields->data[param_id].name;
/* skip if wrong part type */
char section_name[200];
sprintf(section_name, "PartType%i", ptype);
if (strstr(param_name, section_name) == NULL)
continue;
if (strstr(param_name, section_name) == NULL) continue;
int found = 0;
/* loop over each possible output field */
for (int field_id = 0; field_id < num_fields; field_id++) {
char field_name[256];
sprintf(field_name, "PartType%i:%s", ptype, list[field_id].name);
if (strcmp(param_name, field_name) == 0) {
found = 1;
continue;
}
char field_name[256];
sprintf(field_name, "PartType%i:%s", ptype, list[field_id].name);
if (strcmp(param_name, field_name) == 0) {
found = 1;
continue;
}
}
if (!found)
error("Unable to find field corresponding to %s", param_name);
if (!found) error("Unable to find field corresponding to %s", param_name);
}
}
}
......@@ -100,7 +100,7 @@ void io_duplicate_star_gparts(struct threadpool* tp, struct spart* const sparts,
struct gpart* const gparts, size_t Nstars,
size_t Ndm);
void io_check_output_fields(const struct swift_params *output_fields,
const struct engine *e);
void io_check_output_fields(const struct swift_params* output_fields,
const struct engine* e);
#endif /* SWIFT_COMMON_IO_H */
......@@ -111,9 +111,8 @@ __attribute__((always_inline)) INLINE static void darkmatter_write_particles(
"Velocities", FLOAT, 3, UNIT_CONV_SPEED, gparts, convert_gpart_vel);
list[2] =
io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, gparts, mass);
list[3] =
io_make_output_field("ParticleIDs", ULONGLONG, 1, UNIT_CONV_NO_UNITS,
gparts, id_or_neg_offset);
list[3] = io_make_output_field("ParticleIDs", ULONGLONG, 1,
UNIT_CONV_NO_UNITS, gparts, id_or_neg_offset);
list[4] = io_make_output_field("Potential", FLOAT, 1, UNIT_CONV_POTENTIAL,
gparts, potential);
}
......
......@@ -128,9 +128,8 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3,
UNIT_CONV_LENGTH, parts, xparts,
convert_part_pos);
list[1] =
io_make_output_field_convert_part("Velocities", FLOAT, 3, UNIT_CONV_SPEED,
parts, xparts, convert_part_vel);
list[1] = io_make_output_field_convert_part(
"Velocities", FLOAT, 3, UNIT_CONV_SPEED, parts, xparts, convert_part_vel);
list[2] =
io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, parts, mass);
list[3] = io_make_output_field("SmoothingLength", FLOAT, 1, UNIT_CONV_LENGTH,
......@@ -139,11 +138,11 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
UNIT_CONV_ENERGY_PER_UNIT_MASS, parts, u);
list[5] = io_make_output_field("ParticleIDs", ULONGLONG, 1,
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);
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);
}
/**
......
......@@ -56,22 +56,22 @@ __attribute__((always_inline)) INLINE static void hydro_read_particles(
}
__attribute__((always_inline)) INLINE static void convert_part_u(
const struct engine* e, const struct part* p,
const struct xpart* xp, float* ret) {
const struct engine* e, const struct part* p, const struct xpart* xp,
float* ret) {
ret[0] = hydro_get_comoving_internal_energy(p);
}
__attribute__((always_inline)) INLINE static void convert_part_P(
const struct engine* e, const struct part* p,
const struct xpart* xp, float* ret) {
const struct engine* e, const struct part* p, const struct xpart* xp,
float* ret) {
ret[0] = hydro_get_comoving_pressure(p);
}
__attribute__((always_inline)) INLINE static void convert_part_pos(
const struct engine* e, const struct part* p,
const struct xpart* xp, double* ret) {
const struct engine* e, const struct part* p, const struct xpart* xp,
double* ret) {
if (e->s->periodic) {
ret[0] = box_wrap(p->x[0], 0.0, e->s->dim[0]);
......@@ -85,8 +85,8 @@ __attribute__((always_inline)) INLINE static void convert_part_pos(
}
__attribute__((always_inline)) INLINE static void convert_part_vel(
const struct engine* e, const struct part* p,
const struct xpart* xp, float* ret) {
const struct engine* e, const struct part* p, const struct xpart* xp,
float* ret) {
const int with_cosmology = (e->policy & engine_policy_cosmology);
const struct cosmology* cosmo = e->cosmology;
......@@ -120,8 +120,8 @@ __attribute__((always_inline)) INLINE static void convert_part_vel(
}
__attribute__((always_inline)) INLINE static void convert_part_potential(
const struct engine* e, const struct part* p,
const struct xpart* xp, float* ret) {
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);
......@@ -137,8 +137,8 @@ __attribute__((always_inline)) INLINE static void convert_part_potential(
* @param num_fields The number of i/o fields to write.
*/
__attribute__((always_inline)) INLINE static void hydro_write_particles(
const struct part* parts, const struct xpart* xparts,
struct io_props* list, int* num_fields) {
const struct part* parts, const struct xpart* xparts, struct io_props* list,
int* num_fields) {
*num_fields = 10;
......@@ -146,9 +146,8 @@ __attribute__((always_inline)) INLINE static void hydro_write_particles(
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3,
UNIT_CONV_LENGTH, parts, xparts,
convert_part_pos);
list[1] =
io_make_output_field_convert_part("Velocities", FLOAT, 3, UNIT_CONV_SPEED,
parts, xparts, convert_part_vel);
list[1] = io_make_output_field_convert_part(
"Velocities", FLOAT, 3, UNIT_CONV_SPEED, parts, xparts, convert_part_vel);
list[2] =
io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, parts, mass);
list[3] = io_make_output_field("SmoothingLength", FLOAT, 1, UNIT_CONV_LENGTH,
......@@ -157,18 +156,17 @@ __attribute__((always_inline)) INLINE static void hydro_write_particles(
"Entropy", FLOAT, 1, UNIT_CONV_ENTROPY_PER_UNIT_MASS, parts, entropy);
list[5] = io_make_output_field("ParticleIDs", ULONGLONG, 1,
UNIT_CONV_NO_UNITS, parts, id);
list[6] = io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, parts,
rho);
list[6] =
io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, parts, rho);
list[7] = io_make_output_field_convert_part("InternalEnergy", FLOAT, 1,
UNIT_CONV_ENERGY_PER_UNIT_MASS,
parts, xparts, convert_part_u);
list[8] = io_make_output_field_convert_part("Pressure", FLOAT, 1,
UNIT_CONV_PRESSURE, parts, xparts,
convert_part_P);
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);
list[9] = io_make_output_field_convert_part("Potential", FLOAT, 1,
UNIT_CONV_POTENTIAL, parts,
xparts, convert_part_potential);
#ifdef DEBUG_INTERACTIONS_SPH
......@@ -193,7 +191,8 @@ __attribute__((always_inline)) INLINE static void hydro_write_particles(
* @brief Writes the current model of SPH to the file
* @param h_grpsph The HDF5 group in which to write
*/
__attribute__((always_inline)) INLINE static void hydro_write_flavour(hid_t h_grpsph) {
__attribute__((always_inline)) INLINE static void hydro_write_flavour(
hid_t h_grpsph) {
/* Viscosity and thermal conduction */
io_write_attribute_s(h_grpsph, "Thermal Conductivity Model",
......
......@@ -185,9 +185,8 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3,
UNIT_CONV_LENGTH, parts, xparts,
convert_part_pos);
list[1] =
io_make_output_field_convert_part("Velocities", FLOAT, 3, UNIT_CONV_SPEED,
parts, xparts, convert_part_vel);
list[1] = io_make_output_field_convert_part(
"Velocities", FLOAT, 3, UNIT_CONV_SPEED, parts, xparts, convert_part_vel);
list[2] = io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, parts,
conserved.mass);
......@@ -207,9 +206,9 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
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);
list[10] = io_make_output_field_convert_part("Potential", FLOAT, 1,
UNIT_CONV_POTENTIAL, parts,
xparts, convert_part_potential);
}
/**
......
......@@ -155,9 +155,8 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3,
UNIT_CONV_LENGTH, parts, xparts,
convert_part_pos);
list[1] =
io_make_output_field_convert_part("Velocities", FLOAT, 3, UNIT_CONV_SPEED,
parts, xparts, convert_part_vel);
list[1] = io_make_output_field_convert_part(
"Velocities", FLOAT, 3, UNIT_CONV_SPEED, parts, xparts, convert_part_vel);
list[2] =
io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, parts, mass);
list[3] = io_make_output_field("SmoothingLength", FLOAT, 1, UNIT_CONV_LENGTH,
......@@ -166,17 +165,17 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
UNIT_CONV_ENERGY_PER_UNIT_MASS, parts, u);
list[5] = io_make_output_field("ParticleIDs", ULONGLONG, 1,
UNIT_CONV_NO_UNITS, parts, id);
list[6] = io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, parts,
rho);
list[6] =
io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, parts, rho);
list[7] = io_make_output_field_convert_part("Entropy", FLOAT, 1,
UNIT_CONV_ENTROPY_PER_UNIT_MASS,
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);
list[9] = io_make_output_field_convert_part("Potential", FLOAT, 1,
UNIT_CONV_POTENTIAL, parts,
xparts, convert_part_potential);
}
/**
......
......@@ -152,9 +152,8 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
list[0] = io_make_output_field_convert_part("Coordinates", DOUBLE, 3,
UNIT_CONV_LENGTH, parts, xparts,
convert_part_pos);
list[1] =
io_make_output_field_convert_part("Velocities", FLOAT, 3, UNIT_CONV_SPEED,
parts, xparts, convert_part_vel);
list[1] = io_make_output_field_convert_part(
"Velocities", FLOAT, 3, UNIT_CONV_SPEED, parts, xparts, convert_part_vel);
list[2] =
io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, parts, mass);
list[3] = io_make_output_field("SmoothingLength", FLOAT, 1, UNIT_CONV_LENGTH,
......@@ -163,8 +162,8 @@ void hydro_write_particles(const struct part* parts, const struct xpart* xparts,
"Entropy", FLOAT, 1, UNIT_CONV_ENTROPY_PER_UNIT_MASS, parts, entropy);
list[5] = io_make_output_field("ParticleIDs", ULONGLONG, 1,
UNIT_CONV_NO_UNITS, parts, id);
list[6] = io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, parts,
rho);
list[6] =
io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, parts, rho);
list[7] = io_make_output_field_convert_part("InternalEnergy", FLOAT, 1,
UNIT_CONV_ENERGY_PER_UNIT_MASS,
parts, xparts, convert_u);
......@@ -172,9 +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);
list[10] = io_make_output_field_convert_part("Potential", FLOAT, 1,
UNIT_CONV_POTENTIAL, parts,
xparts, convert_part_potential);
}
/**
......
......@@ -97,7 +97,6 @@ struct io_props {
/* Conversion function for gpart */
conversion_func_gpart_float convert_gpart_f;
conversion_func_gpart_double convert_gpart_d;
};
/**
......@@ -147,7 +146,7 @@ INLINE static struct io_props io_make_input_field_(
/**
* @brief Constructs an #io_props from its parameters
*/
#define io_make_output_field(name, type, dim, units, part, field) \
#define io_make_output_field(name, type, dim, units, part, field) \
io_make_output_field_(name, type, dim, units, (char*)(&(part[0]).field), \
sizeof(part[0]))
......@@ -189,10 +188,9 @@ INLINE static struct io_props io_make_output_field_(
* @brief Constructs an #io_props (with conversion) from its parameters
*/
#define io_make_output_field_convert_part(name, type, dim, units, part, xpart, \
convert) \
io_make_output_field_convert_part_##type(name, type, dim, units, \
sizeof(part[0]), part, xpart, \
convert)
convert) \
io_make_output_field_convert_part_##type( \
name, type, dim, units, sizeof(part[0]), part, xpart, convert)
/**
* @brief Construct an #io_props from its parameters
......@@ -277,9 +275,9 @@ INLINE static struct io_props io_make_output_field_convert_part_DOUBLE(
/**
* @brief Constructs an #io_props (with conversion) from its parameters
*/
#define io_make_output_field_convert_gpart(name, type, dim, units, gpart, \
convert) \
io_make_output_field_convert_gpart_##type(name, type, dim, units, \
#define io_make_output_field_convert_gpart(name, type, dim, units, gpart, \
convert) \
io_make_output_field_convert_gpart_##type(name, type, dim, units, \
sizeof(gpart[0]), gpart, convert)
/**
......
......@@ -61,8 +61,8 @@ __attribute__((always_inline)) INLINE static void star_write_particles(
/* List what we want to read */
list[0] = io_make_output_field("Coordinates", DOUBLE, 3, UNIT_CONV_LENGTH,
sparts, x);
list[1] = io_make_output_field("Velocities", FLOAT, 3, UNIT_CONV_SPEED,
sparts, v);
list[1] =
io_make_output_field("Velocities", FLOAT, 3, UNIT_CONV_SPEED, sparts, v);
list[2] =
io_make_output_field("Masses", FLOAT, 1, UNIT_CONV_MASS, sparts, mass);
list[3] = io_make_output_field("ParticleIDs", LONGLONG, 1, UNIT_CONV_NO_UNITS,
......
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