Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
d949f23a
Commit
d949f23a
authored
6 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Added the new function getters also to the Minimal hydro scheme
parent
cb998cc5
No related branches found
No related tags found
1 merge request
!628
Cosmo cooling
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/hydro/Minimal/hydro.h
+113
-34
113 additions, 34 deletions
src/hydro/Minimal/hydro.h
src/hydro/Minimal/hydro_io.h
+1
-1
1 addition, 1 deletion
src/hydro/Minimal/hydro_io.h
with
114 additions
and
35 deletions
src/hydro/Minimal/hydro.h
+
113
−
34
View file @
d949f23a
...
...
@@ -44,34 +44,56 @@
#include
"minmax.h"
/**
* @brief Returns the comoving internal energy of a particle
*
* For implementations where the main thermodynamic variable
* is not internal energy, this function computes the internal
* energy from the thermodynamic variable.
* @brief Returns the comoving internal energy of a particle at the last
* time the particle was kicked.
*
* @param p The particle of interest
* @param xp The extended data of the particle of interest.
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_comoving_internal_energy
(
const
struct
part
*
restrict
p
)
{
hydro_get_comoving_internal_energy
(
const
struct
part
*
restrict
p
,
const
struct
xpart
*
restrict
xp
)
{
return
p
->
u
;
return
x
p
->
u
_full
;
}
/**
* @brief Returns the physical internal energy of a particle
*
* For implementations where the main thermodynamic variable
* is not internal energy, this function computes the internal
* energy from the thermodynamic variable and converts it to
* physical coordinates.
* @brief Returns the physical internal energy of a particle at the last
* time the particle was kicked.
*
* @param p The particle of interest.
* @param xp The extended data of the particle of interest.
* @param cosmo The cosmological model.
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_physical_internal_energy
(
const
struct
part
*
restrict
p
,
const
struct
xpart
*
restrict
xp
,
const
struct
cosmology
*
cosmo
)
{
return
xp
->
u_full
*
cosmo
->
a_factor_internal_energy
;
}
/**
* @brief Returns the comoving internal energy of a particle drifted to the
* current time.
*
* @param p The particle of interest
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_drifted_comoving_internal_energy
(
const
struct
part
*
restrict
p
)
{
return
p
->
u
;
}
/**
* @brief Returns the physical internal energy of a particle drifted to the
* current time.
*
* @param p The particle of interest.
* @param cosmo The cosmological model.
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_drifted_physical_internal_energy
(
const
struct
part
*
restrict
p
,
const
struct
cosmology
*
cosmo
)
{
return
p
->
u
*
cosmo
->
a_factor_internal_energy
;
}
...
...
@@ -106,33 +128,57 @@ __attribute__((always_inline)) INLINE static float hydro_get_physical_pressure(
}
/**
* @brief Returns the comoving entropy of a particle
* @brief Returns the comoving entropy of a particle at the last
* time the particle was kicked.
*
* For implementations where the main thermodynamic variable
* is not entropy, this function computes the entropy from
* the thermodynamic variable.
*
* @param p The particle of interest
* @param p The particle of interest.
* @param xp The extended data of the particle of interest.
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_comoving_entropy
(
const
struct
part
*
restrict
p
)
{
const
struct
part
*
restrict
p
,
const
struct
xpart
*
restrict
xp
)
{
return
gas_entropy_from_internal_energy
(
p
->
rho
,
p
->
u
);
return
gas_entropy_from_internal_energy
(
p
->
rho
,
x
p
->
u
_full
);
}
/**
* @brief Returns the physical entropy of a particle
* @brief Returns the physical entropy of a particl at the last
* time the particle was kicked.
*
* For implementations where the main thermodynamic variable
* is not entropy, this function computes the entropy from
* the thermodynamic variable and converts it to
* physical coordinates.
*
* @param p The particle of interest
* @param p The particle of interest.
* @param xp The extended data of the particle of interest.
* @param cosmo The cosmological model.
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_physical_entropy
(
const
struct
part
*
restrict
p
,
const
struct
cosmology
*
cosmo
)
{
const
struct
part
*
restrict
p
,
const
struct
xpart
*
restrict
xp
,
const
struct
cosmology
*
cosmo
)
{
/* Note: no cosmological conversion required here with our choice of
* coordinates. */
return
gas_entropy_from_internal_energy
(
p
->
rho
,
xp
->
u_full
);
}
/**
* @brief Returns the comoving entropy of a particle drifted to the
* current time.
*
* @param p The particle of interest.
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_drifted_comoving_entropy
(
const
struct
part
*
restrict
p
)
{
return
gas_entropy_from_internal_energy
(
p
->
rho
,
p
->
u
);
}
/**
* @brief Returns the physical entropy of a particle drifted to the
* current time.
*
* @param p The particle of interest.
* @param cosmo The cosmological model.
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_drifted_physical_entropy
(
const
struct
part
*
restrict
p
,
const
struct
cosmology
*
cosmo
)
{
/* Note: no cosmological conversion required here with our choice of
* coordinates. */
...
...
@@ -231,14 +277,14 @@ __attribute__((always_inline)) INLINE static void hydro_get_drifted_velocities(
}
/**
* @brief Returns the time derivative of internal energy of a particle
* @brief Returns the time derivative of
co-moving
internal energy of a particle
*
* We assume a constant density.
*
* @param p The particle of interest
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_internal_energy_dt
(
const
struct
part
*
restrict
p
)
{
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_comoving_internal_energy_dt
(
const
struct
part
*
restrict
p
)
{
return
p
->
u_dt
;
}
...
...
@@ -248,14 +294,47 @@ __attribute__((always_inline)) INLINE static float hydro_get_internal_energy_dt(
*
* We assume a constant density.
*
* @param p The particle of interest
* @param cosmo Cosmology data structure
*/
__attribute__
((
always_inline
))
INLINE
static
float
hydro_get_physical_internal_energy_dt
(
const
struct
part
*
restrict
p
,
const
struct
cosmology
*
cosmo
)
{
return
p
->
u_dt
*
cosmo
->
a_factor_internal_energy
;
}
/**
* @brief Sets the time derivative of the co-moving internal energy of a
* particle
*
* We assume a constant density for the conversion to entropy.
*
* @param p The particle of interest.
* @param du_dt The new time derivative of the internal energy.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_set_internal_energy_dt
(
struct
part
*
restrict
p
,
float
du_dt
)
{
__attribute__
((
always_inline
))
INLINE
static
void
hydro_set_comoving_internal_energy_dt
(
struct
part
*
restrict
p
,
float
du_dt
)
{
p
->
u_dt
=
du_dt
;
}
/**
* @brief Returns the time derivative of internal energy of a particle
*
* We assume a constant density.
*
* @param p The particle of interest.
* @param cosmo Cosmology data structure
* @param du_dt The new time derivative of the internal energy.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_set_physical_internal_energy_dt
(
struct
part
*
restrict
p
,
const
struct
cosmology
*
cosmo
,
float
du_dt
)
{
p
->
u_dt
=
du_dt
*
cosmo
->
a_factor_internal_energy
;
}
/**
* @brief Computes the hydro time-step of a given particle
*
...
...
This diff is collapsed.
Click to expand it.
src/hydro/Minimal/hydro_io.h
+
1
−
1
View file @
d949f23a
...
...
@@ -73,7 +73,7 @@ INLINE static void hydro_read_particles(struct part* parts,
INLINE
static
void
convert_S
(
const
struct
engine
*
e
,
const
struct
part
*
p
,
const
struct
xpart
*
xp
,
float
*
ret
)
{
ret
[
0
]
=
hydro_get_comoving_entropy
(
p
);
ret
[
0
]
=
hydro_get_comoving_entropy
(
p
,
xp
);
}
INLINE
static
void
convert_P
(
const
struct
engine
*
e
,
const
struct
part
*
p
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment