Skip to content
Snippets Groups Projects
Commit c18d56e1 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Format

parent cb14197c
No related branches found
No related tags found
1 merge request!885Gear merge pressure floor and GEAR star formation
......@@ -545,7 +545,6 @@ pow_three_gamma_minus_five_over_two(float x) {
#endif
}
/**
* @brief Return the argument to the power three (adiabatic index - 1).
*
......
......@@ -390,7 +390,8 @@ hydro_set_drifted_physical_internal_energy(struct part *p,
/* Compute the pressure */
float comoving_pressure = gas_pressure_from_entropy(p->rho, p->entropy);
comoving_pressure = pressure_floor_get_comoving_pressure(p, comoving_pressure, cosmo);
comoving_pressure =
pressure_floor_get_comoving_pressure(p, comoving_pressure, cosmo);
/* Compute the sound speed */
const float soundspeed =
......@@ -595,7 +596,8 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
/* Compute the pressure */
float comoving_pressure = gas_pressure_from_entropy(p->rho, p->entropy);
comoving_pressure = pressure_floor_get_comoving_pressure(p, comoving_pressure, cosmo);
comoving_pressure =
pressure_floor_get_comoving_pressure(p, comoving_pressure, cosmo);
/* Compute the sound speed */
const float soundspeed =
......@@ -673,7 +675,8 @@ __attribute__((always_inline)) INLINE static void hydro_reset_predicted_values(
/* Re-compute the pressure */
float comoving_pressure = gas_pressure_from_entropy(p->rho, p->entropy);
comoving_pressure = pressure_floor_get_comoving_pressure(p, comoving_pressure, cosmo);
comoving_pressure =
pressure_floor_get_comoving_pressure(p, comoving_pressure, cosmo);
/* Compute the new sound speed */
const float soundspeed =
......@@ -740,7 +743,8 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
/* Re-compute the pressure */
float comoving_pressure = gas_pressure_from_entropy(p->rho, p->entropy);
comoving_pressure = pressure_floor_get_comoving_pressure(p, comoving_pressure, cosmo);
comoving_pressure =
pressure_floor_get_comoving_pressure(p, comoving_pressure, cosmo);
/* Compute the new sound speed */
const float soundspeed =
......@@ -852,7 +856,8 @@ __attribute__((always_inline)) INLINE static void hydro_convert_quantities(
/* Compute the pressure */
float comoving_pressure = gas_pressure_from_entropy(p->rho, p->entropy);
comoving_pressure = pressure_floor_get_comoving_pressure(p, comoving_pressure, cosmo);
comoving_pressure =
pressure_floor_get_comoving_pressure(p, comoving_pressure, cosmo);
/* Compute the sound speed */
const float soundspeed =
......
......@@ -501,7 +501,7 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration(
*/
__attribute__((always_inline)) INLINE static void hydro_reset_predicted_values(
struct part* restrict p, const struct xpart* restrict xp,
const struct cosmology *cosmo) {
const struct cosmology* cosmo) {
// MATTHIEU: Do we need something here?
}
......
......@@ -543,7 +543,7 @@ __attribute__((always_inline)) INLINE static void hydro_reset_gradient(
*/
__attribute__((always_inline)) INLINE static void hydro_reset_predicted_values(
struct part* restrict p, const struct xpart* restrict xp,
const struct cosmology *cosmo) {
const struct cosmology* cosmo) {
// MATTHIEU: Apply the entropy floor here.
}
......
......@@ -212,21 +212,19 @@ hydro_get_drifted_physical_entropy(const struct part *restrict p,
return gas_entropy_from_internal_energy(p->rho, p->u);
}
/**
* @brief Update the sound speed of a particle
*
* @param p The particle of interest.
* @param cosmo The cosmological model.
*/
__attribute__((always_inline)) INLINE static void
hydro_update_soundspeed(struct part *restrict p,
const struct cosmology *cosmo) {
__attribute__((always_inline)) INLINE static void hydro_update_soundspeed(
struct part *restrict p, const struct cosmology *cosmo) {
/* Compute the sound speed -- see theory section for justification */
/* IDEAL GAS ONLY -- P-U does not work with generic EoS. */
const float comoving_pressure =
pressure_floor_get_comoving_pressure(p, p->pressure_bar, cosmo);
pressure_floor_get_comoving_pressure(p, p->pressure_bar, cosmo);
p->force.soundspeed = sqrtf(hydro_gamma * comoving_pressure / p->rho);
}
......@@ -656,7 +654,7 @@ __attribute__((always_inline)) INLINE static void hydro_prepare_force(
/* Get the pressures */
const float comoving_pressure_with_floor =
pressure_floor_get_comoving_pressure(p, p->pressure_bar, cosmo);
pressure_floor_get_comoving_pressure(p, p->pressure_bar, cosmo);
/* Update variables. */
p->force.f = grad_h_term;
......@@ -774,7 +772,7 @@ __attribute__((always_inline)) INLINE static void hydro_predict_extra(
/* update the required variables */
const float comoving_pressure_with_floor =
pressure_floor_get_comoving_pressure(p, p->pressure_bar, cosmo);
pressure_floor_get_comoving_pressure(p, p->pressure_bar, cosmo);
p->force.pressure_bar_with_floor = comoving_pressure_with_floor;
}
......
......@@ -401,7 +401,7 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration(
*/
__attribute__((always_inline)) INLINE static void hydro_reset_predicted_values(
struct part* restrict p, const struct xpart* restrict xp,
const struct cosmology *cosmo) {}
const struct cosmology* cosmo) {}
/**
* @brief Converts the hydrodynamic variables from the initial condition file to
......@@ -799,7 +799,7 @@ __attribute__((always_inline)) INLINE static float hydro_get_comoving_density(
*/
__attribute__((always_inline)) INLINE static float
hydro_get_physical_internal_energy(const struct part* restrict p,
const struct xpart *restrict xp,
const struct xpart* restrict xp,
const struct cosmology* cosmo) {
return cosmo->a_factor_internal_energy *
......@@ -903,7 +903,7 @@ hydro_get_drifted_physical_internal_energy(const struct part* p,
*/
__attribute__((always_inline)) INLINE static float
hydro_get_drifted_physical_entropy(const struct part* p,
const struct cosmology* cosmo) {
const struct cosmology* cosmo) {
error("Need implementing");
return 0;
......
......@@ -143,7 +143,7 @@ INLINE static void hydro_write_particles(const struct part* parts,
convert_part_pos, "Co-moving positions of the particles");
list[1] = io_make_output_field(
"Velocities", FLOAT, 3, UNIT_CONV_SPEED, 0.f, parts, primitives.v,
"Velocities", FLOAT, 3, UNIT_CONV_SPEED, 0.f, parts, primitives.v,
"Peculiar velocities of the stars. This is (a * dx/dt) where x is the "
"co-moving positions of the particles");
......
......@@ -20,10 +20,12 @@
#define SWIFT_PRESSURE_FLOOR_GEAR_H
/* Forward declaration */
__attribute__((always_inline)) static INLINE float pressure_floor_get_comoving_pressure(
const struct part* p, const float pressure, const struct cosmology *cosmo);
__attribute__((always_inline)) static INLINE float pressure_floor_get_physical_pressure(
const struct part* p, const float pressure, const struct cosmology *cosmo);
__attribute__((always_inline)) static INLINE float
pressure_floor_get_comoving_pressure(const struct part* p, const float pressure,
const struct cosmology* cosmo);
__attribute__((always_inline)) static INLINE float
pressure_floor_get_physical_pressure(const struct part* p, const float pressure,
const struct cosmology* cosmo);
#include "adiabatic_index.h"
#include "cosmology.h"
......@@ -63,15 +65,17 @@ struct pressure_floor_properties {
*
* @return The physical pressure with the floor.
*/
__attribute__((always_inline)) static INLINE float pressure_floor_get_physical_pressure(
const struct part* p, const float pressure_physical, const struct cosmology *cosmo) {
__attribute__((always_inline)) static INLINE float
pressure_floor_get_physical_pressure(const struct part* p,
const float pressure_physical,
const struct cosmology* cosmo) {
const float H_phys = p->h * cosmo->a_inv * kernel_gamma;
const float rho = hydro_get_physical_density(p, cosmo);
/* Compute the pressure floor */
float floor = H_phys * H_phys * rho * pressure_floor_props.constants -
p->pressure_floor_data.sigma2;
p->pressure_floor_data.sigma2;
floor *= rho * hydro_one_over_gamma;
return fmaxf(pressure_physical, floor);
......@@ -88,14 +92,17 @@ __attribute__((always_inline)) static INLINE float pressure_floor_get_physical_p
*
* @return The physical or comoving pressure with the floor.
*/
__attribute__((always_inline)) static INLINE float pressure_floor_get_comoving_pressure(
const struct part* p, const float pressure_comoving, const struct cosmology *cosmo) {
__attribute__((always_inline)) static INLINE float
pressure_floor_get_comoving_pressure(const struct part* p,
const float pressure_comoving,
const struct cosmology* cosmo) {
const float a_coef = pow_three_gamma_minus_one(cosmo->a);
const float rho = hydro_get_comoving_density(p);
/* Compute the pressure floor */
float floor = kernel_gamma * kernel_gamma * p->h * p->h * rho * pressure_floor_props.constants;
float floor = kernel_gamma * kernel_gamma * p->h * p->h * rho *
pressure_floor_props.constants;
floor -= p->pressure_floor_data.sigma2 * cosmo->a * cosmo->a;
floor *= a_coef * rho * hydro_one_over_gamma;
......
......@@ -55,15 +55,10 @@ __attribute__((always_inline)) INLINE static void runner_iact_pressure_floor(
/* Compute the velocity dispersion */
const float a2H = a * a * H;
const float sigma[3] = {
dv[0] + a2H * dx[0],
dv[1] + a2H * dx[1],
dv[2] + a2H * dx[2]
};
const float sigma[3] = {dv[0] + a2H * dx[0], dv[1] + a2H * dx[1],
dv[2] + a2H * dx[2]};
const float sigma2 =
sigma[0] * sigma[0] +
sigma[1] * sigma[1] +
sigma[2] * sigma[2];
sigma[0] * sigma[0] + sigma[1] * sigma[1] + sigma[2] * sigma[2];
/* Compute the velocity dispersion */
pi->pressure_floor_data.sigma2 += sigma2 * wi * hydro_get_mass(pj);
......@@ -97,15 +92,10 @@ runner_iact_nonsym_pressure_floor(float r2, const float *dx, float hi, float hj,
/* Compute the velocity dispersion */
const float a2H = a * a * H;
const float sigma[3] = {
dv[0] + a2H * dx[0],
dv[1] + a2H * dx[1],
dv[2] + a2H * dx[2]
};
const float sigma[3] = {dv[0] + a2H * dx[0], dv[1] + a2H * dx[1],
dv[2] + a2H * dx[2]};
const float sigma2 =
sigma[0] * sigma[0] +
sigma[1] * sigma[1] +
sigma[2] * sigma[2];
sigma[0] * sigma[0] + sigma[1] * sigma[1] + sigma[2] * sigma[2];
/* Compute the velocity dispersion */
pi->pressure_floor_data.sigma2 += sigma2 * wi * hydro_get_mass(pj);
......
......@@ -49,7 +49,8 @@ struct pressure_floor_properties {};
* @return The physical pressure with the floor.
*/
static INLINE float pressure_floor_get_physical_pressure(
const struct part* p, const float physical_pressure, const struct cosmology *cosmo) {
const struct part* p, const float physical_pressure,
const struct cosmology* cosmo) {
return physical_pressure;
}
......@@ -65,7 +66,8 @@ static INLINE float pressure_floor_get_physical_pressure(
* @return The comoving pressure with the floor.
*/
static INLINE float pressure_floor_get_comoving_pressure(
const struct part* p, const float comoving_pressure, const struct cosmology *cosmo) {
const struct part* p, const float comoving_pressure,
const struct cosmology* cosmo) {
return comoving_pressure;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment