Skip to content
Snippets Groups Projects
Commit 70e8162c authored by Josh Borrow's avatar Josh Borrow
Browse files

Added new functions required by code; hydro_set_mass, and hydro_set_init_internal_energy

parent 0fa621b1
No related branches found
No related tags found
1 merge request!540Add Pressure-Energy (P-U) SPH
...@@ -198,6 +198,18 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass( ...@@ -198,6 +198,18 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
return p->mass; return p->mass;
} }
/**
* @brief Sets the mass of a particle
*
* @param p The particle of interest
* @param m The mass to set.
*/
__attribute__((always_inline)) INLINE static void hydro_set_mass(
struct part *restrict p, float m) {
p->mass = m;
}
/** /**
* @brief Returns the velocities drifted to the current time of a particle. * @brief Returns the velocities drifted to the current time of a particle.
* *
...@@ -233,7 +245,7 @@ __attribute__((always_inline)) INLINE static float hydro_get_internal_energy_dt( ...@@ -233,7 +245,7 @@ __attribute__((always_inline)) INLINE static float hydro_get_internal_energy_dt(
} }
/** /**
* @brief Returns the time derivative of internal energy of a particle * @brief Sets the time derivative of internal energy of a particle
* *
* We assume a constant density. * We assume a constant density.
* *
...@@ -245,6 +257,7 @@ __attribute__((always_inline)) INLINE static void hydro_set_internal_energy_dt( ...@@ -245,6 +257,7 @@ __attribute__((always_inline)) INLINE static void hydro_set_internal_energy_dt(
p->u_dt = du_dt; p->u_dt = du_dt;
} }
/** /**
* @brief Computes the hydro time-step of a given particle * @brief Computes the hydro time-step of a given particle
* *
...@@ -525,7 +538,9 @@ __attribute__((always_inline)) INLINE static void hydro_end_force( ...@@ -525,7 +538,9 @@ __attribute__((always_inline)) INLINE static void hydro_end_force(
* @param dt_therm The time-step for this kick (for thermodynamic quantities). * @param dt_therm The time-step for this kick (for thermodynamic quantities).
*/ */
__attribute__((always_inline)) INLINE static void hydro_kick_extra( __attribute__((always_inline)) INLINE static void hydro_kick_extra(
struct part *restrict p, struct xpart *restrict xp, float dt_therm) { struct part *restrict p, struct xpart *restrict xp, float dt_therm,
const struct cosmology *cosmo,
const struct hydro_props *restrict hydro_properties) {
/* Do not decrease the energy by more than a factor of 2*/ /* Do not decrease the energy by more than a factor of 2*/
if (dt_therm > 0. && p->u_dt * dt_therm < -0.5f * xp->u_full) { if (dt_therm > 0. && p->u_dt * dt_therm < -0.5f * xp->u_full) {
...@@ -555,7 +570,8 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra( ...@@ -555,7 +570,8 @@ __attribute__((always_inline)) INLINE static void hydro_kick_extra(
* @param xp The extended particle to act upon * @param xp The extended particle to act upon
*/ */
__attribute__((always_inline)) INLINE static void hydro_convert_quantities( __attribute__((always_inline)) INLINE static void hydro_convert_quantities(
struct part *restrict p, struct xpart *restrict xp) { struct part *restrict p, struct xpart *restrict xp,
const struct cosmology *cosmo) {
/* Compute the pressure */ /* Compute the pressure */
const float pressure = gas_pressure_from_internal_energy(p->rho, p->u); const float pressure = gas_pressure_from_internal_energy(p->rho, p->u);
...@@ -593,4 +609,21 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part( ...@@ -593,4 +609,21 @@ __attribute__((always_inline)) INLINE static void hydro_first_init_part(
hydro_init_part(p, NULL); hydro_init_part(p, NULL);
} }
/**
* @brief Overwrite the initial internal energy of a particle.
*
* Note that in the cases where the thermodynamic variable is not
* internal energy but gets converted later, we must overwrite that
* field. The conversion to the actual variable happens later after
* the initial fake time-step.
*
* @param p The #part to write to.
* @param u_init The new initial internal energy.
*/
__attribute__((always_inline)) INLINE static void
hydro_set_init_internal_energy(struct part *p, float u_init) {
p->u = u_init;
}
#endif /* SWIFT_MINIMAL_HYDRO_H */ #endif /* SWIFT_MINIMAL_HYDRO_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment