Commit ac2365c9 authored by Matthieu Schaller's avatar Matthieu Schaller

Code formatting

parent 647eceac
......@@ -46,7 +46,8 @@ void chemistry_init(const struct swift_params* parameter_file,
*
* Calls chemistry_print_backend for the chosen chemistry model.
*
* @brief The #chemistry_global_data containing information about the current model.
* @brief The #chemistry_global_data containing information about the current
* model.
*/
void chemistry_print(const struct chemistry_global_data* data) {
chemistry_print_backend(data);
......@@ -60,8 +61,8 @@ void chemistry_print(const struct chemistry_global_data* data) {
*/
void chemistry_struct_dump(const struct chemistry_global_data* chemistry,
FILE* stream) {
restart_write_blocks((void*)chemistry, sizeof(struct chemistry_global_data), 1,
stream, "chemistry", "chemistry function");
restart_write_blocks((void*)chemistry, sizeof(struct chemistry_global_data),
1, stream, "chemistry", "chemistry function");
}
/**
......
......@@ -90,8 +90,8 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct chemistry_global_data* data,
struct part* restrict p, struct xpart* restrict xp) {
const struct chemistry_global_data* data, struct part* restrict p,
struct xpart* restrict xp) {
p->chemistry_data.metal_mass_fraction_total =
data->initial_metal_mass_fraction_total;
......@@ -136,9 +136,11 @@ static INLINE void chemistry_init_backend(
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @brief The #chemistry_global_data containing information about the current model.
* @brief The #chemistry_global_data containing information about the current
* model.
*/
static INLINE void chemistry_print_backend(const struct chemistry_global_data* data) {
static INLINE void chemistry_print_backend(
const struct chemistry_global_data* data) {
message("Chemistry model is 'EAGLE' tracking %d elements.",
chemistry_element_count);
......
......@@ -38,7 +38,6 @@
#include "physical_constants.h"
#include "units.h"
/**
* @brief Compute the metal mass fraction
*
......@@ -46,9 +45,10 @@
* @param xp Pointer to the extended particle data.
* @param data The global chemistry information.
*/
__attribute__((always_inline)) INLINE static float chemistry_metal_mass_fraction(
const struct part* restrict p, const struct xpart* restrict xp) {
return p->chemistry_data.Z;
__attribute__((always_inline)) INLINE static float
chemistry_metal_mass_fraction(const struct part* restrict p,
const struct xpart* restrict xp) {
return p->chemistry_data.Z;
}
/**
......@@ -136,8 +136,8 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct chemistry_global_data* data,
struct part* restrict p, struct xpart* restrict xp) {
const struct chemistry_global_data* data, struct part* restrict p,
struct xpart* restrict xp) {
p->chemistry_data.Z = data->initial_metallicity;
chemistry_init_part(p, data);
......
......@@ -43,9 +43,11 @@ chemistry_get_element_name(enum chemistry_element elem) {
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @brief The #chemistry_global_data containing information about the current model.
* @brief The #chemistry_global_data containing information about the current
* model.
*/
static INLINE void chemistry_print_backend(const struct chemistry_global_data* data) {
static INLINE void chemistry_print_backend(
const struct chemistry_global_data* data) {
message("Chemistry function is 'Gear'.");
}
......@@ -65,9 +67,8 @@ __attribute__((always_inline)) INLINE static int chemistry_read_particles(
list[0] = io_make_input_field(
"ElementAbundance", FLOAT, chemistry_element_count, OPTIONAL,
UNIT_CONV_NO_UNITS, parts, chemistry_data.metal_mass_fraction);
list[1] =
io_make_input_field("Z", FLOAT, 1, OPTIONAL, UNIT_CONV_NO_UNITS,
parts, chemistry_data.Z);
list[1] = io_make_input_field("Z", FLOAT, 1, OPTIONAL, UNIT_CONV_NO_UNITS,
parts, chemistry_data.Z);
return 2;
}
......@@ -76,12 +77,10 @@ __attribute__((always_inline)) INLINE static void chemistry_read_parameters(
const struct swift_params* parameter_file, const struct unit_system* us,
const struct phys_const* phys_const, struct chemistry_global_data* data) {
data->initial_metallicity =
parser_get_opt_param_float(parameter_file, "GearChemistry:InitialMetallicity",
-1);
data->initial_metallicity = parser_get_opt_param_float(
parameter_file, "GearChemistry:InitialMetallicity", -1);
}
/**
* @brief Specifies which particle fields to write to a dataset
*
......@@ -97,8 +96,8 @@ __attribute__((always_inline)) INLINE static int chemistry_write_particles(
list[0] = io_make_output_field(
"SmoothedElementAbundance", FLOAT, chemistry_element_count,
UNIT_CONV_NO_UNITS, parts, chemistry_data.smoothed_metal_mass_fraction);
list[1] = io_make_output_field("Z", FLOAT, 1, UNIT_CONV_NO_UNITS,
parts, chemistry_data.Z);
list[1] = io_make_output_field("Z", FLOAT, 1, UNIT_CONV_NO_UNITS, parts,
chemistry_data.Z);
list[2] = io_make_output_field("ElementAbundance", FLOAT,
chemistry_element_count, UNIT_CONV_NO_UNITS,
......@@ -126,5 +125,4 @@ __attribute__((always_inline)) INLINE static void chemistry_write_flavour(
}
#endif
#endif /* SWIFT_CHEMISTRY_IO_GEAR_H */
......@@ -66,9 +66,11 @@ static INLINE void chemistry_init_backend(
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @brief The #chemistry_global_data containing information about the current model.
* @brief The #chemistry_global_data containing information about the current
* model.
*/
static INLINE void chemistry_print_backend(const struct chemistry_global_data* data) {
static INLINE void chemistry_print_backend(
const struct chemistry_global_data* data) {
message("Chemistry function is 'No chemistry'.");
}
......@@ -98,8 +100,8 @@ __attribute__((always_inline)) INLINE static void chemistry_first_init_part(
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct chemistry_global_data* data,
const struct part* restrict p, struct xpart* restrict xp) {}
const struct chemistry_global_data* data, const struct part* restrict p,
struct xpart* restrict xp) {}
/**
* @brief Sets the chemistry properties of the (x-)particles to a valid start
......
......@@ -38,7 +38,6 @@
#include "physical_constants.h"
#include "units.h"
/**
* @brief Apply the cooling function to a particle.
*
......
......@@ -45,8 +45,8 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
*/
__attribute__((always_inline)) INLINE static int cooling_write_particles(
const struct xpart* xparts, struct io_props* list,
const struct cooling_function_data *cooling) {
const struct cooling_function_data* cooling) {
return 0;
}
#endif // SWIFT_COOLING_EAGLE_IO_H
#endif // SWIFT_COOLING_EAGLE_IO_H
......@@ -45,7 +45,6 @@
#include "physical_constants.h"
#include "units.h"
/**
* @brief Apply the cooling function to a particle.
*
......@@ -80,7 +79,7 @@ __attribute__((always_inline)) INLINE static void cooling_cool_part(
float cooling_du_dt = -cooling->cooling_rate;
/* Integrate cooling equation to enforce energy floor */
if (u_old + hydro_du_dt * dt < u_floor) {
if (u_old + hydro_du_dt * dt < u_floor) {
cooling_du_dt = 0.f;
} else if (u_old + (hydro_du_dt + cooling_du_dt) * dt < u_floor) {
cooling_du_dt = (u_old + dt * hydro_du_dt - u_floor) / dt;
......
......@@ -47,8 +47,8 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
*/
__attribute__((always_inline)) INLINE static int cooling_write_particles(
const struct xpart* xparts, struct io_props* list,
const struct cooling_function_data *cooling) {
const struct cooling_function_data* cooling) {
return 0;
}
#endif // SWIFT_COOLING_CONST_DU_IO_H
#endif // SWIFT_COOLING_CONST_DU_IO_H
......@@ -38,7 +38,6 @@
#include "physical_constants.h"
#include "units.h"
/**
* @brief Calculates du/dt in code units for a particle.
*
......
......@@ -49,8 +49,8 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
*/
__attribute__((always_inline)) INLINE static int cooling_write_particles(
const struct xpart* xparts, struct io_props* list,
const struct cooling_function_data *cooling) {
const struct cooling_function_data* cooling) {
return 0;
}
#endif // SWIFT_COOLING_CONST_LAMBDA_IO_H
#endif // SWIFT_COOLING_CONST_LAMBDA_IO_H
This diff is collapsed.
......@@ -57,74 +57,70 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
*/
__attribute__((always_inline)) INLINE static int cooling_write_particles(
const struct xpart* xparts, struct io_props* list,
const struct cooling_function_data *cooling) {
const struct cooling_function_data* cooling) {
int num = 0;
if (cooling->output_mode == 0)
return num;
if (cooling->output_mode == 0) return num;
#if COOLING_GRACKLE_MODE >= 1
/* List what we want to write */
list[0] = io_make_output_field("HI", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.HI_frac);
list[0] = io_make_output_field("HI", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.HI_frac);
list[1] = io_make_output_field("HII", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.HII_frac);
list[2] = io_make_output_field("HeI", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.HeI_frac);
list[1] = io_make_output_field("HII", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.HII_frac);
list[3] = io_make_output_field("HeII", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.HeII_frac);
list[2] = io_make_output_field("HeI", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.HeI_frac);
list[4] = io_make_output_field("HeIII", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.HeIII_frac);
list[3] = io_make_output_field("HeII", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.HeII_frac);
list[5] = io_make_output_field("e", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.e_frac);
list[4] = io_make_output_field("HeIII", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.HeIII_frac);
list[5] = io_make_output_field("e", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.e_frac);
num += 6;
#endif
if (cooling->output_mode == 1)
return num;
if (cooling->output_mode == 1) return num;
#if COOLING_GRACKLE_MODE >= 2
list += num;
list[0] = io_make_output_field("HM", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.HM_frac);
list[1] = io_make_output_field("H2I", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.H2I_frac);
list[0] = io_make_output_field("HM", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.HM_frac);
list[1] = io_make_output_field("H2I", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.H2I_frac);
list[2] = io_make_output_field("H2II", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.H2II_frac);
list[2] = io_make_output_field("H2II", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.H2II_frac);
num += 3;
#endif
if (cooling->output_mode == 2)
return num;
if (cooling->output_mode == 2) return num;
#if COOLING_GRACKLE_MODE >= 3
list += num;
list[0] = io_make_output_field("DI", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.DI_frac);
list[1] = io_make_output_field("DII", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.DII_frac);
list[0] = io_make_output_field("DI", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.DI_frac);
list[1] = io_make_output_field("DII", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.DII_frac);
list[2] = io_make_output_field("HDI", FLOAT, 1, UNIT_CONV_NO_UNITS,
xparts, cooling_data.HDI_frac);
list[2] = io_make_output_field("HDI", FLOAT, 1, UNIT_CONV_NO_UNITS, xparts,
cooling_data.HDI_frac);
num += 3;
#endif
return num;
}
/**
......@@ -146,27 +142,25 @@ __attribute__((always_inline)) INLINE static void cooling_read_parameters(
parser_get_param_double(parameter_file, "GrackleCooling:Redshift");
cooling->with_metal_cooling =
parser_get_param_int(parameter_file, "GrackleCooling:WithMetalCooling");
parser_get_param_int(parameter_file, "GrackleCooling:WithMetalCooling");
cooling->provide_volumetric_heating_rates =
parser_get_opt_param_int(parameter_file, "GrackleCooling:ProvideVolumetricHeatingRates", 0);
cooling->provide_volumetric_heating_rates = parser_get_opt_param_int(
parameter_file, "GrackleCooling:ProvideVolumetricHeatingRates", 0);
cooling->provide_specific_heating_rates =
parser_get_opt_param_int(parameter_file, "GrackleCooling:ProvideSpecificHeatingRates", 0);
cooling->provide_specific_heating_rates = parser_get_opt_param_int(
parameter_file, "GrackleCooling:ProvideSpecificHeatingRates", 0);
cooling->self_shielding_method =
parser_get_opt_param_int(parameter_file, "GrackleCooling:SelfShieldingMethod", 0);
cooling->self_shielding_method = parser_get_opt_param_int(
parameter_file, "GrackleCooling:SelfShieldingMethod", 0);
cooling->output_mode =
parser_get_opt_param_int(parameter_file, "GrackleCooling:OutputMode", 0);
cooling->max_step =
parser_get_opt_param_int(parameter_file, "GrackleCooling:MaxSteps", 10000);
parser_get_opt_param_int(parameter_file, "GrackleCooling:OutputMode", 0);
cooling->convergence_limit =
parser_get_opt_param_double(parameter_file, "GrackleCooling:ConvergenceLimit", 1e-2);
cooling->max_step = parser_get_opt_param_int(
parameter_file, "GrackleCooling:MaxSteps", 10000);
cooling->convergence_limit = parser_get_opt_param_double(
parameter_file, "GrackleCooling:ConvergenceLimit", 1e-2);
}
#endif // SWIFT_COOLING_GRACKLE_IO_H
#endif // SWIFT_COOLING_GRACKLE_IO_H
......@@ -38,7 +38,6 @@
#include "physical_constants.h"
#include "units.h"
/**
* @brief Apply the cooling function to a particle.
*
......@@ -93,8 +92,8 @@ __attribute__((always_inline)) INLINE static void cooling_first_init_part(
const struct phys_const* restrict phys_const,
const struct unit_system* restrict us,
const struct cosmology* restrict cosmo,
const struct cooling_function_data* data,
const struct part* restrict p, struct xpart* restrict xp) {}
const struct cooling_function_data* data, const struct part* restrict p,
struct xpart* restrict xp) {}
/**
* @brief Returns the total radiated energy by this particle.
......
......@@ -45,8 +45,8 @@ __attribute__((always_inline)) INLINE static void cooling_write_flavour(
*/
__attribute__((always_inline)) INLINE static int cooling_write_particles(
const struct xpart* xparts, struct io_props* list,
const struct cooling_function_data *cooling) {
const struct cooling_function_data* cooling) {
return 0;
}
#endif // SWIFT_COOLING_NONE_IO_H
#endif // SWIFT_COOLING_NONE_IO_H
......@@ -326,7 +326,9 @@ static void dumpCells_map(struct cell *c, void *data) {
/* So output local super cells that are active and have MPI
* tasks as requested. */
if (c->nodeID == e->nodeID && (!super ||((super && c->super == c) || (c->parent == NULL))) && active && mpiactive) {
if (c->nodeID == e->nodeID &&
(!super || ((super && c->super == c) || (c->parent == NULL))) &&
active && mpiactive) {
/* If requested we work out how many particles are active in this cell. */
int pactcount = 0;
......
......@@ -5202,15 +5202,18 @@ void engine_unpin() {
* @param chemistry The chemistry information.
* @param sourceterms The properties of the source terms function.
*/
void engine_init(
struct engine *e, struct space *s, const struct swift_params *params,
long long Ngas, long long Ndm, int policy, int verbose,
struct repartition *reparttype, const struct unit_system *internal_units,
const struct phys_const *physical_constants, struct cosmology *cosmo,
const struct hydro_props *hydro, struct gravity_props *gravity,
const struct external_potential *potential,
const struct cooling_function_data *cooling_func,
const struct chemistry_global_data *chemistry, struct sourceterms *sourceterms) {
void engine_init(struct engine *e, struct space *s,
const struct swift_params *params, long long Ngas,
long long Ndm, int policy, int verbose,
struct repartition *reparttype,
const struct unit_system *internal_units,
const struct phys_const *physical_constants,
struct cosmology *cosmo, const struct hydro_props *hydro,
struct gravity_props *gravity,
const struct external_potential *potential,
const struct cooling_function_data *cooling_func,
const struct chemistry_global_data *chemistry,
struct sourceterms *sourceterms) {
/* Clean-up everything */
bzero(e, sizeof(struct engine));
......@@ -5974,7 +5977,8 @@ void engine_struct_restore(struct engine *e, FILE *stream) {
e->cooling_func = cooling_func;
struct chemistry_global_data *chemistry =
(struct chemistry_global_data *)malloc(sizeof(struct chemistry_global_data));
(struct chemistry_global_data *)malloc(
sizeof(struct chemistry_global_data));
chemistry_struct_restore(chemistry, stream);
e->chemistry = chemistry;
......
......@@ -330,15 +330,18 @@ void engine_drift_top_multipoles(struct engine *e);
void engine_reconstruct_multipoles(struct engine *e);
void engine_print_stats(struct engine *e);
void engine_dump_snapshot(struct engine *e);
void engine_init(
struct engine *e, struct space *s, const struct swift_params *params,
long long Ngas, long long Ndm, int policy, int verbose,
struct repartition *reparttype, const struct unit_system *internal_units,
const struct phys_const *physical_constants, struct cosmology *cosmo,
const struct hydro_props *hydro, struct gravity_props *gravity,
const struct external_potential *potential,
const struct cooling_function_data *cooling_func,
const struct chemistry_global_data *chemistry, struct sourceterms *sourceterms);
void engine_init(struct engine *e, struct space *s,
const struct swift_params *params, long long Ngas,
long long Ndm, int policy, int verbose,
struct repartition *reparttype,
const struct unit_system *internal_units,
const struct phys_const *physical_constants,
struct cosmology *cosmo, const struct hydro_props *hydro,
struct gravity_props *gravity,
const struct external_potential *potential,
const struct cooling_function_data *cooling_func,
const struct chemistry_global_data *chemistry,
struct sourceterms *sourceterms);
void engine_config(int restart, struct engine *e,
const struct swift_params *params, int nr_nodes, int nodeID,
int nr_threads, int with_aff, int verbose,
......
......@@ -860,7 +860,7 @@ void prepare_file(struct engine* e, const char* baseName, long long N_total[6],
int periodic = e->s->periodic;
int numFiles = 1;
const struct cooling_function_data *cooling = e->cooling_func;
const struct cooling_function_data* cooling = e->cooling_func;
/* First time, we need to create the XMF file */
if (e->snapshotOutputCount == 0) xmf_create_file(baseName);
......@@ -1245,7 +1245,8 @@ void write_output_parallel(struct engine* e, const char* baseName,
Nparticles = Ngas;
hydro_write_particles(parts, xparts, list, &num_fields);
num_fields += chemistry_write_particles(parts, list + num_fields);
num_fields += cooling_write_particles(xparts, list + num_fields, cooling);
num_fields +=
cooling_write_particles(xparts, list + num_fields, cooling);
break;
case swift_type_dark_matter:
......
......@@ -744,7 +744,7 @@ void write_output_serial(struct engine* e, const char* baseName,
const struct gpart* gparts = e->s->gparts;
struct gpart* dmparts = NULL;
const struct spart* sparts = e->s->sparts;
const struct cooling_function_data *cooling = e->cooling_func;
const struct cooling_function_data* cooling = e->cooling_func;
FILE* xmfFile = 0;
/* Number of unassociated gparts */
......@@ -993,8 +993,8 @@ void write_output_serial(struct engine* e, const char* baseName,
Nparticles = Ngas;
hydro_write_particles(parts, xparts, list, &num_fields);
num_fields += chemistry_write_particles(parts, list + num_fields);
num_fields += cooling_write_particles(xparts, list + num_fields,
cooling);
num_fields +=
cooling_write_particles(xparts, list + num_fields, cooling);
break;
case swift_type_dark_matter:
......
......@@ -612,7 +612,7 @@ void write_output_single(struct engine* e, const char* baseName,
const struct gpart* gparts = e->s->gparts;
struct gpart* dmparts = NULL;
const struct spart* sparts = e->s->sparts;
const struct cooling_function_data *cooling = e->cooling_func;
const struct cooling_function_data* cooling = e->cooling_func;
/* Number of unassociated gparts */
const size_t Ndm = Ntot > 0 ? Ntot - (Ngas + Nstars) : 0;
......@@ -812,8 +812,8 @@ void write_output_single(struct engine* e, const char* baseName,
N = Ngas;
hydro_write_particles(parts, xparts, list, &num_fields);
num_fields += chemistry_write_particles(parts, list + num_fields);
num_fields += cooling_write_particles(xparts, list + num_fields,
cooling);
num_fields +=
cooling_write_particles(xparts, list + num_fields, cooling);
break;
case swift_type_dark_matter:
......
......@@ -360,7 +360,8 @@
#ifdef HAVE_SSE4_1
#define vec_blend(mask, a, b) _mm_blendv_ps(a, b, mask.v)
#else
#define vec_blend(mask, a, b) _mm_or_ps(_mm_and_ps(mask.v,b), _mm_andnot_ps(mask.v,a))
#define vec_blend(mask, a, b) \
_mm_or_ps(_mm_and_ps(mask.v, b), _mm_andnot_ps(mask.v, a))
#endif
#define vec_todbl_lo(a) _mm_cvtps_pd(a)
#define vec_todbl_hi(a) _mm_cvtps_pd(_mm_movehl_ps(a, a))
......
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