Commit 4ae9ab16 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Brought the PE-SPH implementation back to speed with the rest of the code.

parent c98eeca5
......@@ -432,4 +432,40 @@ __attribute__((always_inline)) INLINE static float pow_one_over_gamma(float x) {
#endif
}
/**
* @brief Return the argument to the power one minus two over the adiabatic
* index
*
* Computes \f$x^{1 - \frac{2}{\gamma}}\f$.
*
* @param x Argument
* @return Argument to the power one minus two over the adiabatic index
*/
__attribute__((always_inline)) INLINE static float pow_one_minus_two_over_gamma(
float x) {
#if defined(HYDRO_GAMMA_5_3)
return powf(x, -0.2f);
#elif defined(HYDRO_GAMMA_7_5)
return powf(x, -0.428571429f);
#elif defined(HYDRO_GAMMA_4_3)
return 1.f / sqrtf(x);
#elif defined(HYDRO_GAMMA_2_1)
return 1.f;
#else
error("The adiabatic index is not defined !");
return 0.f;
#endif
}
#endif /* SWIFT_ADIABATIC_INDEX_H */
......@@ -20,8 +20,9 @@
#define SWIFT_PRESSURE_ENTROPY_HYDRO_H
/**
* @file PressureEntropy/hydro_part.h
* @brief Pressure-Entropy implementation of SPH (Particle definition)
* @file PressureEntropy/hydro.h
* @brief Pressure-Entropy implementation of SPH (Non-neighbour loop
* equations)
*
* The thermal variable is the entropy (S) and the entropy is smoothed over
* contact discontinuities to prevent spurious surface tension.
......@@ -88,6 +89,28 @@ __attribute__((always_inline)) INLINE static float hydro_get_soundspeed(
return p->force.soundspeed;
}
/**
* @brief Returns the density of a particle
*
* @param p The particle of interest
*/
__attribute__((always_inline)) INLINE static float hydro_get_density(
const struct part *restrict p) {
return p->rho;
}
/**
* @brief Returns the mass of a particle
*
* @param p The particle of interest
*/
__attribute__((always_inline)) INLINE static float hydro_get_mass(
const struct part *restrict p) {
return p->mass;
}
/**
* @brief Modifies the thermal state of a particle to the imposed internal
* energy
......@@ -301,8 +324,8 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration(
* @param timeBase The minimal time-step size
*/
__attribute__((always_inline)) INLINE static void hydro_predict_extra(
struct part *restrict p, const struct xpart *restrict xp, int t0, int t1,
double timeBase) {
struct part *restrict p, const struct xpart *restrict xp, float dt, int t0,
int t1, double timeBase) {
/* Drift the pressure */
const float dt_entr = (t1 - (p->ti_begin + p->ti_end) / 2) * timeBase;
......
......@@ -21,7 +21,7 @@
/**
* @file PressureEntropy/hydro_debug.h
* @brief Pressure-Entropy implementation of SPH (Particle definition)
* @brief Pressure-Entropy implementation of SPH (Debugging routines)
*
* The thermal variable is the entropy (S) and the entropy is smoothed over
* contact discontinuities to prevent spurious surface tension.
......
......@@ -20,8 +20,8 @@
#define SWIFT_PRESSURE_ENTROPY_HYDRO_IACT_H
/**
* @file PressureEntropy/hydro_part.h
* @brief Pressure-Entropy implementation of SPH (Particle definition)
* @file PressureEntropy/hydro_iact.h
* @brief Pressure-Entropy implementation of SPH (Neighbour loop equations)
*
* The thermal variable is the entropy (S) and the entropy is smoothed over
* contact discontinuities to prevent spurious surface tension.
......
......@@ -21,7 +21,7 @@
/**
* @file PressureEntropy/hydro_io.h
* @brief Pressure-Entropy implementation of SPH (Particle definition)
* @brief Pressure-Entropy implementation of SPH (i/o routines)
*
* The thermal variable is the entropy (S) and the entropy is smoothed over
* contact discontinuities to prevent spurious surface tension.
......
......@@ -29,100 +29,105 @@
* Follows Hopkins, P., MNRAS, 2013, Volume 428, Issue 4, pp. 2840-2856
*/
#include "cooling_struct.h"
/* Extra particle data not needed during the SPH loops over neighbours. */
struct xpart {
/* Offset between current position and position at last tree rebuild. */
/*! Offset between current position and position at last tree rebuild. */
float x_diff[3];
/* Velocity at the last full step. */
/*! Velocity at the last full step. */
float v_full[3];
} __attribute__((aligned(xpart_align)));
/*! Additional data used to record cooling information */
struct cooling_xpart_data cooling_data;
} SWIFT_STRUCT_ALIGN;
/* Data of a single particle. */
struct part {
/* Particle position. */
/*! Particle position. */
double x[3];
/* Particle predicted velocity. */
/*! Particle predicted velocity. */
float v[3];
/* Particle acceleration. */
/*! Particle acceleration. */
float a_hydro[3];
/* Particle cutoff radius. */
/*! Particle cutoff radius. */
float h;
/* Particle mass. */
/*! Particle mass. */
float mass;
/* Particle time of beginning of time-step. */
/*! Particle time of beginning of time-step. */
int ti_begin;
/* Particle time of end of time-step. */
/*! Particle time of end of time-step. */
int ti_end;
/* Particle density. */
/*! Particle density. */
float rho;
/* Particle weighted pressure. */
/*! Particle weighted pressure. */
float weightedPressure;
/* Particle entropy. */
/*! Particle entropy. */
float entropy;
/* Entropy time derivative */
/*! Entropy time derivative */
float entropy_dt;
union {
struct {
/* Number of neighbours. */
/*! Number of neighbours. */
float wcount;
/* Number of neighbours spatial derivative. */
/*! Number of neighbours spatial derivative. */
float wcount_dh;
/* Derivative of particle weighted pressure with h. */
/*! Derivative of particle weighted pressure with h. */
float weightedPressure_dh;
/* Particle velocity curl. */
/*! Particle velocity curl. */
// float rot_v[3];
/* Particle velocity divergence. */
/*! Particle velocity divergence. */
// float div_v;
} density;
struct {
/* "Grad h" term */
/*! "Grad h" term */
float f_ij;
/* Pressure term */
/*! Pressure term */
float pressure_term;
/* Particle sound speed. */
/*! Particle sound speed. */
float soundspeed;
/* Signal velocity. */
/*! Signal velocity. */
float v_sig;
/* Time derivative of the smoothing length */
/*! Time derivative of the smoothing length */
float h_dt;
} force;
};
/* Particle ID. */
/*! Particle ID. */
long long id;
/* Pointer to corresponding gravity part. */
/*! Pointer to corresponding gravity part. */
struct gpart* gpart;
} __attribute__((aligned(part_align)));
} SWIFT_STRUCT_ALIGN;
#endif /* SWIFT_PRESSURE_ENTROPY_HYDRO_PART_H */
Supports Markdown
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