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
d6ebadaf
Commit
d6ebadaf
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
When updating the sound-speed of a particle, also update its signal velocity.
parent
cac2e78f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/hydro/Gadget2/hydro.h
+19
-4
19 additions, 4 deletions
src/hydro/Gadget2/hydro.h
src/hydro/Minimal/hydro.h
+19
-4
19 additions, 4 deletions
src/hydro/Minimal/hydro.h
src/hydro/PressureEntropy/hydro.h
+21
-4
21 additions, 4 deletions
src/hydro/PressureEntropy/hydro.h
with
59 additions
and
12 deletions
src/hydro/Gadget2/hydro.h
+
19
−
4
View file @
d6ebadaf
...
...
@@ -37,6 +37,7 @@
#include
"equation_of_state.h"
#include
"hydro_properties.h"
#include
"kernel_hydro.h"
#include
"minmax.h"
/**
* @brief Returns the internal energy of a particle
...
...
@@ -116,8 +117,9 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
* @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
* This overwrites the current state of the particle but does *not* change its
* time-derivatives. Entropy, pressure, sound-speed and signal velocity will be
* updated.
*
* @param p The particle
* @param u The new internal energy
...
...
@@ -133,17 +135,24 @@ __attribute__((always_inline)) INLINE static void hydro_set_internal_energy(
/* Compute the new sound speed */
const
float
soundspeed
=
gas_soundspeed_from_pressure
(
p
->
rho
,
pressure
);
/* Update the signal velocity */
const
float
v_sig_old
=
p
->
force
.
v_sig
;
const
float
v_sig_new
=
p
->
force
.
v_sig
-
p
->
force
.
soundspeed
+
soundspeed
;
const
float
v_sig
=
max
(
v_sig_old
,
v_sig_new
);
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
p
->
force
.
v_sig
=
v_sig
;
}
/**
* @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
* This overwrites the current state of the particle but does *not* change its
* time-derivatives. Entropy, pressure, sound-speed and signal velocity will be
* updated.
*
* @param p The particle
* @param S The new entropy
...
...
@@ -159,10 +168,16 @@ __attribute__((always_inline)) INLINE static void hydro_set_entropy(
/* Compute the new sound speed */
const
float
soundspeed
=
gas_soundspeed_from_pressure
(
p
->
rho
,
pressure
);
/* Update the signal velocity */
const
float
v_sig_old
=
p
->
force
.
v_sig
;
const
float
v_sig_new
=
p
->
force
.
v_sig
-
p
->
force
.
soundspeed
+
soundspeed
;
const
float
v_sig
=
max
(
v_sig_old
,
v_sig_new
);
const
float
rho_inv
=
1
.
f
/
p
->
rho
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
P_over_rho2
=
pressure
*
rho_inv
*
rho_inv
;
p
->
force
.
v_sig
=
v_sig
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/hydro/Minimal/hydro.h
+
19
−
4
View file @
d6ebadaf
...
...
@@ -39,6 +39,7 @@
#include
"equation_of_state.h"
#include
"hydro_properties.h"
#include
"kernel_hydro.h"
#include
"minmax.h"
/**
* @brief Returns the internal energy of a particle
...
...
@@ -124,8 +125,9 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
* @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
* This overwrites the current state of the particle but does *not* change its
* time-derivatives. Internal energy, pressure, sound-speed and signal velocity
* will be updated.
*
* @param p The particle
* @param u The new internal energy
...
...
@@ -141,15 +143,22 @@ __attribute__((always_inline)) INLINE static void hydro_set_internal_energy(
/* Compute the new sound speed */
const
float
soundspeed
=
gas_soundspeed_from_internal_energy
(
p
->
rho
,
p
->
u
);
/* Update the signal velocity */
const
float
v_sig_old
=
p
->
force
.
v_sig
;
const
float
v_sig_new
=
p
->
force
.
v_sig
-
p
->
force
.
soundspeed
+
soundspeed
;
const
float
v_sig
=
max
(
v_sig_old
,
v_sig_new
);
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
pressure
=
pressure
;
p
->
force
.
v_sig
=
v_sig
;
}
/**
* @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
* This overwrites the current state of the particle but does *not* change its
* time-derivatives. Internal energy, pressure, sound-speed and signal velocity
* will be updated.
*
* @param p The particle
* @param S The new entropy
...
...
@@ -165,8 +174,14 @@ __attribute__((always_inline)) INLINE static void hydro_set_entropy(
/* Compute the new sound speed */
const
float
soundspeed
=
gas_soundspeed_from_internal_energy
(
p
->
rho
,
p
->
u
);
/* Update the signal velocity */
const
float
v_sig_old
=
p
->
force
.
v_sig
;
const
float
v_sig_new
=
p
->
force
.
v_sig
-
p
->
force
.
soundspeed
+
soundspeed
;
const
float
v_sig
=
max
(
v_sig_old
,
v_sig_new
);
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
pressure
=
pressure
;
p
->
force
.
v_sig
=
v_sig
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/hydro/PressureEntropy/hydro.h
+
21
−
4
View file @
d6ebadaf
...
...
@@ -37,6 +37,7 @@
#include
"equation_of_state.h"
#include
"hydro_properties.h"
#include
"kernel_hydro.h"
#include
"minmax.h"
/**
* @brief Returns the internal energy of a particle
...
...
@@ -116,8 +117,9 @@ __attribute__((always_inline)) INLINE static float hydro_get_mass(
* @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
* This overwrites the current state of the particle but does *not* change its
* time-derivatives. Entropy, pressure, sound-speed and signal velocity will be
* updated.
*
* @param p The particle
* @param u The new internal energy
...
...
@@ -133,17 +135,25 @@ __attribute__((always_inline)) INLINE static void hydro_set_internal_energy(
/* Compute the sound speed from the pressure*/
const
float
soundspeed
=
gas_soundspeed_from_pressure
(
p
->
rho_bar
,
pressure
);
/* Update the signal velocity */
const
float
v_sig_old
=
p
->
force
.
v_sig
;
const
float
v_sig_new
=
p
->
force
.
v_sig
-
p
->
force
.
soundspeed
+
soundspeed
;
const
float
v_sig
=
max
(
v_sig_old
,
v_sig_new
);
const
float
rho_bar_inv
=
1
.
f
/
p
->
rho_bar
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
P_over_rho2
=
pressure
*
rho_bar_inv
*
rho_bar_inv
;
p
->
force
.
v_sig
=
v_sig
;
}
/**
* @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
* This overwrites the current state of the particle but does *not* change its
* time-derivatives. Entropy, pressure, sound-speed and signal velocity will be
* updated.
*
* @param p The particle
* @param S The new entropy
...
...
@@ -159,10 +169,17 @@ __attribute__((always_inline)) INLINE static void hydro_set_entropy(
/* Compute the sound speed from the pressure*/
const
float
soundspeed
=
gas_soundspeed_from_pressure
(
p
->
rho_bar
,
pressure
);
/* Update the signal velocity */
const
float
v_sig_old
=
p
->
force
.
v_sig
;
const
float
v_sig_new
=
p
->
force
.
v_sig
-
p
->
force
.
soundspeed
+
soundspeed
;
const
float
v_sig
=
max
(
v_sig_old
,
v_sig_new
);
const
float
rho_bar_inv
=
1
.
f
/
p
->
rho_bar
;
p
->
force
.
soundspeed
=
soundspeed
;
p
->
force
.
P_over_rho2
=
pressure
*
rho_bar_inv
*
rho_bar_inv
;
p
->
force
.
v_sig
=
v_sig
;
}
/**
...
...
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