Commit a8008abe authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Added setter functions to modify the internal thermal state of particles

parent 8e2b479e
......@@ -42,8 +42,8 @@
//#define HYDRO_GAMMA_2_1
/* Equation of state choice */
#define IDEAL_GAS
//#define ISOTHERMAL_GAS
#define EOS_IDEAL_GAS
//#define EOS_ISOTHERMAL_GAS
/* Kernel function to use */
#define CUBIC_SPLINE_KERNEL
......
......@@ -32,7 +32,7 @@
#include "inline.h"
/* ------------------------------------------------------------------------- */
#if defined(IDEAL_GAS)
#if defined(EOS_IDEAL_GAS)
/**
* @brief Returns the internal energy given density and entropy
......@@ -120,7 +120,7 @@ gas_soundspeed_from_internal_energy(float density, float u) {
}
/* ------------------------------------------------------------------------- */
#elif defined(ISOTHERMAL_GAS)
#elif defined(EOS_ISOTHERMAL_GAS)
/**
* @brief Returns the internal energy given density and entropy
......
......@@ -71,6 +71,37 @@ __attribute__((always_inline)) INLINE static float hydro_get_soundspeed(
return p->force.soundspeed;
}
/**
* @brief Modifies the thermal state of a particle to the imposed internal
* energy
*
* This overrides the current state of the particle but does not change the
* time-derivatives
*
* @param p The particle
* @param u The new internal energy
*/
__attribute__((always_inline)) INLINE static void hydro_set_internal_energy(
struct part *restrict p, float u) {
p->u = u;
}
/**
* @brief Modifies the thermal state of a particle to the imposed entropy
*
* This overrides the current state of the particle but does not change the
* time-derivatives
*
* @param p The particle
* @param S The new entropy
*/
__attribute__((always_inline)) INLINE static void hydro_set_entropy(
struct part *restrict p, float S) {
p->u = gas_internal_energy_from_entropy(p->rho, S);
}
/**
* @brief Computes the hydro time-step of a given particle
*
......
......@@ -72,6 +72,37 @@ __attribute__((always_inline)) INLINE static float hydro_get_soundspeed(
return p->force.soundspeed;
}
/**
* @brief Modifies the thermal state of a particle to the imposed internal
* energy
*
* This overrides the current state of the particle but does *not* change its
* time-derivatives
*
* @param p The particle
* @param u The new internal energy
*/
__attribute__((always_inline)) INLINE static void hydro_set_internal_energy(
struct part *restrict p, float u) {
p->entropy = gas_entropy_from_internal_energy(p->rho, u);
}
/**
* @brief Modifies the thermal state of a particle to the imposed entropy
*
* This overrides the current state of the particle but does *not* change its
* time-derivatives
*
* @param p The particle
* @param S The new entropy
*/
__attribute__((always_inline)) INLINE static void hydro_set_entropy(
struct part *restrict p, float S) {
p->entropy = S;
}
/**
* @brief Computes the hydro time-step of a given particle
*
......
......@@ -77,6 +77,37 @@ __attribute__((always_inline)) INLINE static float hydro_get_soundspeed(
return gas_soundspeed_from_internal_energy(p->rho, p->u);
}
/**
* @brief Modifies the thermal state of a particle to the imposed internal
* energy
*
* This overrides the current state of the particle but does *not* change its
* time-derivatives
*
* @param p The particle
* @param u The new internal energy
*/
__attribute__((always_inline)) INLINE static void hydro_set_internal_energy(
struct part *restrict p, float u) {
p->u = u;
}
/**
* @brief Modifies the thermal state of a particle to the imposed entropy
*
* This overrides the current state of the particle but does *not* change its
* time-derivatives
*
* @param p The particle
* @param S The new entropy
*/
__attribute__((always_inline)) INLINE static void hydro_set_entropy(
struct part *restrict p, float S) {
p->u = gas_internal_energy_from_entropy(p->rho, S);
}
/**
* @brief Computes the hydro time-step of a given particle
*
......
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