diff --git a/src/debug.c b/src/debug.c index d2fdf7c124100a87939e83fc302ab701a507805f..2be981175eabe41a8a7e57aec4261a9b38def6ac 100644 --- a/src/debug.c +++ b/src/debug.c @@ -38,7 +38,6 @@ #error "Invalid choice of SPH variant" #endif - /** * @brief Looks for the particle with the given id and prints its information to *the standard output. diff --git a/src/hydro/Default/hydro.h b/src/hydro/Default/hydro.h index cca09937cba4ae246814bf29bb4c05d5c0866685..412a4e4a96281f8c5bf3713b2482abc67ce10362 100644 --- a/src/hydro/Default/hydro.h +++ b/src/hydro/Default/hydro.h @@ -31,9 +31,9 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep( const float dt_cfl = 2.f * const_cfl * kernel_gamma * p->h / p->force.v_sig; /* Limit change in u */ - const float dt_u_change = (p->force.u_dt != 0.0f) - ? fabsf(const_max_u_change * p->u / p->force.u_dt) - : FLT_MAX; + const float dt_u_change = + (p->force.u_dt != 0.0f) ? fabsf(const_max_u_change * p->u / p->force.u_dt) + : FLT_MAX; return fminf(dt_cfl, dt_u_change); } @@ -48,7 +48,8 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep( * @param xp The extended particle data to act upon */ __attribute__((always_inline)) -INLINE static void hydro_first_init_part(struct part* p, struct xpart* xp) {} + INLINE static void hydro_first_init_part(struct part* p, struct xpart* xp) { +} /** * @brief Prepares a particle for the density calculation. @@ -106,8 +107,8 @@ __attribute__((always_inline)) * @param xp The extended particle data to act upon * @param time The current time */ -__attribute__((always_inline)) -INLINE static void hydro_prepare_force(struct part* p, struct xpart* xp, float time) { +__attribute__((always_inline)) INLINE static void hydro_prepare_force( + struct part* p, struct xpart* xp, float time) { /* Some smoothing length multiples. */ const float h = p->h; @@ -206,15 +207,13 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra( __attribute__((always_inline)) INLINE static void hydro_end_force(struct part* p) {} - - /** * @brief Kick the additional variables * * @param p The particle to act upon */ __attribute__((always_inline)) - INLINE static void hydro_kick_extra(struct part* p, float dt) {} + INLINE static void hydro_kick_extra(struct part* p, float dt) {} /** * @brief Converts hydro quantity of a particle diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index 2236ab6955839ae3281fe39786d371db5644799c..b25879af4ccfa5ee4da890abb5e371e57ce84409 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -28,9 +28,9 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep( struct part* p, struct xpart* xp) { /* Acceleration */ - float ac = sqrtf(p->a_hydro[0] * p->a_hydro[0] + - p->a_hydro[1] * p->a_hydro[1] + - p->a_hydro[2] * p->a_hydro[2]); + float ac = + sqrtf(p->a_hydro[0] * p->a_hydro[0] + p->a_hydro[1] * p->a_hydro[1] + + p->a_hydro[2] * p->a_hydro[2]); ac = fmaxf(ac, 1e-30); const float dt_accel = sqrtf(2.f); // MATTHIEU @@ -51,7 +51,8 @@ __attribute__((always_inline)) INLINE static float hydro_compute_timestep( * @param xp The extended particle data to act upon */ __attribute__((always_inline)) -INLINE static void hydro_first_init_part(struct part* p, struct xpart* xp) {} + INLINE static void hydro_first_init_part(struct part* p, struct xpart* xp) { +} /** * @brief Prepares a particle for the density calculation. @@ -103,7 +104,7 @@ __attribute__((always_inline)) p->density.wcount_dh *= ih * (4.0f / 3.0f * M_PI * kernel_gamma3); const float irho = 1.f / p->rho; - + /* Compute the derivative term */ p->rho_dh = 1.f / (1.f + 0.33333333f * p->h * p->rho_dh * irho); @@ -125,14 +126,13 @@ __attribute__((always_inline)) * @param xp The extended particle data to act upon * @param time The current time */ -__attribute__((always_inline)) -INLINE static void hydro_prepare_force(struct part* p, struct xpart* xp, float time) { +__attribute__((always_inline)) INLINE static void hydro_prepare_force( + struct part* p, struct xpart* xp, float time) { /* Compute the norm of the curl */ p->force.curl_v = sqrtf(p->density.rot_v[0] * p->density.rot_v[0] + - p->density.rot_v[1] * p->density.rot_v[1] + - p->density.rot_v[2] * p->density.rot_v[2]); - + p->density.rot_v[1] * p->density.rot_v[1] + + p->density.rot_v[2] * p->density.rot_v[2]); /* Compute the pressure */ const float dt = time - 0.5f * (p->t_begin + p->t_end); @@ -202,7 +202,6 @@ __attribute__((always_inline)) (const_hydro_gamma - 1.f) * powf(p->rho, -(const_hydro_gamma - 1.f)); } - /** * @brief Kick the additional variables * @@ -211,16 +210,15 @@ __attribute__((always_inline)) * @param dt The time-step for this kick * @param half_dt The half time-step for this kick */ -__attribute__((always_inline)) - INLINE static void hydro_kick_extra(struct part* p, struct xpart* xp, - float dt, float half_dt) { +__attribute__((always_inline)) INLINE static void hydro_kick_extra( + struct part* p, struct xpart* xp, float dt, float half_dt) { /* Do not decrease the entropy (temperature) by more than a factor of 2*/ const float entropy_change = p->entropy_dt * dt; if (entropy_change > -0.5f * p->entropy) p->entropy += entropy_change; else - p->entropy *= 0.5f; + p->entropy *= 0.5f; /* Do not 'overcool' when timestep increases */ if (p->entropy + 0.5f * p->entropy_dt * dt < 0.5f * p->entropy) @@ -238,5 +236,5 @@ __attribute__((always_inline)) INLINE static void hydro_convert_quantities(struct part* p) { p->entropy = (const_hydro_gamma - 1.f) * p->entropy * - powf(p->rho, -(const_hydro_gamma - 1.f)); + powf(p->rho, -(const_hydro_gamma - 1.f)); } diff --git a/src/hydro/Gadget2/hydro_debug.h b/src/hydro/Gadget2/hydro_debug.h index d8ee7c161c8f7a4d9135bd37d739138970cc3bf2..5ac83e227c3b59595a045ea9fb0474671ee5df92 100644 --- a/src/hydro/Gadget2/hydro_debug.h +++ b/src/hydro/Gadget2/hydro_debug.h @@ -29,9 +29,8 @@ __attribute__((always_inline)) "v_sig=%e dh/dt=%.3e t_begin=%.3e, t_end=%.3e\n", p->x[0], p->x[1], p->x[2], p->v[0], p->v[1], p->v[2], xp->v_full[0], xp->v_full[1], xp->v_full[2], p->a_hydro[0], p->a_hydro[1], p->a_hydro[2], - p->h, (int)p->density.wcount, p->mass, p->rho_dh, p->rho, p->force.pressure, - p->entropy, p->entropy_dt, p->force.soundspeed, - p->div_v, p->force.curl_v, p->density.rot_v[0], - p->density.rot_v[1], p->density.rot_v[2], p->force.v_sig, p->h_dt, - p->t_begin, p->t_end); + p->h, (int)p->density.wcount, p->mass, p->rho_dh, p->rho, + p->force.pressure, p->entropy, p->entropy_dt, p->force.soundspeed, + p->div_v, p->force.curl_v, p->density.rot_v[0], p->density.rot_v[1], + p->density.rot_v[2], p->force.v_sig, p->h_dt, p->t_begin, p->t_end); } diff --git a/src/hydro/Gadget2/hydro_part.h b/src/hydro/Gadget2/hydro_part.h index 777495035881d295b1958c8e62db19dd8c0c9723..41898513aadddf7a7f7f5f6acb7516af6ecad1f4 100644 --- a/src/hydro/Gadget2/hydro_part.h +++ b/src/hydro/Gadget2/hydro_part.h @@ -17,7 +17,6 @@ * ******************************************************************************/ - /* Extra particle data not needed during the SPH loops over neighbours. */ struct xpart { @@ -26,7 +25,7 @@ struct xpart { /* Velocity at the last full step. */ float v_full[3]; - + } __attribute__((aligned(xpart_align))); /* Data of a single particle. */ @@ -65,43 +64,42 @@ struct part { /* Entropy time derivative */ float entropy_dt; - + /* Particle mass. */ float mass; - - union{ - + + union { + struct { /* Number of neighbours */ float wcount; - + /* Number of neighbours spatial derivative */ float wcount_dh; - + /* Velocity curl components */ float rot_v[3]; - + } density; struct { - + /* Velocity curl norm*/ float curl_v; /* Signal velocity */ float v_sig; - + /* Particle pressure */ float pressure; /* Particle sound speed */ float soundspeed; - + } force; - }; - + /* Velocity divergence */ float div_v; diff --git a/src/hydro/Minimal/hydro_iact.h b/src/hydro/Minimal/hydro_iact.h index b8a21b4bb0720a5889a8f8dabbb42714bf285327..6afb9d8d38a4fc7f1d38b7286720ddb7f3c51ab4 100644 --- a/src/hydro/Minimal/hydro_iact.h +++ b/src/hydro/Minimal/hydro_iact.h @@ -28,8 +28,8 @@ /** * @brief Minimal conservative implementation of SPH * - * The thermal variable is the internal energy (u). No viscosity nor - * thermal conduction terms are implemented. + * The thermal variable is the internal energy (u). No viscosity nor + * thermal conduction terms are implemented. */ /** diff --git a/src/serial_io.c b/src/serial_io.c index ebb7eee68882766c5f550cda7feee1d9b68ab5cc..481a82c4977310aa28b94bfc543f1acbf8b90f35 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -241,10 +241,10 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile, char* name, * * Calls #error() if an error occurs. */ -void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name, - enum DATA_TYPE type, int N, int dim, long long N_total, - int mpi_rank, long long offset, char* part_c, - struct UnitSystem* us, +void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name, + enum DATA_TYPE type, int N, int dim, long long N_total, + int mpi_rank, long long offset, char* part_c, + struct UnitSystem* us, enum UnitConversionFactor convFactor) { hid_t h_data = 0, h_err = 0, h_memspace = 0, h_filespace = 0; @@ -259,11 +259,10 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name, /* message("Writing '%s' array...", name); */ /* Prepare the arrays in the file */ - if(mpi_rank == 0) - prepareArray(grp, fileName, xmfFile, name, type, N_total, dim, - us, convFactor); + if (mpi_rank == 0) + prepareArray(grp, fileName, xmfFile, name, type, N_total, dim, us, + convFactor); - /* Allocate temporary buffer */ temp = malloc(N * dim * sizeOfType(type)); if (temp == NULL) error("Unable to allocate memory for temporary buffer"); @@ -359,9 +358,9 @@ void writeArrayBackEnd(hid_t grp, char* fileName, FILE* xmfFile, char* name, */ #define writeArray(grp, fileName, xmfFile, name, type, N, dim, part, N_total, \ mpi_rank, offset, field, us, convFactor) \ - writeArrayBackEnd(grp, fileName, xmfFile, name, type, N, dim, N_total, \ - mpi_rank, offset, (char*)(&(part[0]).field), \ - us, convFactor) + writeArrayBackEnd(grp, fileName, xmfFile, name, type, N, dim, N_total, \ + mpi_rank, offset, (char*)(&(part[0]).field), us, \ + convFactor) /* Import the right hydro definition */ #include "hydro_io.h" @@ -639,8 +638,8 @@ void write_output_serial(struct engine* e, struct UnitSystem* us, int mpi_rank, error("Error while opening particle group on rank %d.\n", mpi_rank); /* Write particle fields from the particle structure */ - hydro_write_particles(h_grp, fileName, xmfFile, N, N_total, mpi_rank, offset, - parts, us); + hydro_write_particles(h_grp, fileName, xmfFile, N, N_total, mpi_rank, + offset, parts, us); /* Close particle group */ H5Gclose(h_grp);